Пример #1
0
 def testLoadApplication(self):
     a = service.Application("hello")
     baseconfig = {
         'file': None,
         'xml': None,
         'source': None,
         'python': None
     }
     for style in 'source xml pickle'.split():
         if style == 'xml' and not gotMicrodom:
             continue
         config = baseconfig.copy()
         config[{'pickle': 'file'}.get(style, style)] = 'helloapplication'
         sob.IPersistable(a).setStyle(style)
         sob.IPersistable(a).save(filename='helloapplication')
         a1 = app.getApplication(config, None)
         self.assertEqual(service.IService(a1).name, "hello")
     config = baseconfig.copy()
     config['python'] = 'helloapplication'
     open("helloapplication", 'w').writelines([
         "from twisted.application import service\n",
         "application = service.Application('hello')\n",
     ])
     a1 = app.getApplication(config, None)
     self.assertEqual(service.IService(a1).name, "hello")
Пример #2
0
 def testLoadApplication(self):
     """
     Test loading an application file in different dump format.
     """
     a = service.Application("hello")
     baseconfig = {'file': None, 'xml': None, 'source': None, 'python':None}
     for style in 'source xml pickle'.split():
         if style == 'xml' and not gotMicrodom:
             continue
         config = baseconfig.copy()
         config[{'pickle': 'file'}.get(style, style)] = 'helloapplication'
         sob.IPersistable(a).setStyle(style)
         sob.IPersistable(a).save(filename='helloapplication')
         a1 = app.getApplication(config, None)
         self.assertEqual(service.IService(a1).name, "hello")
     config = baseconfig.copy()
     config['python'] = 'helloapplication'
     f = open("helloapplication", 'w')
     f.writelines([
     "from twisted.application import service\n",
     "application = service.Application('hello')\n",
     ])
     f.close()
     a1 = app.getApplication(config, None)
     self.assertEqual(service.IService(a1).name, "hello")
Пример #3
0
 def testLoadApplication(self):
     a = service.Application("hello")
     baseconfig = {"file": None, "xml": None, "source": None, "python": None}
     for style in "source xml pickle".split():
         if style == "xml" and not gotMicrodom:
             continue
         config = baseconfig.copy()
         config[{"pickle": "file"}.get(style, style)] = "helloapplication"
         sob.IPersistable(a).setStyle(style)
         sob.IPersistable(a).save(filename="helloapplication")
         a1 = app.getApplication(config, None)
         self.assertEqual(service.IService(a1).name, "hello")
     config = baseconfig.copy()
     config["python"] = "helloapplication"
     open("helloapplication", "w").writelines(
         ["from twisted.application import service\n", "application = service.Application('hello')\n"]
     )
     a1 = app.getApplication(config, None)
     self.assertEqual(service.IService(a1).name, "hello")
Пример #4
0
 def testLoadApplication(self):
     """
     Test loading an application file in different dump format.
     """
     a = service.Application("hello")
     baseconfig = {"file": None, "source": None, "python": None}
     for style in "source pickle".split():
         config = baseconfig.copy()
         config[{"pickle": "file"}.get(style, style)] = "helloapplication"
         sob.IPersistable(a).setStyle(style)
         sob.IPersistable(a).save(filename="helloapplication")
         a1 = app.getApplication(config, None)
         self.assertEqual(service.IService(a1).name, "hello")
     config = baseconfig.copy()
     config["python"] = "helloapplication"
     f = open("helloapplication", "w")
     f.writelines(["from twisted.application import service\n", "application = service.Application('hello')\n"])
     f.close()
     a1 = app.getApplication(config, None)
     self.assertEqual(service.IService(a1).name, "hello")
