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

Python ui.error函数代码示例

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

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



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

示例1: main

def main():
    settings = None
    try:
        meta, settings, profile, debug, benchmarks, name, port = setup()

        while True:
            data = ui.main(meta, settings)

            if data is None:
                break

            if data['local']:
                # Local Server
                server_obj = server_interface.LocalInterface(name, data['save'], port, settings)
            else:
                # Remote Server
                server_obj = server_interface.RemoteInterface(name, data['ip'], data['port'])

            if not server_obj.error:
                render_interface.setup_render_module(settings)

                if profile:
                    cProfile.runctx('game(server_obj, settings, benchmarks)', globals(), locals(), filename='game.profile')
                elif debug:
                    pdb.run('game(server_obj, settings, benchmarks)', globals(), locals())
                else:
                    game(server_obj, settings, benchmarks)

            if server_obj.error:
                ui.error(server_obj.error)

    finally:
        setdown()
开发者ID:itsapi,项目名称:pycraft,代码行数:33,代码来源:main.py


示例2: exit_if_path_exists

 def exit_if_path_exists(self):
     """
     Exit early if the path cannot be found.
     """
     if os.path.exists(self.output_path):
         ui.error(c.MESSAGES["path_exists"], self.output_path)
         sys.exit(1)
开发者ID:AlbanAndrieu,项目名称:ansigenome,代码行数:7,代码来源:init.py


示例3: status

def status(publish_path):
    u''' 检查发布库的编译状态 '''
    publish_path, root_path = StaticPackage.get_roots(publish_path)
    if not publish_path:
        ui.error(u'不是发布库')
        return 1

    package = StaticPackage(root_path, publish_path)

    files = package.get_publish_files()
    for filename in files:
        filetype = os.path.splitext(filename)[1]

        source, mode = package.parse(filename)
        try:
            rfiles = package.get_relation_files(source, all = True)
        except PackageNotFoundException, e:
            ui.error(u'%s package not found' % e.url)
        else:
            modified, not_exists = package.listener.check(filename, rfiles)
            if len(modified) or len(not_exists):
                for modified_file in modified:
                    ui.msg('M ' + modified_file)

                for not_exists_file in not_exists:
                    ui.msg('! ' + not_exists_file)
开发者ID:ObjectJS,项目名称:opm-python,代码行数:26,代码来源:commands.py


示例4: exit_if_path_not_found

def exit_if_path_not_found(path):
    """
    Exit if the path is not found.
    """
    if not os.path.exists(path):
        ui.error(c.MESSAGES["path_missing"], path)
        sys.exit(1)
开发者ID:Yannig,项目名称:ansigenome,代码行数:7,代码来源:utils.py


示例5: link

def link(path, link_path, force = False):
    u''' 将发布库与源库进行映射

如果库设置了url,则同时使用.package文件进行连接,需要工作区支持,如果没有url,则只进行本地连接。'''

    publish_path, root_path = StaticPackage.get_roots(path)
    if not publish_path and not root_path and link_path:
        publish_path, root_path = StaticPackage.get_roots(link_path)
        path, link_path = link_path, path

    if not publish_path:
        publish_path = os.path.realpath(link_path)
    else:
        root_path = os.path.realpath(link_path)

    if not root_path:
        ui.error('package not found')

    package = StaticPackage(root_path, publish_path = publish_path)

    if not os.path.exists(publish_path):
        if force:
            os.makedirs(publish_path)
        else:
            ui.msg(u'%s path not exists, run opm link path -f to create it.' % publish_path)
            return 1

    package.link()

    ui.msg(u'linked publish %s to %s' % (publish_path, root_path))
开发者ID:ObjectJS,项目名称:opm-python,代码行数:30,代码来源:commands.py


示例6: serve

