• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python ui.error函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中qisys.ui.error函数的典型用法代码示例。如果您正苦于以下问题:Python error函数的具体用法?Python error怎么用?Python error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了error函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: get_log

    def get_log(self, before_ref, after_ref):
        """ Return a list of commits between two refspecs, in
        natural order (most recent commits last)

        Each commit is a dict containing, 'sha1' and 'message'

        FIXME: parse author and date ?
        """
        # old git does not support -z and inists on adding \n
        # between log entries, so we have no choice but choose
        # a custom separator. '\f' looks safe enough
        res = list()
        rc, out = self.call("log", "--reverse",
                            "--format=%H%n%B\f",
                            "%s..%s" % (before_ref, after_ref),
                            raises=False)
        if rc != 0:
            ui.error(out)
            return res
        for log_chunk in out.split('\f'):
            if not log_chunk:
                continue
            log_chunk = log_chunk.strip()
            sha1, message = log_chunk.split('\n', 1)
            message = message.strip()
            commit = {
                "sha1" : sha1,
                "message" : message,
            }
            res.append(commit)
        return res
开发者ID:Giessen,项目名称:qibuild,代码行数:31,代码来源:git.py


示例2: configure_virtualenv

def configure_virtualenv(config, python_worktree,  build_worktree=None,
                         remote_packages=None, site_packages=True):
    if not remote_packages:
        remote_packages = list()

    # create a new virtualenv
    python_worktree.config = config
    venv_path = python_worktree.venv_path
    pip = python_worktree.pip

    try:
        virtualenv.create_environment(python_worktree.venv_path,
                                      site_packages=site_packages)
    except:
        ui.error("Failed to create virtualenv")
        return

    # Install all Python projects using pip install -e .
    python_projects = python_worktree.python_projects
    for i, project in enumerate(python_projects):
        ui.info_count(i, len(python_projects),
                     ui.green, "Configuring", ui.reset, ui.blue, project.src)
        cmd = [pip, "install", "--editable", "."]
        qisys.command.call(cmd, cwd=project.path)

    # Write a qi.pth file containing path to C/C++ extensions
    if build_worktree:
        handle_extensions(venv_path, python_worktree, build_worktree)

    # Install the extension in the virtualenv
    binaries_path = virtualenv.path_locations(venv_path)[-1]
    pip_binary = os.path.join(binaries_path, "pip")
    if remote_packages:
        cmd = [pip_binary, "install"] + remote_packages
        subprocess.check_call(cmd)
开发者ID:cgestes,项目名称:qibuild,代码行数:35,代码来源:venv.py


示例3: main_wrapper

def main_wrapper(module, args):
    """This wraps the main method of an action so that:
       - backtrace is not printed by default
       - backtrace is printed is --backtrace was given
       - a pdb session is run if --pdb was given
    """
    try:
        module.do(args)
    except Exception as e:
        if args.pdb:
            traceback = sys.exc_info()[2]
            print ""
            print "### Exception:", e
            print "### Starting a debugger"
            try:
                import ipdb
                ipdb.post_mortem(traceback)
                sys.exit(0)
            except ImportError:
                import pdb
                pdb.post_mortem(traceback)
                sys.exit(0)
        if args.backtrace:
            raise
        ui.error(e)
        sys.exit(2)
开发者ID:bithium,项目名称:qibuild,代码行数:26,代码来源:script.py


示例4: generate_mo_file

    def generate_mo_file(self, locale):
        """ Generate .mo file for the given locale

        """
        ui.info(ui.green, "Generating translation for", ui.reset,
                ui.bold, locale)
        input_file = self.get_po_file(locale)
        if not os.path.exists(input_file):
            ui.error("No .po found for locale: ", locale, "\n",
                     "(looked in %s)" % input_file, "\n",
                     "Did you run qilinguist update?")
            return

        output_file = os.path.join(self.mo_path, locale, "LC_MESSAGES",
                                   self.domain + ".mo")
        to_make = os.path.dirname(output_file)
        qisys.sh.mkdir(to_make, recursive=True)

        cmd = ["msgfmt", "--check", "--statistics"]

        # required by libqi:
        conf_file = os.path.join(self.mo_path, ".confintl")
        with open(conf_file, "w") as fp:
            fp.write("# THIS FILE IS AUTOGENERATED\n"
                    "#Do not delete or modify it\n"
                    "# This file is used to find translation dictionaries\n")

        cmd.extend(["--output-file", output_file])
        cmd.extend(["--directory", self.po_path])
        cmd.append(input_file)

        qisys.command.call(cmd)
