当前位置: 首页>>代码示例>>Python>>正文


Python observable.Observable类代码示例

本文整理汇总了Python中observable.Observable的典型用法代码示例。如果您正苦于以下问题:Python Observable类的具体用法?Python Observable怎么用?Python Observable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Observable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

 def __init__(self, config):
     self._config = config
     self._mame = None
     self._connection = None
     self._running = False
     Observable.__init__(self)
     threading.Thread.__init__(self)
开发者ID:Centurix,项目名称:Frontside,代码行数:7,代码来源:scanner.py

示例2: __init__

    def __init__(self, app=None):
        Observable.__init__(self)
        self.app = None
        self.resources = {}

        if app is not None:
            self.init_app(app)
开发者ID:cravler,项目名称:flask-twisted,代码行数:7,代码来源:__init__.py

示例3: __init__

 def __init__(self):
     self.Name = Observable(None)
     self.FullPath = Observable(None)
     self.Magic = Observable(None)
     self.Format = Observable(None)
     self.Directory = Observable(None)
     self.Magic.addCallback(self,self.OnMagic)
开发者ID:osynge,项目名称:vmimagemanagerSgeInt,代码行数:7,代码来源:archiveModel.py

示例4: subscribe

 def subscribe(self, *args, **keys):
     Observable.subscribe( self, *args, **keys )
     if self.dirty:
         self._notifyDirty()
 #
 #def _getRecursiveDirty(self):
 #    if self.dirty:
 #        return True
 #    
 #    for name, value in vars(self).items():
 #        if hasattr(name, 'dirty'):
 #            if value.recursiveDirty:
 #                return True
 #    
 #    return False
 #
 #def _setRecursiveDirty(self, dirtyValue):
 #    for name in self.observer_attribs:
 #        value = getattr(self, name)
 #        try:
 #            value.recursiveDirty = dirtyValue
 #        except AttributeError:
 #            pass
 #        #value.dirty = False
 #        pass
 #            
 #    self.dirty = dirtyValue
 #
 #recursiveDirty = property( _getRecursiveDirty, _setRecursiveDirty )
开发者ID:acarl123,项目名称:wxPython,代码行数:29,代码来源:dirtyObservable.py

示例5: __init__

    def __init__(self, trigger, func, args, kwargs, misfire_grace_time,
                 coalesce, name=None, max_runs=None, max_instances=1, active=True):
        Observable.__init__(self)
        if not trigger:
            raise ValueError('The trigger must not be None')
        if not hasattr(func, '__call__'):
            raise TypeError('func must be callable')
        if not hasattr(args, '__getitem__'):
            raise TypeError('args must be a list-like object')
        if not hasattr(kwargs, '__getitem__'):
            raise TypeError('kwargs must be a dict-like object')
        if misfire_grace_time <= 0:
            raise ValueError('misfire_grace_time must be a positive value')
        if max_runs is not None and max_runs <= 0:
            raise ValueError('max_runs must be a positive value')
        if max_instances <= 0:
            raise ValueError('max_instances must be a positive value')


        self._lock = Lock()
        self.trigger = trigger
        self.func = func
        self.args = args
        self.kwargs = kwargs
        self.name = to_unicode(name or get_callable_name(func))
        self.misfire_grace_time = misfire_grace_time
        self.coalesce = coalesce
        self.max_runs = max_runs
        self.max_instances = max_instances
        self.runs = 0
        self.instances = 0
        self.active = active
开发者ID:ecdpalma,项目名称:napscheduler,代码行数:32,代码来源:job.py

示例6: __init__

    def __init__(self,id_scan,nom_unique,type_scan,chemin_rapport,liste_adresses,nmap_options=None,nessus_policy_id=None):
        Observable.__init__(self)
        self.nmap={'enable':False,'options':None,'instance':None,'status':'disable','progress':0,'import':'disable'}
        self.nessus={'enable':False,'id':-1,'policy_id':None,'status':'disable','progress':0,'import':'disable'}
        self.erreurs=[]
        self.cibles=liste_adresses
        self.nom_unique=nom_unique
        self.chemin_rapport=chemin_rapport
        self.id_scan=id_scan
        self.tache_attente=[]
        self.compteur_erreur_nessus=0
        self.type_scan=type_scan

        if nmap_options!=None:
            self.nmap['enable']=True
            self.nmap['options']=nmap_options
            self.nmap['status']='ready'
            self.nmap['import']='ready'
            self.nmap['instance']=scanNmap(self.cibles,self.nmap['options'],CHEMIN_TEMP+'nmap/'+str(self.nom_unique)+'.xml')


        if nessus_policy_id!=None:
            self.nessus['enable']=True
            self.nessus['policy_id']=nessus_policy_id
            self.nessus['status']='ready'
            self.nessus['import']='ready'
开发者ID:LeGaulois,项目名称:soc,代码行数:26,代码来源:scanner.py

示例7: __init__

    def __init__(self, tableau_adresse, options, fichier_sortie):
        Thread.__init__(self)
        Observable.__init__(self)
        self.adresse = ""
        self.progress = 0.0
        self.status = "ready"

        # On cree un string a partir de la liste des adresses
        # contenues dans le tableau
        for ip in tableau_adresse:
            try:
                ip = valideIP(ip)
                self.adresse += " " + str(ip)
            except:
                pass

        liste_arguments = [options, fichier_sortie]

        # Contrôle des arguments
        for arg in liste_arguments:
            error = re.search('[;|<>"`&{}]', str(arg))

            if error != None:
                raise Exception("Paramètres Nmap invalide")

        # Si pas de levé d'exception
        self.options = options
        self.fichier_sortie = fichier_sortie