def serve(workspace_path, fastcgi = False, port = 8080, debug = False, noload = False, hg = False, hg_port = 8000):
    u''' 启动一个可实时编译的静态服务器

请指定工作区路径'''

    if Workspace.is_root(workspace_path):
        workspace = Workspace(os.path.realpath(workspace_path))
        if not noload:
            load(workspace = workspace)
    else:
        ui.error(u'工作区无效');
        workspace = None

    def print_request(environ, start_response):
        ''' 输出fastcgi本次请求的相关信息 '''

        import cgi
        start_response('200 OK', [('Content-Type', 'text/html')])
        yield '<html><head><title>Hello World!</title></head>\n' \
              '<body>\n' \
              '<p>Hello World!</p>\n' \
              '<table border="1">'
        names = environ.keys()
        names.sort()
        for name in names:
            yield '<tr><td>%s</td><td>%s</td></tr>\n' % (
                name, cgi.escape(`environ[name]`))

        form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ,
                                keep_blank_values=1)
        if form.list:
            yield '<tr><th colspan="2">Form data</th></tr>'

        for field in form.list:
            yield '<tr><td>%s</td><td>%s</td></tr>\n' % (
                field.name, field.value)

        yield '</table>\n' \
              '</body></html>\n'

    def listen(environ, start_response):
        ''' 监听请求 '''
        if environ['DOCUMENT_URI'].endswith('/net.test'):
            return print_request(environ, start_response)

        DEBUG = debug

        filename = os.path.realpath(environ['REQUEST_FILENAME'])
        url = environ['DOCUMENT_URI']

        force = False # 是否强制重新编译
        # 没有 referer 时强制重新编译
        if not 'HTTP_REFERER' in environ.keys():
            force = True

        try:
            publish_path, root_path = StaticPackage.get_roots(filename, workspace = workspace)
        except PackageNotFoundException, e:
            ui.error(u'%s package not found' % e.url)
        else:
开发者ID:ObjectJS,项目名称:opm-python,代码行数:60,代码来源:commands.py


示例7: main

def main():
    try:
        meta, settings, profile, name, port = setup()

        while True:
            data = ui.main(meta, settings)

            if data is None:
                break

            if data['local']:
                # Local Server
                server_obj = server_interface.LocalInterface(name, data['save'], port)
            else:
                # Remote Server
                server_obj = server_interface.RemoteInterface(name, data['ip'], data['port'])

            if not server_obj.error:
                if profile:
                    cProfile.runctx('game(server_obj, settings)', globals(), locals(), filename='game.profile')
                else:
                    game(server_obj, settings)

            if server_obj.error:
                ui.error(server_obj.error)

    finally:
        setdown()
开发者ID:Euphe,项目名称:pycraft,代码行数:28,代码来源:main.py


示例8: exit_if_missing_graphviz

    def exit_if_missing_graphviz(self):
        """
        Detect the presence of the dot utility to make a png graph.
        """
        (out, err) = utils.capture_shell("which dot")

        if "dot" not in out:
            ui.error(c.MESSAGES["dot_missing"])
开发者ID:ContentSquare,项目名称:ansigenome,代码行数:8,代码来源:export.py


示例9: validate_format

    def validate_format(self, allowed_formats):
        """
        Validate the allowed formats for a specific type.
        """
        if self.format in allowed_formats:
            return

        ui.error("Export type '{0}' does not accept '{1}' format, only: "
                 "{2}".format(self.type, self.format, allowed_formats))
        sys.exit(1)
开发者ID:ContentSquare,项目名称:ansigenome,代码行数:10,代码来源:export.py


示例10: file_to_string

def file_to_string(path):
    """
    Return the contents of a file when given a path.
    """
    if not os.path.exists(path):
        ui.error(c.MESSAGES["path_missing"], path)
        sys.exit(1)

    with codecs.open(path, "r", "UTF-8") as contents:
        return contents.read()
开发者ID:Yannig,项目名称:ansigenome,代码行数:10,代码来源:utils.py


示例11: url_to_string

def url_to_string(url):
    """
    Return the contents of a web site url as a string.
    """
    try:
        page = urllib2.urlopen(url)
    except (urllib2.HTTPError, urllib2.URLError) as err:
        ui.error(c.MESSAGES["url_unreachable"], err)
        sys.exit(1)

    return page
开发者ID:Yannig,项目名称:ansigenome,代码行数:11,代码来源:utils.py


示例12: mkdir_p

def mkdir_p(path):
    """
    Emulate the behavior of mkdir -p.
    """
    try:
        os.makedirs(path)
    except OSError as err:
        if err.errno == errno.EEXIST and os.path.isdir(path):
            pass
        else:
            ui.error(c.MESSAGES["path_unmakable"], err)
            sys.exit(1)
开发者ID:Yannig,项目名称:ansigenome,代码行数:12,代码来源:utils.py


示例13: file_to_list

def file_to_list(path):
    """
    Return the contents of a file as a list when given a path.
    """
    if not os.path.exists(path):
        ui.error(c.MESSAGES["path_missing"], path)
        sys.exit(1)

    with codecs.open(path, "r", "UTF-8") as contents:
        lines = contents.read().splitlines()

    return lines
开发者ID:Yannig,项目名称:ansigenome,代码行数:12,代码来源:utils.py


