本文整理汇总了Python中twisted.application.service.loadApplication函数的典型用法代码示例。如果您正苦于以下问题:Python loadApplication函数的具体用法?Python loadApplication怎么用?Python loadApplication使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了loadApplication函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_simpleStoreAndLoad
def test_simpleStoreAndLoad(self):
a = service.Application("hello")
p = sob.IPersistable(a)
for style in "source pickle".split():
p.setStyle(style)
p.save()
a1 = service.loadApplication("hello.ta" + style[0], style)
self.assertEqual(service.IService(a1).name, "hello")
f = open("hello.tac", "w")
f.writelines(["from twisted.application import service\n", "application = service.Application('hello')\n"])
f.close()
a1 = service.loadApplication("hello.tac", "python")
self.assertEqual(service.IService(a1).name, "hello")
开发者ID:pelluch,项目名称:VTK,代码行数:13,代码来源:test_application.py
示例2: convertStyle
def convertStyle(filein, typein, passphrase, fileout, typeout, encrypt):
application = service.loadApplication(filein, typein, passphrase)
sob.IPersistable(application).setStyle(typeout)
passphrase = getSavePassphrase(encrypt)
if passphrase:
fileout = None
sob.IPersistable(application).save(filename=fileout, passphrase=passphrase)
开发者ID:antong,项目名称:twisted,代码行数:7,代码来源:app.py
示例3: test_convertStyle
def test_convertStyle(self):
appl = service.Application("lala")
for instyle in "source pickle".split():
for outstyle in "source pickle".split():
sob.IPersistable(appl).setStyle(instyle)
sob.IPersistable(appl).save(filename="converttest")
app.convertStyle("converttest", instyle, None, "converttest.out", outstyle, 0)
appl2 = service.loadApplication("converttest.out", outstyle)
self.assertEqual(service.IService(appl2).name, "lala")
开发者ID:pelluch,项目名称:VTK,代码行数:9,代码来源:test_application.py
示例4: convertStyle
def convertStyle(filein, typein, passphrase, fileout, typeout, encrypt):
# FIXME: https://twistedmatrix.com/trac/ticket/7827
# twisted.persisted is not yet ported to Python 3, so import it here.
from twisted.persisted import sob
application = service.loadApplication(filein, typein, passphrase)
sob.IPersistable(application).setStyle(typeout)
passphrase = getSavePassphrase(encrypt)
if passphrase:
fileout = None
sob.IPersistable(application).save(filename=fileout, passphrase=passphrase)
开发者ID:vmarkovtsev,项目名称:twisted,代码行数:10,代码来源:app.py
示例5: addToApplication
def addToApplication(ser, name, append, procname, type, encrypted, uid, gid):
if append and os.path.exists(append):
a = service.loadApplication(append, 'pickle', None)
else:
a = service.Application(name, uid, gid)
if procname:
service.IProcess(a).processName = procname
ser.setServiceParent(service.IServiceCollection(a))
sob.IPersistable(a).setStyle(type)
passphrase = app.getSavePassphrase(encrypted)
if passphrase:
append = None
sob.IPersistable(a).save(filename=append, passphrase=passphrase)
开发者ID:galaxysd,项目名称:BitTorrent,代码行数:13,代码来源:mktap.py
示例6: test_implicitConversion
def test_implicitConversion(self):
a = Dummy()
a.__dict__ = {'udpConnectors': [], 'unixConnectors': [],
'_listenerDict': {}, 'name': 'dummy',
'sslConnectors': [], 'unixPorts': [],
'_extraListeners': {}, 'sslPorts': [], 'tcpPorts': [],
'services': {}, 'gid': 0, 'tcpConnectors': [],
'extraConnectors': [], 'udpPorts': [], 'extraPorts': [],
'uid': 0}
pickle.dump(a, open("file.tap", 'wb'))
a1 = service.loadApplication("file.tap", "pickle", None)
self.assertEqual(service.IService(a1).name, "dummy")
self.assertEqual(list(service.IServiceCollection(a1)), [])
开发者ID:pwarren,项目名称:AGDeviceControl,代码行数:13,代码来源:test_application.py
示例7: _saveConfiguredIDTest
def _saveConfiguredIDTest(self, argv, uid, gid):
"""
Test that when L{run} is invoked and L{sys.argv} has the given
value, the resulting application has the specified UID and GID.
@type argv: C{list} of C{str}
@param argv: The value to which to set L{sys.argv} before calling L{run}.
@type uid: C{int}
@param uid: The expected value for the resulting application's
L{IProcess.uid}.
@type gid: C{int}
@param gid: The expected value for the resulting application's
L{IProcess.gid}.
"""
sys.argv = argv
run()
app = loadApplication("ftp.tap", "pickle", None)
process = IProcess(app)
self.assertEqual(process.uid, uid)
self.assertEqual(process.gid, gid)
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:22,代码来源:test_mktap.py
示例8: getApplication
def getApplication(config, passphrase):
s = [(config[t], t) for t in ["python", "xml", "source", "file"] if config[t]][0]
filename, style = s[0], {"file": "pickle"}.get(s[1], s[1])
try:
log.msg("Loading %s..." % filename)
application = service.loadApplication(filename, style, passphrase)
log.msg("Loaded.")
except Exception, e:
s = "Failed to load application: %s" % e
if isinstance(e, KeyError) and e.args[0] == "application":
s += """
Could not find 'application' in the file. To use 'twistd -y', your .tac
file must create a suitable object (e.g., by calling service.Application())
and store it in a variable named 'application'. twistd loads your .tac file
and scans the global variables for one of this name.
Please read the 'Using Application' HOWTO for details.
"""
traceback.print_exc(file=log.logfile)
log.msg(s)
log.deferr()
sys.exit("\n" + s + "\n")
开发者ID:RichDijk,项目名称:eXe,代码行数:22,代码来源:app.py
注:本文中的twisted.application.service.loadApplication函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论