当前位置: 首页>>代码示例>>Python>>正文


Python usage.error方法代码示例

本文整理汇总了Python中twisted.python.usage.error方法的典型用法代码示例。如果您正苦于以下问题:Python usage.error方法的具体用法?Python usage.error怎么用?Python usage.error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.python.usage的用法示例。


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

示例1: opt_reactor

# 需要导入模块: from twisted.python import usage [as 别名]
# 或者: from twisted.python.usage import error [as 别名]
def opt_reactor(self, shortName):
        """
        Which reactor to use (see --help-reactors for a list of possibilities)
        """
        # Actually actually actually install the reactor right at this very
        # moment, before any other code (for example, a sub-command plugin)
        # runs and accidentally imports and installs the default reactor.
        #
        # This could probably be improved somehow.
        try:
            installReactor(shortName)
        except NoSuchReactor:
            msg = ("The specified reactor does not exist: '%s'.\n"
                   "See the list of available reactors with "
                   "--help-reactors" % (shortName,))
            raise usage.UsageError(msg)
        except Exception as e:
            msg = ("The specified reactor cannot be used, failed with error: "
                   "%s.\nSee the list of available reactors with "
                   "--help-reactors" % (e,))
            raise usage.UsageError(msg)
        else:
            self["reactor"] = shortName 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:25,代码来源:app.py

示例2: opt_reactor

# 需要导入模块: from twisted.python import usage [as 别名]
# 或者: from twisted.python.usage import error [as 别名]
def opt_reactor(self, shortName):
        """
        Which reactor to use (see --help-reactors for a list of possibilities)
        """
        # Actually actually actually install the reactor right at this very
        # moment, before any other code (for example, a sub-command plugin)
        # runs and accidentally imports and installs the default reactor.
        #
        # This could probably be improved somehow.
        try:
            installReactor(shortName)
        except NoSuchReactor:
            msg = ("The specified reactor does not exist: '%s'.\n"
                   "See the list of available reactors with "
                   "--help-reactors" % (shortName,))
            raise usage.UsageError(msg)
        except Exception, e:
            msg = ("The specified reactor cannot be used, failed with error: "
                   "%s.\nSee the list of available reactors with "
                   "--help-reactors" % (e,))
            raise usage.UsageError(msg) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:23,代码来源:app.py

示例3: runService

# 需要导入模块: from twisted.python import usage [as 别名]
# 或者: from twisted.python.usage import error [as 别名]
def runService(service):
    """Run the `service`."""
    config = Options()
    args = [
        "--logger=provisioningserver.logger.EventLogger",
        "--nodaemon",
        "--pidfile=",
    ]
    args += sys.argv[1:]
    args += [service]
    try:
        config.parseOptions(args)
    except usage.error as exc:
        print(config)
        print("%s: %s" % (sys.argv[0], exc))
    else:
        UnixApplicationRunner(config).run() 
开发者ID:maas,项目名称:maas,代码行数:19,代码来源:server.py

示例4: _reportImportError

# 需要导入模块: from twisted.python import usage [as 别名]
# 或者: from twisted.python.usage import error [as 别名]
def _reportImportError(self, module, e):
        """
        Helper method to report an import error with a profile module. This
        has to be explicit because some of these modules are removed by
        distributions due to them being non-free.
        """
        s = "Failed to import module %s: %s" % (module, e)
        s += """
This is most likely caused by your operating system not including
the module due to it being non-free. Either do not use the option
--profile, or install the module; your operating system vendor
may provide it in a separate package.
"""
        raise SystemExit(s) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:16,代码来源:app.py

示例5: run

# 需要导入模块: from twisted.python import usage [as 别名]
# 或者: from twisted.python.usage import error [as 别名]
def run(runApp, ServerOptions):
    config = ServerOptions()
    try:
        config.parseOptions()
    except usage.error as ue:
        print(config)
        print("%s: %s" % (sys.argv[0], ue))
    else:
        runApp(config) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:11,代码来源:app.py

示例6: run

# 需要导入模块: from twisted.python import usage [as 别名]
# 或者: from twisted.python.usage import error [as 别名]
def run():
    if len(sys.argv) == 1:
        sys.argv.append("--help")
    config = Options()
    try:
        config.parseOptions()
    except usage.error as ue:
        raise SystemExit("%s: %s" % (sys.argv[0], ue))
    _initialDebugSetup(config)

    try:
        trialRunner = _makeRunner(config)
    except _DebuggerNotFound as e:
        raise SystemExit('%s: %s' % (sys.argv[0], str(e)))

    suite = _getSuite(config)
    if config['until-failure']:
        test_result = trialRunner.runUntilFailure(suite)
    else:
        test_result = trialRunner.run(suite)
    if config.tracer:
        sys.settrace(None)
        results = config.tracer.results()
        results.write_results(show_missing=1, summary=False,
                              coverdir=config.coverdir().path)
    sys.exit(not test_result.wasSuccessful()) 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:28,代码来源:trial.py

