コード例 #1
0
ファイル: test_powerup.py プロジェクト: perkinslr/axiom-py3
 def testStoreServicePowerup(self):
     s = Store()
     ss = SillyService(store=s)
     s.powerUp(ss, IService)
     IService(s).startService()
     IService(s).stopService()
     self.assertEqual(ss.started, 1)
     self.assertEqual(ss.stopped, 1)
     self.assertEqual(ss.running, 0)
コード例 #2
0
ファイル: test_powerup.py プロジェクト: perkinslr/axiom-py3
 def testItemServicePowerup(self):
     s = Store()
     sm = Summer(store=s)
     ss = SillyService(store=s)
     sm.powerUp(ss, IService)
     IService(sm).startService()
     IService(sm).stopService()
     self.assertEqual(ss.started, 1)
     self.assertEqual(ss.stopped, 1)
     self.assertEqual(ss.running, 0)
コード例 #3
0
ファイル: test_scheduler.py プロジェクト: calston/tums
    def setUp(self):
        self.clock = Clock()

        scheduler = Scheduler(store=self.siteStore)
        self.stubTime(scheduler)
        installOn(scheduler, self.siteStore)
        IService(self.siteStore).startService()
コード例 #4
0
ファイル: test_fulltext.py プロジェクト: jonathanj/mantissa
    def setUp(self):
        """
        Make a store, an account/substore, an indexer, and call startService()
        on the superstore's IService so the batch process interactions that
        happen in fulltext.py work
        """
        self.dbdir = self.mktemp()
        self.path = u'index'

        superstore = store.Store(self.dbdir)

        loginSystem = LoginSystem(store=superstore)
        installOn(loginSystem, superstore)

        account = loginSystem.addAccount(u'testuser', u'example.com', None)
        substore = account.avatars.open()

        self.store = substore
        self.indexer = self.createIndexer()

        self.svc = IService(superstore)
        self.svc.startService()

        # Make sure the indexer is actually available
        writer = self.openWriteIndex()
        writer.close()
コード例 #5
0
 def test_as_app(self):
     """The agent class can be accessed as an application."""
     app = BaseAgent().as_app()
     multi_service = IService(app, None)
     self.assertTrue(IServiceCollection.providedBy(multi_service))
     services = list(multi_service)
     self.assertEqual(len(services), 1)
コード例 #6
0
 def test_namedService(self):
     """
     The site store IScheduler implementation can be retrieved as a named
     service from the store's IServiceCollection powerup.
     """
     self.assertIdentical(
         IService(self.store).getServiceNamed(SITE_SCHEDULER),
         IScheduler(self.store))
コード例 #7
0
 def test_setServiceParent(self):
     """
     Test that the C{self.portType.setServiceParent} method adds the C{self.portType} to
     the Axiom Store Service as a child.
     """
     port = self.port(store=self.store)
     port.setServiceParent(self.store)
     self.failUnlessIn(port, list(IService(self.store)))
コード例 #8
0
ファイル: test_substore.py プロジェクト: DalavanCloud/axiom-1
 def _startService(self):
     """
     Start the service and make sure we know it's started so tearDown can
     shut it down.
     """
     assert not self.serviceStarted
     self.serviceStarted = True
     return IService(self.topdb).startService()
コード例 #9
0
 def test_disownServiceParent(self):
     """
     Test that the C{self.portType.disownServiceParent} method removes the
     C{self.portType} from the Axiom Store Service.
     """
     port = self.port(store=self.store)
     port.setServiceParent(self.store)
     port.disownServiceParent()
     self.failIfIn(port, list(IService(self.store)))
コード例 #10
0
ファイル: stubloader.py プロジェクト: perkinslr/axiom-py3
 def setUp(self):
     """
     Prepare to test a stub by opening and then fully upgrading the legacy
     store.
     """
     self.store = self.openLegacyStore()
     self.service = IService(self.store)
     self.service.startService()
     return self.store.whenFullyUpgraded()
コード例 #11
0
 def test_schedulerStartsWhenServiceStarts(self):
     """
     Test that IScheduler(store).startService() gets called whenever
     IService(store).startService() is called.
     """
     service = IService(self.store)
     service.startService()
     scheduler = service.getServiceNamed(SITE_SCHEDULER)
     self.assertTrue(scheduler.running)
コード例 #12
0
ファイル: axiom_plugins.py プロジェクト: perkinslr/axiom-py3
 def makeService(cls, options):
     """
     Create an L{IService} for the database specified by the given
     configuration.
     """
     from axiom.store import Store
     store = Store(options['dbdir'], debug=options['debug'])
     service = IService(store)
     _CheckSystemVersion(store).setServiceParent(service)
     return service