示例14: graph_png

    def graph_png(self):
        """
        Export a graph of the data in png format using graphviz/dot.
        """
        if not self.out_file:
            ui.error(c.MESSAGES["png_missing_out"])
            sys.exit(1)

        cli_flags = "-Gsize='{0}' -Gdpi='{1}' {2} ".format(self.size, self.dpi,
                                                           self.flags)
        cli_flags += "-o {0}".format(self.out_file)

        (out, err) = utils.capture_shell(
            "ansigenome export -t graph -f dot | dot -Tpng {0}"
            .format(cli_flags))

        if err:
            ui.error(err)
开发者ID:ContentSquare,项目名称:ansigenome,代码行数:18,代码来源:export.py


示例15: yaml_load

def yaml_load(path, input="", err_quit=False):
    """
    Return a yaml dict from a file or string with error handling.
    """
    try:
        if len(input) > 0:
            return yaml.load(input)
        elif len(path) > 0:
            return yaml.load(file_to_string(path))
    except Exception as err:
        file = os.path.basename(path)
        ui.error("",
                 c.MESSAGES["yaml_error"].replace("%file", file), err,
                 "")

        if err_quit:
            sys.exit(1)

        return False
开发者ID:Yannig,项目名称:ansigenome,代码行数:19,代码来源:utils.py


示例16: compile

def compile(filename, package = None, force = False, no_build_files = False):
    u'编译一个css/js文件'

    filename = os.path.realpath(filename)

    if not package:
        publish_path, root_path = StaticPackage.get_roots(filename)

        if not root_path:
            ui.error(u'没有找到源文件')
            return 1
        else:
            package = StaticPackage(root_path, publish_path)

    try:
        modified, not_exists = package.compile(filename, force = force)
    except IOError, e:
        ui.error('%s file not found' % e.filename)
        return 1
开发者ID:ObjectJS,项目名称:opm-python,代码行数:19,代码来源:commands.py


示例17: listen

    def listen(environ, start_response):
        ''' 监听请求 '''
        if environ['DOCUMENT_URI'].endswith('/net.test'):
            return print_request(environ, start_response)

        DEBUG = debug

        filename = os.path.realpath(environ['REQUEST_FILENAME'])
        url = environ['DOCUMENT_URI']

        force = False # 是否强制重新编译
        # 没有 referer 时强制重新编译
        if not 'HTTP_REFERER' in environ.keys():
            force = True

        try:
            publish_path, root_path = StaticPackage.get_roots(filename, workspace = workspace)
        except PackageNotFoundException, e:
            ui.error(u'%s package not found' % e.url)
开发者ID:ObjectJS,项目名称:opm-python,代码行数:19,代码来源:commands.py


示例18: packages

def packages(workspace_path, show_url = False):
    u''' 本工作区中所有源库 '''

    if os.path.isfile(workspace_path):
        workspace_path = os.path.dirname(workspace_path)

    # 有可能不是workspace跟路径,而是某个子路径
    workspace_path = Workspace.get_workspace(workspace_path)
    if not workspace_path:
        ui.error(u'没有工作区')
        return 1
    else:
        workspace = Workspace(workspace_path)
        if show_url:
            for url in workspace.url_packages.keys():
                ui.msg(url)
        else:
            for local_path in workspace.local_packages.keys():
                ui.msg(os.path.realpath(os.path.join(workspace.root, local_path)))
开发者ID:ObjectJS,项目名称:opm-python,代码行数:19,代码来源:commands.py


示例19: incs

def incs(filename, all = False, reverse = False):
    u''' 某文件所有依赖的文件 '''

    filename = os.path.realpath(filename)
    root_path = StaticPackage.get_root(filename)
    package = StaticPackage(root_path)

    filetype = os.path.splitext(filename)[1]

    if reverse:
        if filetype == '.css':
            ui.error(u'Not support yet, sorry.')
            return 1
        else:
            files = package.get_included(filename, all = all)
    else:
        files = package.get_relation_files(filename, all = all)

    for file in files:
        ui.msg(file)
开发者ID:ObjectJS,项目名称:opm-python,代码行数:20,代码来源:commands.py


示例20: get

def get(workspace, url):
    u''' 从公共代码库获取源库

 当前目录会被作为工作区,所有获取到的源库代码都会放到此工作区内
    '''

    if workspace.__class__ == str:
        try:
            workspace = Workspace(workspace)
        except ConfigError as e:
            ui.error(u'config error %s' % e.path)
            return 1

    load(workspace)

    try:
        packages = workspace.fetch_packages(url)
    except PackageNotFoundException, e:
        ui.error('%s package not found' % e.url)
        return 1
开发者ID:ObjectJS,项目名称:opm-python,代码行数:20,代码来源:commands.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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