Пример #5
0
 def testLoadApplication(self):
     """
     Test loading an application file in different dump format.
     """
     a = service.Application("hello")
     baseconfig = {"file": None, "source": None, "python": None}
     for style in "source pickle".split():
         config = baseconfig.copy()
         config[{"pickle": "file"}.get(style, style)] = "helloapplication"
         sob.IPersistable(a).setStyle(style)
         sob.IPersistable(a).save(filename="helloapplication")
         a1 = app.getApplication(config, None)
         self.assertEqual(service.IService(a1).name, "hello")
     config = baseconfig.copy()
     config["python"] = "helloapplication"
     with open("helloapplication", "w") as f:
         f.writelines([
             "from twisted.application import service\n",
             "application = service.Application('hello')\n",
         ])
     a1 = app.getApplication(config, None)
     self.assertEqual(service.IService(a1).name, "hello")
 def testLoadApplication(self):
     """
     Test loading an application file in different dump format.
     """
     a = service.Application("hello")
     baseconfig = {'file': None, 'source': None, 'python': None}
     for style in 'source pickle'.split():
         config = baseconfig.copy()
         config[{'pickle': 'file'}.get(style, style)] = 'helloapplication'
         sob.IPersistable(a).setStyle(style)
         sob.IPersistable(a).save(filename='helloapplication')
         a1 = app.getApplication(config, None)
         self.assertEqual(service.IService(a1).name, "hello")
     config = baseconfig.copy()
     config['python'] = 'helloapplication'
     with open("helloapplication", 'w') as f:
         f.writelines([
             "from twisted.application import service\n",
             "application = service.Application('hello')\n",
         ])
     a1 = app.getApplication(config, None)
     self.assertEqual(service.IService(a1).name, "hello")
Пример #7
0
def runApp(config):
    checkPID(config["pidfile"])
    passphrase = app.getPassphrase(config["encrypted"])
    app.installReactor(config["reactor"])
    config["nodaemon"] = config["nodaemon"] or config["debug"]
    oldstdout = sys.stdout
    oldstderr = sys.stderr
    startLogging(config["logfile"], config["syslog"], config["prefix"], config["nodaemon"])
    app.initialLog()
    application = app.getApplication(config, passphrase)
    startApplication(config, application)
    app.runReactorWithLogging(config, oldstdout, oldstderr)
    removePID(config["pidfile"])
    app.reportProfile(config["report-profile"], service.IProcess(application).processName)
    log.msg("Server Shut Down.")
Пример #8
0
def runApp(config):
    passphrase = app.getPassphrase(config['encrypted'])
    app.installReactor(config['reactor'])
    application = app.getApplication(config, passphrase)
    oldstdout = sys.stdout
    oldstderr = sys.stderr
    startLogging(config['logfile'])
    app.initialLog()
    os.chdir(config['rundir'])
    service.IService(application).privilegedStartService()
    app.startApplication(application, not config['no_save'])
    app.startApplication(internet.TimerService(0.1, lambda:None), 0)
    app.runReactorWithLogging(config, oldstdout, oldstderr)
    app.reportProfile(config['report-profile'],
                      service.IProcess(application).processName)
    log.msg("Server Shut Down.")
Пример #9
0
def runApp(config):
    passphrase = app.getPassphrase(config['encrypted'])
    app.installReactor(config['reactor'])
    application = app.getApplication(config, passphrase)
    oldstdout = sys.stdout
    oldstderr = sys.stderr
    startLogging(config['logfile'])
    app.initialLog()
    os.chdir(config['rundir'])
    service.IService(application).privilegedStartService()
    app.startApplication(application, not config['no_save'])
    app.startApplication(internet.TimerService(0.1, lambda: None), 0)
    app.runReactorWithLogging(config, oldstdout, oldstderr)
    app.reportProfile(config['report-profile'],
                      service.IProcess(application).processName)
    log.msg("Server Shut Down.")
Пример #10
0
def runApp(config):
    checkPID(config['pidfile'])
    passphrase = app.getPassphrase(config['encrypted'])
    app.installReactor(config['reactor'])
    config['nodaemon'] = config['nodaemon'] or config['debug']
    oldstdout = sys.stdout
    oldstderr = sys.stderr
    startLogging(config['logfile'], config['syslog'], config['prefix'],
                 config['nodaemon'])
    app.initialLog()
    application = app.getApplication(config, passphrase)
    startApplication(config, application)
    app.runReactorWithLogging(config, oldstdout, oldstderr)
    removePID(config['pidfile'])
    app.reportProfile(config['report-profile'],
                      service.IProcess(application).processName)
    log.msg("Server Shut Down.")