开发者ID:LeGaulois,项目名称:soc,代码行数:28,代码来源:client_nmap.py

示例8: __init__

	def __init__(self, network_interface, src_ip, target_ip):
		Observable.__init__(self)
		Executable.__init__(self, self.ping_executable)
		self.network_interface = network_interface
		self.src_ip = src_ip
		self.target_ip = target_ip
		print "# Setting up loop for pinging " + target_ip + " (with " + src_ip + " on " + network_interface + ") "
开发者ID:figgefred,项目名称:arp-failover,代码行数:7,代码来源:pingloop.py

示例9: __init__

    def __init__(self, config, environ, logger, statechglogger):
        Observable.__init__(self)
        self.config = config
        self.environ = environ
        self.statechglogger = statechglogger
        self.logdispatch = logger
        self.rulenumber = 0
        self.rulename = 'template class'
        self.mandatory = False
        self.helptext = """This is the default help text for the base rule
class. If you are seeing this text it is because the developer for one of the
rules forgot to assign the appropriate help text. Please file a bug against
LANL-stonix."""
        self.executionpriority = 50
        self.rootrequired = True
        self.configinsimple = False
        self.detailedresults = """This is the default detailed results text
        for the base rule class. If you are seeing this text it is because the
        developer for one of the rules forgot to assign the appropriate text.
        Please file a bug against stonix."""
        self.compliant = False
        self.rulesuccess = True
        self.databaserule = False
        self.applicable = {'default': 'default'}
        self.revertable = False
        self.confitems = []
        self.currstate = "notconfigured"
        self.targetstate = "configured"
        self.guidance = []
开发者ID:inscriptionweb,项目名称:stonix,代码行数:29,代码来源:rule.py

示例10: __init__

 def __init__(self, environment):
     Observable.__init__(self)
     self.environment = environment
     self.debug = self.environment.getdebugmode()
     self.verbose = self.environment.getverbosemode()
     self.constsrequired = [localize.REPORTSERVER,
                            localize.STONIXDEVS,
                            localize.STONIXERR,
                            localize.MAILRELAYSERVER]
     reportfile = 'stonix-report.log'
     xmlfile = 'stonix-xmlreport.xml'
     self.logpath = self.environment.get_log_path()
     self.reportlog = os.path.join(self.logpath, reportfile)
     self.xmllog = os.path.join(self.logpath, xmlfile)
     if self.debug:
         print 'LOGDISPATCHER: xml log path: ' + self.xmllog
     if os.path.isfile(self.xmllog):
         try:
             if os.path.exists(self.xmllog + '.old'):
                 os.remove(self.xmllog + '.old')
             move(self.xmllog, self.xmllog + '.old')
         except (KeyboardInterrupt, SystemExit):
             # User initiated exit
             raise
         except Exception, err:
             print 'logdispatcher: '
             print traceback.format_exc()
             print err
开发者ID:CSD-Public,项目名称:stonix,代码行数:28,代码来源:logdispatcher.py

示例11: QuackCounter

class QuackCounter(Quackable):

    number_of_quacks = 0

    def __init__(self, quackable):
        self._quackable = quackable
        self._observable = Observable(self)

    def __repr__(self):
        return repr(self._quackable)

    def quack(self):
        self._quackable.quack()
        QuackCounter.number_of_quacks += 1
        self.notify_observers()

    def register_observer(self, observer):
        self._observable.register_observer(observer)

    def notify_observers(self):
        self._observable.notify_observers()

    @classmethod
    def get_quacks(cls):
        return cls.number_of_quacks
开发者ID:lk9025,项目名称:PyPattern,代码行数:25,代码来源:duck.py

示例12: test_no_event_for_trigger

def test_no_event_for_trigger():
    """test exception raising for not existing events"""
    obs = Observable()

    assert not obs.trigger("no_existing_event")

    with pytest.raises(EventNotFound):
        obs.off("no_existing_event")
开发者ID:timofurrer,项目名称:pyobservable,代码行数:8,代码来源:test_core.py

示例13: refresh_play_status

 def refresh_play_status(self):
     logger.debug("refresh_playing_status")
     try:
         status = self.get_status()
         if 'state' in status:
             self.play_status = status['state']
         Observable.notify_toggle_observers(self, {'status': self.play_status})
     except mpd.ConnectionError:
         logger.error('Lost connection on get get_playing_status')
开发者ID:lgnap,项目名称:pitft-mpd-controller,代码行数:9,代码来源:mpc.py

示例14: test_on

def test_on():
    """test event registering with the on method"""
    obs = Observable()

    def on_test():
        pass

    obs.on("on_test", on_test)
    assert on_test in obs._events["on_test"]
开发者ID:timofurrer,项目名称:pyobservable,代码行数:9,代码来源:test_core.py

示例15: test_trigger_arg

def test_trigger_arg():
    """test event triggering with arguments"""
    obs = Observable()

    @obs.on("some_test")
    def some_test(some_data):
        assert some_data == "some data"

    assert obs.trigger("some_test", "some data")
开发者ID:timofurrer,项目名称:pyobservable,代码行数:9,代码来源:test_core.py


注:本文中的observable.Observable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。