示例7: run

# 需要导入模块: from twisted.python import usage [as 别名]
# 或者: from twisted.python.usage import error [as 别名]
def run(runApp, ServerOptions):
    config = ServerOptions()
    try:
        config.parseOptions()
    except usage.error, ue:
        print config
        print "%s: %s" % (sys.argv[0], ue) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:9,代码来源:app.py

示例8: run

# 需要导入模块: from twisted.python import usage [as 别名]
# 或者: from twisted.python.usage import error [as 别名]
def run(options=None):
    #  parse options
    try:
        config = MyOptions()
        config.parseOptions(options)
    except usage.error, ue:
         sys.exit("%s: %s" % (sys.argv[0], ue))

    #  create RPM build environment 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:11,代码来源:tap2rpm.py

示例9: run

# 需要导入模块: from twisted.python import usage [as 别名]
# 或者: from twisted.python.usage import error [as 别名]
def run():
    if len(sys.argv) == 1:
        sys.argv.append("--help")
    config = Options()
    try:
        config.parseOptions()
    except usage.error, ue:
        raise SystemExit, "%s: %s" % (sys.argv[0], ue) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:10,代码来源:trial.py

示例10: run

# 需要导入模块: from twisted.python import usage [as 别名]
# 或者: from twisted.python.usage import error [as 别名]
def run():
    #  parse options
    try:
        config = MyOptions()
        config.parseOptions()
    except usage.error, ue:
         sys.exit("%s: %s" % (sys.argv[0], ue))

    #  set up some useful local variables 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:11,代码来源:tap2rpm.py

示例11: run

# 需要导入模块: from twisted.python import usage [as 别名]
# 或者: from twisted.python.usage import error [as 别名]
def run():

    try:
        config = MyOptions()
        config.parseOptions()
    except usage.error, ue:
        sys.exit("%s: %s" % (sys.argv[0], ue)) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:9,代码来源:tap2deb.py

示例12: _supportsColor

# 需要导入模块: from twisted.python import usage [as 别名]
# 或者: from twisted.python.usage import error [as 别名]
def _supportsColor(self):
        # assuming stderr
        import sys
        if not sys.stderr.isatty():
            return False # auto color only on TTYs
        try:
            import curses
            curses.setupterm()
            return curses.tigetnum("colors") > 2
        except:
            # guess false in case of error
            return False 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:14,代码来源:trial.py

示例13: postOptions

# 需要导入模块: from twisted.python import usage [as 别名]
# 或者: from twisted.python.usage import error [as 别名]
def postOptions(self):
        if self['repository'] is None:
            raise usage.error("You must pass --repository")
        if self._includes:
            self['includes'] = '(%s)' % ('|'.join(self._includes), )
        if self._excludes:
            self['excludes'] = '(%s)' % ('|'.join(self._excludes), ) 
开发者ID:buildbot,项目名称:buildbot-contrib,代码行数:9,代码来源:svn_buildbot.py

示例14: run

# 需要导入模块: from twisted.python import usage [as 别名]
# 或者: from twisted.python.usage import error [as 别名]
def run(self):
        opts = Options()
        try:
            opts.parseOptions()
        except usage.error as ue:
            print(opts)
            print("%s: %s" % (sys.argv[0], ue))
            sys.exit()

        changes = self.getChanges(opts)
        if opts['dryrun']:
            for i, c in enumerate(changes):
                print("CHANGE #%d" % (i + 1))
                keys = sorted(c.keys())
                for k in keys:
                    print("[%10s]: %s" % (k, c[k]))
            print("*NOT* sending any changes")
            return

        d = self.sendChanges(opts, changes)

        def quit(*why):
            print("quitting! because", why)
            reactor.stop()

        d.addCallback(quit, "SUCCESS")

        @d.addErrback
        def failed(f):
            print("FAILURE")
            print(f)
            reactor.stop()

        reactor.callLater(60, quit, "TIMEOUT")
        reactor.run() 
开发者ID:buildbot,项目名称:buildbot-contrib,代码行数:37,代码来源:svn_buildbot.py

示例15: postOptions

# 需要导入模块: from twisted.python import usage [as 别名]
# 或者: from twisted.python.usage import error [as 别名]
def postOptions(self):
        if self['repository'] is None:
            raise usage.error("You must pass --repository") 
开发者ID:buildbot,项目名称:buildbot-contrib,代码行数:5,代码来源:bk_buildbot.py


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