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")
Esempio n. 2
0
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)
Esempio n. 3
0
 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")
Esempio n. 4
0
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)
Esempio n. 5
0
 def testStylesBeingSet(self):
     o = Dummy()
     o.foo = 5
     o.setComponent(sob.IPersistable, sob.Persistent(o, 'lala'))
     for style in 'source pickle'.split():
         sob.IPersistable(o).setStyle(style)
         sob.IPersistable(o).save(filename='lala.' + style)
         o1 = sob.load('lala.' + style, style)
         self.assertEqual(o.foo, o1.foo)
         self.assertEqual(sob.IPersistable(o1).style, style)
Esempio n. 6
0
 def testStylesBeingSet(self):
     o = Dummy()
     o.foo = 5
     o.setComponent(sob.IPersistable, sob.Persistent(o, 'lala'))
     for style in 'xml source pickle'.split():
         if style == 'xml' and not gotMicrodom:
             continue
         sob.IPersistable(o).setStyle(style)
         sob.IPersistable(o).save(filename='lala.'+style)
         o1 = sob.load('lala.'+style, style)
         self.failUnlessEqual(o.foo, o1.foo)
         self.failUnlessEqual(sob.IPersistable(o1).style, style)
Esempio n. 7
0
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)
 def test_convertStyle(self):
     appl = service.Application("lala")
     for instyle in 'xml source pickle'.split():
         if instyle == 'xml' and not gotMicrodom:
             continue
         for outstyle in 'xml source pickle'.split():
             if outstyle == 'xml' and not gotMicrodom:
                 continue
             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")
Esempio n. 9
0
def startApplication(application, save):
    from twisted.internet import reactor
    service.IService(application).startService()
    if save:
        p = sob.IPersistable(application)
        reactor.addSystemEventTrigger('after', 'shutdown', p.save, 'shutdown')
    reactor.addSystemEventTrigger('before', 'shutdown',
                                  service.IService(application).stopService)
Esempio n. 10
0
def startApplication(application, save):
    from twisted.internet import reactor

    service.IService(application).startService()
    if save:
        p = sob.IPersistable(application)
        reactor.addSystemEventTrigger("after", "shutdown", p.save, "shutdown")
    reactor.addSystemEventTrigger("before", "shutdown",
                                  service.IService(application).stopService)
Esempio n. 11
0
def startApplication(application, save):
    from twisted.internet import reactor
    service.IService(application).startService()
    if save:
        # 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
        p = sob.IPersistable(application)
        reactor.addSystemEventTrigger('after', 'shutdown', p.save, 'shutdown')
    reactor.addSystemEventTrigger('before', 'shutdown',
                                  service.IService(application).stopService)
Esempio n. 12
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")
Esempio n. 14
0
 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")
     with open("hello.tac", "w") as f:
         f.writelines([
             "from twisted.application import service\n",
             "application = service.Application('hello')\n",
         ])
     a1 = service.loadApplication("hello.tac", "python")
     self.assertEqual(service.IService(a1).name, "hello")
Esempio n. 15
0
 def test_simpleStoreAndLoad(self):
     a = service.Application("hello")
     p = sob.IPersistable(a)
     for style in 'xml source pickle'.split():
         if style == 'xml' and not gotMicrodom:
             continue
         p.setStyle(style)
         p.save()
         a1 = service.loadApplication("hello.ta" + style[0], style)
         self.assertEqual(service.IService(a1).name, "hello")
     open("hello.tac", 'w').writelines([
         "from twisted.application import service\n",
         "application = service.Application('hello')\n",
     ])
     a1 = service.loadApplication("hello.tac", 'python')
     self.assertEqual(service.IService(a1).name, "hello")
Esempio n. 16
0
 def testPersistableComponent(self):
     a = service.Application("hello")
     p = sob.IPersistable(a)
     self.assertEqual(p.style, "pickle")
     self.assertEqual(p.name, "hello")
     self.assertIs(p.original, a)
Esempio n. 17
0
 def testPersistableComponent(self):
     a = service.Application("hello")
     p = sob.IPersistable(a)
     self.assertEqual(p.style, 'pickle')
     self.assertEqual(p.name, 'hello')
     self.assert_(p.original is a)
Esempio n. 18
0
    unittest.TextTestRunner().run(the_test_suite)	
    
    
    print "End of LeoNtest."
    
    # let the server running
    print "Look at http://localhost:8788 for the results"
    
    if ("1" in sys.argv) or ("2" in sys.argv):
        os.system("./leon.py LeoNtest.leo &") # LeoNtest.leo contain nodes for automatic test sequence execution on the clien side.
        
    if "2" in sys.argv:
        os.system("./leon.py LeoNtest.leo &") # run a second instance
        
    
    reactor.run() # keep the LeoServer running
    
    if "save_tap" in sys.argv:
        from twisted.persisted import sob
        per  = sob.IPersistable(server_app)
        from twisted.application import service
        t_filename = "%s-shutdown.tap" % service.IService(server_app).name
        print "Creating the %s file." % t_filename
        print "'.tap' files are executed with 'twistd'.\n'twistd -f %s' for normal usage. 'twistd -nf %s' for debugging.\nSee 'twistd' help for avanced options" % (t_filename, t_filename)
        per.save(filename= t_filename)

    print "Finishing the LeoNtest services."
#@nonl
#@-node:@file LeoNtest.py
#@-leo