开发者ID:Giessen,项目名称:qibuild,代码行数:32,代码来源:qigettext.py


示例5: do

def do(args):
    """ Main entry point """
    git_worktree = qisrc.parsers.get_git_worktree(args)
    git_project = qisrc.parsers.get_one_git_project(git_worktree, args)
    git = qisrc.git.Git(git_project.path)
    current_branch = git.get_current_branch()
    if not current_branch:
        ui.error("Not currently on any branch")
        sys.exit(2)
    if git_project.review:
        maintainers = qisrc.maintainers.get(git_project, warn_if_none=True)
        reviewers = [x['email'] for x in maintainers]
        reviewers.extend(args.reviewers or list())
        # Prefer gerrit logins or groups instead of e-mails
        reviewers = [x.split("@")[0] for x in reviewers]
        qisrc.review.push(git_project, current_branch,
                          bypass_review=(not args.review),
                          dry_run=args.dry_run, reviewers=reviewers,
                          topic=args.topic)
    else:
        if args.dry_run:
            git.push("-n")
        else:
            if args.review and not args.yes:
                mess = """\
The project is not under code review.
Are you sure you want to run `git push` ?
This action cannot be undone\
"""
                answer = qisys.interact.ask_yes_no(mess, default=False)
                if answer:
                    git.push()
            else:
                git.push()
开发者ID:aldebaran,项目名称:qibuild,代码行数:34,代码来源:push.py


示例6: checkout

    def checkout(self, branch, force=False):
        """ Called by ``qisrc checkout``

        For each project, checkout the branch if it is different than
        the default branch of the manifest.

        """
        ui.info(ui.green, ":: Checkout projects ...")
        errors = list()
        manifest_xml = os.path.join(self._syncer.manifest_repo, "manifest.xml")
        manifest = qisrc.manifest.Manifest(manifest_xml)
        max_src = max([len(x.src) for x in self.git_projects])
        n = len(self.git_projects)
        for i, project in enumerate(self.git_projects):
            ui.info_count(i, n, ui.bold, "Checkout",
                         ui.reset, ui.blue, project.src.ljust(max_src), end="\r")
            if project.default_branch is None:
                continue
            branch_name = project.default_branch.name
            remote_name = project.default_remote.name
            git = qisrc.git.Git(project.path)
            ok, err = git.safe_checkout(branch_name, remote_name, force=force)
            if not ok:
                errors.append((project.src, err))
        if not errors:
            return
        ui.error("Failed to checkout some projects")
        for (project, error) in errors:
            ui.info(project, ":", error)
开发者ID:cgestes,项目名称:qibuild,代码行数:29,代码来源:worktree.py


示例7: push_projects

def push_projects(git_projects, dry_run=False):
    """ Push Projects """
    if not git_projects:
        return
    ui.info(ui.green, "Pushing ", len(git_projects), "projects")
    for i, git_project in enumerate(git_projects):
        default_branch = git_project.default_branch.name
        remote_branch = git_project.default_branch.remote_branch
        ui.info_count(i, len(git_projects), git_project.src)
        git = qisrc.git.Git(git_project.path)
        if git_project.review:
            push_remote = git_project.review_remote
        else:
            push_remote = git_project.default_remote
        remote_ref = "%s/%s" % (push_remote.name, remote_branch)
        display_changes(git, default_branch, remote_ref)
        answer = qisys.interact.ask_yes_no("OK to push?", default=False)
        if not answer:
            return
        to_push = "%s:%s" % (default_branch, remote_branch)
        push_args = [push_remote.name, to_push]
        push_args.append("--force")
        if dry_run:
            push_args.append("--dry-run")
        rc, out = git.push(*push_args, raises=False)
        if rc == 0:
            ui.info(out)
        else:
            ui.error(out)
开发者ID:aldebaran,项目名称:qibuild,代码行数:29,代码来源:rebase.py


示例8: do

def do(args):
    """ Main entry point """
    git_worktree = qisrc.parsers.get_git_worktree(args)
    git_projects = qisrc.parsers.get_git_projects(git_worktree, args)
    for git_project in git_projects:
        maintainers = qisrc.maintainers.get(git_project)
        if not maintainers:
            mess = """\
The project in {src} has no maintainer.
Please edit {qiproject_xml} to silence this warning
"""
            ui.warning(mess.format(src=git_project.src, qiproject_xml=git_project.qiproject_xml), end="")
        reviewers = [x["email"] for x in maintainers]
        reviewers.extend(args.reviewers or list())
        git = qisrc.git.Git(git_project.path)
        current_branch = git.get_current_branch()
        if not current_branch:
            ui.error("Not currently on any branch")
            sys.exit(2)
        if git_project.review:
            qisrc.review.push(
                git_project,
                current_branch,
                bypass_review=(not args.review),
                dry_run=args.dry_run,
                reviewers=reviewers,
                topic=args.topic,
            )
        else:
            if args.dry_run:
                git.push("-n")
            else:
                git.push()
