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
def __init__(self): """ Constructor for monster base class. Initiates observable args: param(self) """ Observable.__init__(self)
def __init__(self, config): self._config = config self._mame = None self._connection = None self._running = False Observable.__init__(self) threading.Thread.__init__(self)
def __init__(self, trig, echo): Thread.__init__(self) self.trig = trig self.echo = echo self.distance = UltraSonicSensor.DISTANCE_DEFAULT Observable.__init__(self) self.cont = True
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
def __init__(self, app=None): Observable.__init__(self) self.app = None self.resources = {} if app is not None: self.init_app(app)
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'
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
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 + ") "
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 = []
def __init__(self): # Create Home as an Observer object Observer.__init__(self) # Create Home as an Observable object Observable.__init__(self) # Monsters/NPCs within the house self.monsters = [] # Populates the homes with random monsters for i in range(randint(0, 10)): randNum = randint(1, 5) if (randNum == 1): currMonster = Persons() elif (randNum == 2): currMonster = Zombies() elif (randNum == 3): currMonster = Ghouls() elif (randNum == 4): currMonster = Vampires() elif (randNum == 5): currMonster = Werewolves() # Has house observe each monster currMonster.add_observer(self) self.monsters.append(currMonster)
def __init__(self, *args, **kwargs): self._children = [] self.synchronize_on_event = {} Observable.__init__(self, *args, **kwargs) self.add_observer("any", self._replicate_event) self.synchronize_on_all_events()
def __init__(self): SaveableType.__init__(self) Observable.__init__(self) self.values = [] self.signal_add = Signal() self.signal_remove = Signal() self.array_type = array_type self.signal_changed = Signal()
def __init__(self): Observable.__init__(self) self.level = 0 self.isPaused = True self.id = None self.currClip = None self.currClipIndex = None self.name = None self.md5 = None self.dDBook = None self.msg = "Welcome to Daisy Delight"
def __init__(self,connection,transparent): Observable.__init__(self) self.connection = connection self.transparent = transparent connection.addListeners(self) self.datas = HostsInfos() self.nas= Nas(connection, transparent, self.datas) self.L2=LearningSwitch(connection, transparent) self.add_observer(self.nas,'nac') self.dhcp_interceptor = DhcpIntercept(connection, transparent, self.datas) self.add_observer(self.dhcp_interceptor,'dhcp')
def __init__(self, app=None, ssl=False, ssl_cert=None, ssl_pem=None): Observable.__init__(self) self.app = None self.resources = {} if app is not None: self.init_app(app) if ssl and ssl_cert and ssl_pem: self.ssl = True self.ssl_cert = ssl_cert self.ssl_pem = ssl_pem
def __init__(self): Thread.__init__(self) Observable.__init__(self) self.scanListe=[] self.ScannerNessus=Nessus() self.attenteNessus=[] try: self.ScannerNessus.connexion() except: pass self.log=log(CHEMIN_LOGS+'scan.log','scanner.'+'srv_tache')
def __init__(self, platform): Observable.__init__(self) self._platform = platform self._event_filters = [] self._timeout = None self._subscription = { 'eventFilters': [], 'expirationTime': '', # 2014-03-12T19:54:35.613Z 'expiresIn': 0, 'deliveryMode': { 'transportType': 'PubNub', 'encryption': False, 'address': '', 'subscriberKey': '', 'secretKey': '' }, 'id': '', 'creationTime': '', # 2014-03-12T19:54:35.613Z 'status': '', # Active 'uri': '' } self._pubnub = None
def __init__(self, position=None, label=None, shape=None, size=None, color=None, filled=None, comment=None): Observable.__init__(self, [ "position", "label", "shape", "size", "color", "filled", "comment" ]) # Position in image space self.position = position if position is not None else [0., 0., 0.] self.label = label or "" # Integer, value in ImageAnnotation.Shape self.shape = shape or ImageAnnotation.Shape.sphere self.size = size or 0. # RGB color, each component in 0,1 range self.color = color or [0., 0., 0.] self.filled = filled or False self.comment = comment or ""
def __init__(self, connection, transparent, host_authenticated): Observable.__init__(self) Thread.__init__(self) self.radclient = radClient(rad_secret, rad_addr, rad_authport) self.connection = connection self.transparent = transparent self.hosts_authenticated = host_authenticated self.host_progress={} #Permet de stocker la liste des machines en cours d'authentification #{'aa:bb:cc:dd:ee:ff': # { # 'switch': mac_addr, # 'port': int, # 'match':[], # 'internal-identity': toto, # 'external-identity': toto, # 'mac': aa:bb:cc:dd:ee:ff, # 'authenticated': False #Case for periodic-authenticated # } #} self.start()
def __init__(self, hostname): Observable.__init__(self) self.play_status = '' self.current_song = [] self.song_time_elapsed = 0 self.song_time_total = 0 self.volume = 0 self.client = MPDClient() self.client.timeout = 10 self.client.idletimeout = None connected = False logger.debug('Connecting') while not connected: try: logger.debug('.') self.client.connect(hostname, 6600) connected = True logger.debug('Connected') except mpd.ConnectionError: time.sleep(0.2) self.time_thread = None
def __init__(self, *args, **kwargs): Observable.__init__(self) list.__init__(self, *args, **kwargs)
def __init__(self): Observable.__init__(self)
def __init__(self): Observable.__init__(self) Thread.__init__(self) self._observers = []
def __init__(self, connection, transparent, host_authenticated): Observable.__init__(self) self.connection = connection self.transparent = transparent self.hosts_authenticated = host_authenticated self.sock= socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
def __init__(self): Observable.__init__(self) self.generateMonsters()
def __init__(self, shape=(0, ), dtype=numpy.single, spacing=None, origin=None, direction=None, data_type="scalar", image_type="normal", annotations=None, metadata=None, **kwargs): """ Create an image. Extra arguments may contain : * data or value (mutually exclusive) * dti * any other argument of numpy.ndarray.__init__ """ ################## # Public members # ################## # Numpy array holding the voxel values self.data = None # Type/dimensionality of the data : can be one of scalar, vector, or matrix self.data_type = data_type # Acquisition modality of the image : can be normal or spectroscopy. TODO : use metadata self.image_type = image_type # Annotations on the image. TODO : store them in metadata self.annotations = ObservableList(annotations or []) # Metadata self.metadata = metadata or {} ############################ # Property-related members # ############################ # Spacing between pixels, in mm self._spacing = None # Origin of the image, in mm self._origin = None # Matrix of direction cosines that specify the direction between samples self._direction = None self._index_to_physical_matrix = None self._physical_to_index_matrix = None ################## # Initialization # ################## Observable.__init__(self, ["modified"]) # Modify the shape of DTI images if "dti" in kwargs: self.data_type = "vector" if kwargs["dti"] == "tensor_2": self.image_type = "tensor_2" shape = list(shape) shape.append(6) # elif kwargs["dti"] == "tensor_4" : # pass else: raise exception.Exception("Unkown DTI model : %s" % kwargs["dti"]) del kwargs["dti"] # Array initialization : either data or value if "data" in kwargs and "value" in kwargs: raise exception.Exception("Only one of data and value is allowed") if "data" in kwargs: self.data = numpy.asarray(kwargs["data"]) del kwargs["data"] else: if "value" in kwargs: value = kwargs["value"] del kwargs["value"] else: value = None self.data = numpy.ndarray(shape, dtype, **kwargs) if value is not None: self.data.fill(value) if spacing is None: self._set_spacing(self._default_spacing()) else: self._set_spacing(spacing) if origin is None: self._set_origin(self._default_origin()) else: self._set_origin(origin) if direction is None: self._set_direction(self._default_direction()) else: self._set_direction(direction)