示例#1
0
文件: appmgr.py 项目: cbrinley/droned
    def debugReport(self, FromDeferred=False):
        """Friendly Debug Reporting in the Logs

           handles instances of twisted.python.failure.Failure
           
           This method is callback chain safe
        """
        if isinstance(FromDeferred, Failure):
            try: FromDeferred.raiseException()
            except: pass #just need the current exception in sys.exc_info
            crashReport('Service [%s]: Caught unhandled exception' % \
                    (self.name,), self)
        #assume this can be part of a callback chain
        return FromDeferred
示例#2
0
    def startService(self):
        """Start All AppManager Services"""
        if self.scanning.called:  #need to pre-populate values
            self.scanning = defer.maybeDeferred(self._first_scan)
        self.first_run = True
        self._task = task.LoopingCall(self.scan_app_instances)

        #plugins will be created and loaded when needed
        for shortname in config.APPLICATIONS.keys():
            manager = None
            try:
                applog = logWithContext(type=shortname, route=SERVICENAME)
                applog('Loading Application Plugin')
                applog('Creating Application Manager')
                manager = AppManager(shortname)
                manager.parentService = self
                #check and see if the model is bound
                if not AppManager(shortname).running:
                    applog('Starting Application Manager')
                    manager.start()
            except:
                failure = Failure()
                #bad plugin, not adaptable
                failures = (InvalidPlugin, TypeError)
                if failure.check(*failures) and manager:
                    log('plugin for %s is invalid' % (manager.name, ))
                    manager.action.__class__.delete(manager.action)
                    try:
                        pluginFactory.delete_plugin(manager.model)
                    except:
                        pass  #silence
                    AppManager.delete(manager)
                    if not config.EXCESSIVE_LOGGING:
                        continue  #avoid extra logging
                try:
                    failure.raiseException()
                except:
                    crashReport('ApplicationLoader', self)
        Service.startService(self)
        Event('instance-started').subscribe(self.reset_tracking)
        #wire allapps action into the server
        drone.builtins.update({
            'allapps': self.allapps_action,
            'applist': self.applist_action,
        })
        #delay scanning by some interval
        config.reactor.callLater(SERVICECONFIG.initial_delay,
                                 self._start_all_tasks)
示例#3
0
文件: appmgr.py 项目: c0ns0le/droned
    def debugReport(self, FromDeferred=False):
        """Friendly Debug Reporting in the Logs

           handles instances of twisted.python.failure.Failure
           
           This method is callback chain safe
        """
        if isinstance(FromDeferred, Failure):
            try:
                FromDeferred.raiseException()
            except:
                pass  #just need the current exception in sys.exc_info
            crashReport('Service [%s]: Caught unhandled exception' % \
                    (self.name,), self)
        #assume this can be part of a callback chain
        return FromDeferred
示例#4
0
   def startService(self):
       """Start All AppManager Services"""
       if self.scanning.called: #need to pre-populate values
           self.scanning = defer.maybeDeferred(self._first_scan)
       self.first_run = True
       self._task = task.LoopingCall(self.scan_app_instances)

       #plugins will be created and loaded when needed
       for shortname in config.APPLICATIONS.keys():
           manager = None
           try:
               applog = logWithContext(type=shortname,route=SERVICENAME)
               applog('Loading Application Plugin')
               applog('Creating Application Manager')
               manager = AppManager(shortname)
               manager.parentService = self
               #check and see if the model is bound
               if not AppManager(shortname).running:
                   applog('Starting Application Manager')
                   manager.start()
           except:
               failure = Failure()
               #bad plugin, not adaptable
               failures = (InvalidPlugin, TypeError)
               if failure.check(*failures) and manager:
                   log('plugin for %s is invalid' % (manager.name,))
                   manager.action.__class__.delete(manager.action)
                   try: pluginFactory.delete_plugin(manager.model)
                   except: pass #silence
                   AppManager.delete(manager)
                   if not config.EXCESSIVE_LOGGING: continue #avoid extra logging
               try: failure.raiseException()
               except: crashReport('ApplicationLoader', self)
       Service.startService(self)
       Event('instance-started').subscribe(self.reset_tracking)
       #wire allapps action into the server
       drone.builtins.update({
           'allapps': self.allapps_action,
           'applist': self.applist_action,
       })
       #delay scanning by some interval
       config.reactor.callLater(SERVICECONFIG.initial_delay, self._start_all_tasks)