开发者ID:Fantomatic,项目名称:qibuild,代码行数:33,代码来源:push.py


示例9: main_wrapper

def main_wrapper(module, args):
    """This wraps the main method of an action so that:
       - backtrace is not printed by default
       - backtrace is printed is --backtrace was given
       - a pdb session is run if --pdb was given
    """
    try:
        module.do(args)
    except Exception as e:
        if args.pdb:
            traceback = sys.exc_info()[2]
            print ""
            print "### Exception:", e
            print "### Starting a debugger"
            try:
                #pylint: disable-msg=F0401
                import ipdb
                ipdb.post_mortem(traceback)
                sys.exit(0)
            except ImportError:
                import pdb
                pdb.post_mortem(traceback)
                sys.exit(0)
        if args.backtrace:
            raise
        message = str(e)
        if message.endswith("\n"):
            message = message[:-1]
        ui.error(e.__class__.__name__, message)
        sys.exit(2)
开发者ID:Phlogistique,项目名称:qibuild,代码行数:30,代码来源:script.py


示例10: _run

    def _run(self, num_jobs=1):
        """ Helper function for ._run """
        if not self.launcher:
            ui.error("test launcher not set, cannot run tests")
            return
        for i, test in enumerate(self.tests):
            self.task_queue.put((test, i))

        if num_jobs == 1:
            self.test_logger.single_job = True
        threads = list()

        for i in range(0, num_jobs):
            worker = TestWorker(self.task_queue, i)
            worker.launcher = self.launcher
            worker.launcher.worker_index = i
            worker.test_logger = self.test_logger
            worker.results = self.results
            threads.append(worker)
            worker.start()

        # Do not use .join() so that this can be interrupted:
        while self.task_queue.unfinished_tasks and \
              not self._interrupted:
            time.sleep(0.1)

        for worker_thread in threads:
            worker_thread.stop()
            worker_thread.join()
开发者ID:cameronyoyos,项目名称:qibuild,代码行数:29,代码来源:test_queue.py


示例11: jar

def jar(jar_path, files, paths):
    """ Search each files using qibuild find and
        add them into a jar using qisys
    """

    # Create command line
    jar_path = qisys.sh.to_native_path(jar_path)
    args = ["cvfM"]
    args += [jar_path]

    if not files:
        raise Exception("Missing arguments : Files to package")
    for wanted_file in files:
        ui.info("Searching for " + wanted_file + "...")
        path = qibuild.find.find(paths, wanted_file, expect_one=False)[0]
        if not path:
            ui.error("Cannot find " + wanted_file + " in worktree")
            return None
        ui.debug("Found : " + path)
        dirname = os.path.dirname(path)
        basename = os.path.basename(path)
        args += ["-C", dirname, basename]
        ui.debug("Added -C " + dirname + " " + wanted_file + " to command line")

    qisys.command.call(["jar"] + args, ignore_ret_code=False)
    return jar_path
开发者ID:Giessen,项目名称:qibuild,代码行数:26,代码来源:jar.py


示例12: commit_all

 def commit_all(self, message):
     """ Commit All """
     __rc, out = self.call("status", raises=False)
     for line in out.splitlines():
         line = line.strip()
         filename = line[8:]
         if line.startswith("!"):
             self.call("remove", filename)
         if line.startswith("?"):
             self.call("add", filename)
         # Prevent 'Node has unexpectedly changed kind' error
         # when a file is replaced by a symlink.
         # see http://antoniolorusso.com/blog/2008/09/29/svn-entry-has-unexpectedly-changed-special-status/
         if line.startswith("~"):
             full_path = os.path.join(self.path, filename)
             if os.path.islink(full_path):
                 target = os.readlink(full_path)  # pylint:disable=no-member
                 os.remove(full_path)
                 self.call("remove", filename)
                 os.symlink(target, full_path)  # pylint:disable=no-member
                 self.call("add", filename)
             else:
                 ui.error("Could not deal with", filename, "\n",
                          "Please open a bug report")
     self.call("commit", "--message", message)
