本文整理汇总了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
示例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)
示例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()
示例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)
示例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)
示例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())
示例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)
示例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
示例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)
示例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
示例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))
示例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
示例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), )
示例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()
示例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")