コード例 #13
0
ファイル: test_service.py プロジェクト: ling-1/GETAiqiyiDanmu
    def test_applicationComponents(self):
        """
        Check L{twisted.application.service.Application} instantiation.
        """
        app = Application("app-name")

        self.assertTrue(verifyObject(IService, IService(app)))
        self.assertTrue(verifyObject(IServiceCollection, IServiceCollection(app)))
        self.assertTrue(verifyObject(IProcess, IProcess(app)))
        self.assertTrue(verifyObject(IPersistable, IPersistable(app)))
コード例 #14
0
    def test_defaultService(self):
        """
        Test the value of a Slave service in it's simplest
        configuration.
        """
        service = CalDAVServiceMaker().makeService(self.options)

        self.failUnless(IService(service),
                        "%s does not provide IService" % (service, ))
        self.failUnless(service.services, "No services configured")
        self.failUnless(isinstance(service, CalDAVService),
                        "%s is not a CalDAVService" % (service, ))
コード例 #15
0
ファイル: service.py プロジェクト: shiradz/fusion-index
    def makeService(self, options):
        service = MultiService()

        store = Store(options['db'])
        store.querySQL('PRAGMA journal_mode=WAL;')
        store.querySQL('PRAGMA synchronous=NORMAL;')
        IService(store).setServiceParent(service)

        site = Site(IndexRouter(store=store).router.resource())
        webService = strports.service(options['port'], site, reactor=reactor)
        webService.setServiceParent(service)
        return service
コード例 #16
0
ファイル: axiom_plugins.py プロジェクト: DalavanCloud/axiom-1
 def makeService(cls, options):
     """
     Create an L{IService} for the database specified by the given
     configuration.
     """
     from axiom.store import Store
     jm = options['journal-mode']
     if jm is not None:
         jm = jm.decode('ascii')
     store = Store(options['dbdir'], debug=options['debug'], journalMode=jm)
     service = IService(store)
     _CheckSystemVersion(store).setServiceParent(service)
     return service
コード例 #17
0
 def setUp(self):
     temp = self.mktemp()
     f = sys.modules[self.__module__].__file__
     dfn = os.path.join(
         os.path.dirname(f),
         os.path.basename(f).split("test_")[1].split('.py')[0]+'.axiom')
     arcname = dfn + '.tbz2'
     tarball = tarfile.open(arcname, 'r:bz2')
     for member in tarball.getnames():
         tarball.extract(member, temp)
     self.store = Store(os.path.join(temp, os.path.basename(dfn)))
     self.service = IService(self.store)
     self.service.startService()
     return self.store.whenFullyUpgraded()
コード例 #18
0
ファイル: relopausable.py プロジェクト: astrorafael/tessflux
def Application(name, uid=None, gid=None):
    """
    Return a compound class.
    Return an object supporting the L{IService}, L{IPausable}, L{IReloadable}, L{IServiceCollection},
    L{IProcess} and L{sob.IPersistable} interfaces, with the given
    parameters. Always access the return value by explicit casting to
    one of the interfaces.
    """
    ret = components.Componentized()
    availableComponents = [TopLevelService(), Process(uid, gid),
                           sob.Persistent(ret, name)]

    for comp in availableComponents:
        ret.addComponent(comp, ignoreClass=1)
    IService(ret).setName(name)
    return ret  
コード例 #19
0
    def setUp(self):
        self.clock = Clock()

        self.dbdir = filepath.FilePath(self.mktemp())
        self.store = Store(self.dbdir)
        self.substoreItem = SubStore.createNew(self.store, ['sub'])
        self.substore = self.substoreItem.open()

        self.scheduler = IScheduler(self.store)
        self.subscheduler = IScheduler(self.substore)

        self.scheduler.callLater = self.clock.callLater
        self.scheduler.now = lambda: Time.fromPOSIXTimestamp(self.clock.seconds())
        self.subscheduler.now = lambda: Time.fromPOSIXTimestamp(self.clock.seconds())

        IService(self.store).startService()
コード例 #20
0
ファイル: test_upgrading.py プロジェクト: perkinslr/axiom-py3
    def closeStore(self):
        """
        Close C{self.currentStore} and discard the reference.  If there is a
        store service running, stop it first.
        """
        service = IService(self.currentStore)
        if service.running:
            result = service.stopService()
        else:
            result = succeed(None)

        def close(ignored):
            self.currentStore.close()
            self.currentStore = None

        result.addCallback(close)
        return result
コード例 #21
0
ファイル: test_upgrading.py プロジェクト: perkinslr/axiom-py3
    def closeStore(self):
        """
        Close C{self.currentTopStore} and C{self.currentSubStore}.  If there is
        a store service running in C{self.currentTopStore}, stop it first.
        """
        service = IService(self.currentTopStore)
        if service.running:
            result = service.stopService()
        else:
            result = succeed(None)

        def stopped(ignored):
            self.currentSubStore.close()
            self.currentTopStore.close()
            self.currentSubStore = None
            self.currentTopStore = None

        result.addCallback(stopped)
        return result
コード例 #22
0
    def setUp(self):

        self.config = {
            'MEMCACHE_SERVERS': {
                'c0': {
                    'host': 'localhost'
                },
                'c1': {
                    'host': 'localhost'
                },
                'c2': {
                    'host': 'localhost'
                },
            },
        }
        self.config_id = conf.settings.add_config(self.config)
        self.app = Application(__name__)
        self.memcache = app.build_memcache(self.app)
        IService(self.app).startService()

        yield timed.sleep(1)
コード例 #23
0
def _main_async(reactor, argv=None, _abort_for_test=False):
    if argv is None:
        argv = sys.argv
    
    if not _abort_for_test:
        # Some log messages would be discarded if we did not set up things early.
        configure_logging()
    
    # Option parsing is done before importing the main modules so as to avoid the cost of initializing gnuradio if we are aborting early. TODO: Make that happen for createConfig too.
    argParser = argparse.ArgumentParser(prog=argv[0])
    argParser.add_argument('config_path', metavar='CONFIG',
        help='path of configuration directory or file')
    argParser.add_argument('--create', dest='createConfig', action='store_true',
        help='write template configuration file to CONFIG and exit')
    argParser.add_argument('-g, --go', dest='openBrowser', action='store_true',
        help='open the UI in a web browser')
    argParser.add_argument('--force-run', dest='force_run', action='store_true',
        help='Run DSP even if no client is connected (for debugging).')
    args = argParser.parse_args(args=argv[1:])

    # Verify we can actually run.
    # Note that this must be done before we actually load core modules, because we might get an import error then.
    version_report = yield _check_versions()
    if version_report:
        print(version_report, file=sys.stderr)
        sys.exit(1)

    # Write config file and exit if asked ...
    if args.createConfig:
        write_default_config(args.config_path)
        _log.info('Created default configuration at: {config_path}', config_path=args.config_path)
        sys.exit(0)  # TODO: Consider using a return value or something instead
    
    # ... else read config file
    config_obj = Config(reactor=reactor, log=_log)
    execute_config(config_obj, args.config_path)
    yield config_obj._wait_and_validate()
    
    _log.info('Constructing...')
    app = config_obj._create_app()
    
    reactor.addSystemEventTrigger('during', 'shutdown', app.close_all_devices)
    
    _log.info('Restoring state...')
    pfg = PersistenceFileGlue(
        reactor=reactor,
        root_object=app,
        filename=config_obj._state_filename,
        get_defaults=_app_defaults)
    
    _log.info('Starting web server...')
    services = MultiService()
    for maker in config_obj._service_makers:
        IService(maker(app)).setServiceParent(services)
    services.startService()
    
    _log.info('ShinySDR is ready.')
    
    for service in services:
        # TODO: should have an interface (currently no proper module to put it in)
        service.announce(args.openBrowser)
    
    if args.force_run:
        _log.debug('force_run')
        # TODO kludge, make this less digging into guts
        app.get_receive_flowgraph().get_monitor().state()['fft'].subscribe2(lambda v: None, the_subscription_context)
    
    if _abort_for_test:
        services.stopService()
        yield pfg.sync()
        defer.returnValue(app)
    else:
        yield defer.Deferred()  # never fires
コード例 #24
0
ファイル: tums.py プロジェクト: calston/tums
    pass
if start:
    try:
        port = Settings.HIVEPort
    except:
        port = 54322
    thebe = internet.SSLServer(port, thebeProto, xmlrpc.ServerContextFactory())
    thebe.setServiceParent(application)
tums.setServiceParent(application)
tumsSSL.setServiceParent(application)

infoserv = internet.TCPServer(9681, InfoServ.deploy())
infoserv.setServiceParent(application)

flowDb = Database.AggregatorDatabase()
axiomBatch = IService(flowDb.store)
axiomBatch.setServiceParent(application)

#Update the Firewall
Shorewall.upgradeRules()

## TwistD bootstrap code
nodaemon = 0
log = '/var/log/tums.log'
if len(sys.argv) > 1:
    if sys.argv[1] == "-n":
        nodaemon = 1
        log = None

if __name__ == '__main__':
コード例 #25
0
 def tearDown(self):
     return IService(self.store).stopService()
コード例 #26
0
 def stopStoreService(self):
     service = IService(self.store)
     if service.running:
         return service.stopService()
コード例 #27
0
 def startStoreService(self):
     """
     Start the Store Service.
     """
     service = IService(self.store)
     service.startService()
コード例 #28
0
    def setUp(self):
        self.clock = Clock()

        scheduler = IScheduler(self.siteStore)
        self.stubTime(scheduler)
        IService(self.siteStore).startService()
コード例 #29
0
 def stop(self):
     self.poller.reset_all_tasks()
     d = IService(self.app).stopService()
     d.addCallback(self.all_services_stoped)
コード例 #30
0
ファイル: test_upgrading.py プロジェクト: perkinslr/axiom-py3
 def startStoreService(self):
     svc = IService(self.currentTopStore)
     svc.getServiceNamed(
         "Batch Processing Controller").disownServiceParent()
     svc.startService()