开发者ID:aldebaran,项目名称:qibuild,代码行数:25,代码来源:svn.py


示例13: clever_reset_ref

def clever_reset_ref(git_project, ref, raises=True):
    """ Resets only if needed, fetches only if needed """
    try:
        remote_name = git_project.default_remote.name
    except AttributeError:
        error_msg = "Project {} has no default remote, defaulting to origin"
        ui.error(error_msg.format(git_project.name))
        remote_name = "origin"
    git = qisrc.git.Git(git_project.path)
    # Deals with "refs/" prefixed ref first
    if ref.startswith("refs/"):
        return _reset_hard_to_refs_prefixed_ref(git, remote_name, ref, raises=raises)
    # Else, ref format is a local name (branch or tag)
    # Check if this ref exists and if we are already in the expected state
    rc, ref_sha1 = git.call("rev-parse", ref, "--", raises=False)
    if rc != 0:
        # Maybe this is a newly pushed tag, try to fetch:
        git.fetch(remote_name)
        rc, ref_sha1 = git.call("rev-parse", ref, "--", raises=False)
        if rc != 0:
            return False, "Could not parse %s as a valid ref" % ref
    _, actual_sha1 = git.call("rev-parse", "HEAD", raises=False)
    if actual_sha1 == ref_sha1:  # Nothing to do
        return None if raises else True, ""
    # Reset to the ref local name
    return _reset_hard_to_local_refs_name(git, remote_name, ref, raises=raises)
开发者ID:aldebaran,项目名称:qibuild,代码行数:26,代码来源:reset.py


示例14: dump_symbols_from_binary

def dump_symbols_from_binary(binary, pool_dir, dump_syms_executable=None):
    """ Dump sympobls from the binary.
    Results can be found in
    <pool_dir>/<binary name>/<id>/<binary name>.sym

    """
    cmd = [dump_syms_executable, binary]
    ui.debug(cmd)
    process = subprocess.Popen(cmd, stdout=subprocess.PIPE,
                                    stderr=subprocess.PIPE)
    (out, err) = process.communicate()
    if process.returncode != 0:
        ui.error("Failed to dump symbols", err)
        return

    # First line looks like:
    # MODULE Linux x86_64  ID  binary
    lines = out.splitlines()
    first_line = lines[0]
    uuid = first_line.split()[3]
    name = first_line.split()[4]

    to_make = os.path.join(pool_dir, name, uuid)
    qisys.sh.mkdir(to_make, recursive=True)
    with open(os.path.join(to_make, name + ".sym"), "w") as fp:
        fp.write(out)
开发者ID:cameronyoyos,项目名称:qibuild,代码行数:26,代码来源:breakpad.py


示例15: _run

    def _run(self, num_jobs=1):
        """ Helper function for ._run """
        if not self.launcher:
            ui.error("test launcher not set, cannot run tests")
            return
        for i, test in enumerate(self.tests):
            self.task_queue.put((test, i))

        if num_jobs == 1:
            self.test_logger.single_job = True

        for i in range(0, num_jobs):
            worker = TestWorker(self.task_queue, i)
            worker.launcher = self.launcher
            worker.launcher.worker_index = i
            worker.test_logger = self.test_logger
            worker.results = self.results
            self._workers.append(worker)
            worker.start()

        while not self.task_queue.empty() and \
              not self._interrupted:
            time.sleep(0.1)

        for worker_thread in self._workers:
            worker_thread.join()
开发者ID:Grimy,项目名称:qibuild,代码行数:26,代码来源:test_queue.py


示例16: build

 def build(self, **kwargs):
     """ Run sphinx.main() with the correct arguments """
     try:
         import sphinx
     except ImportError, e:
         ui.error(e, "skipping build")
         return
开发者ID:Giessen,项目名称:qibuild,代码行数:7,代码来源:sphinx_project.py


示例17: configure

    def configure(self, **kwargs):
        """ Create a correct conf.py in self.build_dir """
        rel_paths = kwargs.get("rel_paths", False)
        in_conf_py = os.path.join(self.source_dir, "conf.in.py")
        should_use_template = False
        if os.path.exists(in_conf_py):
            should_use_template = True
        else:
            in_conf_py = os.path.join(self.source_dir, "conf.py")
            if not os.path.exists(in_conf_py):
                ui.error("Could not find a conf.py or a conf.in.py in", self.source_dir)
                return

        with open(in_conf_py) as fp:
            conf = fp.read()

        if should_use_template:
            if self.template_project:
                from_template = self.template_project.sphinx_conf
                from_template = from_template.format(**kwargs)
                conf = from_template + conf
            else:
                ui.warning("Found a conf.in.py but no template project found "
                           "in the worktree")

        from_conf = dict()
        try:
            # quick hack if conf.in.py used __file__
            from_conf["__file__"] = in_conf_py
            exec(conf, from_conf)
            conf = conf.replace("__file__", 'r"%s"' % in_conf_py)
        except Exception, e:
            ui.error("Could not read", in_conf_py, "\n", e)
            return
开发者ID:Giessen,项目名称:qibuild,代码行数:34,代码来源:sphinx_project.py


示例18: summary

    def summary(self):
        """ Display the tests results.

        Called at the end of self.run()
        Sets ``self.ok``

        """
        if not self.tests:
            self.ok = False
            return
        num_tests = len(self.results)
        failures = [x for x in self.results.values() if x.ok is False]
        num_failed = len(failures)
        message = "Ran %i tests in %is" % (num_tests, self.elapsed_time)
        ui.info(message)
        self.ok = (not failures) and not self._interrupted
        if self.ok:
            ui.info(ui.green, "All pass. Congrats!")
            return
        if num_failed != 0:
            ui.error(num_failed, "failures")
        if failures:
            max_len = max(len(x.test["name"]) for x in failures)
            for i, failure in enumerate(failures):
                ui.info_count(i, num_failed,
                            ui.blue, failure.test["name"].ljust(max_len + 2),
                            ui.reset, *failure.message)
开发者ID:Grimy,项目名称:qibuild,代码行数:27,代码来源:test_queue.py


示例19: generate_mo_file

 def generate_mo_file(self, locale):
     """ Generate .mo file for the given locale """
     ui.info(ui.green, "Generating translation for", ui.reset,
             ui.bold, locale)
     input_file = self.get_po_file(locale)
     if not os.path.exists(input_file):
         ui.error("No .po found for locale: ", locale, "\n",
                  "(looked in %s)" % input_file, "\n",
                  "Did you run qilinguist update?")
         return None
     output_file = os.path.join(self.mo_path, locale, "LC_MESSAGES",
                                self.domain + ".mo")
     to_make = os.path.dirname(output_file)
     qisys.sh.mkdir(to_make, recursive=True)
     cmd = ["msgfmt", "--check", "--statistics"]
     # required by libqi:
     conf_file = os.path.join(self.mo_path, ".confintl")
     with open(conf_file, "w") as fp:
         fp.write("# THIS FILE IS AUTOGENERATED\n"
                  "# Do not delete or modify it\n"
                  "# This file is used to find translation dictionaries\n")
     cmd.extend(["--output-file", output_file])
     cmd.extend(["--directory", self.po_path])
     cmd.append(input_file)
     process = subprocess.Popen(cmd, stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE)
     __out, err = process.communicate()
     ui.info(err.strip())
     if "untranslated" in err:
         return False, "Some untranslated messages were found"
     if process.returncode != 0:
         return False, "msgfmt failed"
     return True, ""
开发者ID:aldebaran,项目名称:qibuild,代码行数:33,代码来源:qigettext.py


示例20: do

def do(args):
    """Main entry point."""
    cmake_builder = qibuild.parsers.get_cmake_builder(args)
    if len(cmake_builder.projects) != 1:
        raise Exception("This action can only work on one project")
    project = cmake_builder.projects[0]
    if not os.path.exists(project.build_directory):
        ui.error("""It looks like your project has not been configured yet
(The build directory: '%s' does not exist)""" %
        project.build_directory)
        answer = qisys.interact.ask_yes_no(
            "Do you want me to run qibuild configure for you?",
            default=True)
        if not answer:
            sys.exit(2)
        else:
            cmake_builder.configure()

    ide = get_ide(cmake_builder.build_config.qibuild_cfg)
    if not ide:
        return

    if ide.name == "Visual Studio":
        open_visual(project)
    elif ide.name == "Xcode":
        open_xcode(project)
    elif ide.name == "QtCreator":
        open_qtcreator(project, ide.path)
    else:
        # Not supported (yet) IDE:
        mess  = "Invalid ide: %s\n" % ide.name
        mess += "Supported IDES are: %s" % ", ".join(SUPPORTED_IDES)
        raise Exception(mess)
开发者ID:cameronyoyos,项目名称:qibuild,代码行数:33,代码来源:open.py



注:本文中的qisys.ui.error函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ui.info函数代码示例发布时间:2022-05-26
下一篇:
Python ui.debug函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap