Exemplo n.º 1
0
 def send(self, worker_id, data):
     worker = self.lookup_worker(worker_id)
     if worker is None:
         log.warning('Worker {0} not available'.format(worker))
         return
     log.debug('Sending:{0} to {1}'.format(data, worker))
     self.connection.send(data, worker)
Exemplo n.º 2
0
 def read_config(self, configfile=""):
     try:
         if configfile != "":
             self.file = configfile
         raw = open(self.file, "r")
         data = yaml.load(raw)
         self.communication = CommunicationConfig()
         communication_found = False
         master_found = False
         for name, section in data.items():
             if is_communication(name):
                 if communication_found:
                     log.warning("More than one communication node found, discarding")
                 else:
                     communication_found = True
                     self.communication.set_from_yaml(section)
             elif is_master(name):
                 if master_found:
                     log.warning("More than one master found, discarding")
                 else:
                     master_found = True
                     self.master = MasterConfig()
                     self.master.set_from_yaml(section)
             elif is_workers(name):
                 for worker_node in section:
                     worker = WorkerConfig()
                     worker.set_from_yaml(worker_node[CONFIG_WORKER])
                     self.workers.append(worker)
             else:
                 log.warning("Unknown module found {0}!".format(str(name)))
         if not communication_found:
             log.warning("No communication node found, defaults will be used")
     except Exception as e:
         log.warning("Unable to load config file {0} : {1}".format(self.file, e.args[0]))
Exemplo n.º 3
0
 def send(self, worker_id, data):
     worker = self.lookup_worker(worker_id)
     if worker is None:
         log.warning('Worker {0} not available'.format(worker))
         return
     log.debug('Sending:{0} to {1}'.format(data, worker))
     self.connection.send(data, worker)
Exemplo n.º 4
0
 def read_config(self, configfile=''):
     try:
         if configfile != '':
             self.file = configfile
         raw = open(self.file, 'r')
         data = yaml.load(raw)
         self.communication = CommunicationConfig()
         communication_found = False
         master_found = False
         for name, section in data.items():
             if is_communication(name):
                 if communication_found:
                     log.warning('More than one communication node found, discarding')
                 else:
                     communication_found = True
                     self.communication.set_from_yaml(section)
             elif is_master(name):
                 if master_found:
                     log.warning('More than one master found, discarding')
                 else:
                     master_found = True
                     self.master = MasterConfig()
                     self.master.set_from_yaml(section)
             elif is_workers(name):
                 for worker_node in section:
                     worker = WorkerConfig()
                     worker.set_from_yaml(worker_node[CONFIG_WORKER])
                     self.workers.append(worker)
             else:
                 log.warning('Unknown module found {0}!'.format(str(name)))
         if not communication_found:
             log.warning('No communication node found, defaults will be used')
     except Exception as e:
         log.warning('Unable to load config file {0} : {1}'.format(self.file, e.args[0]))
Exemplo n.º 5
0
 def check(self):
     if self.simulation:
         return True
     try:
         with open(self.io) as file:
             return True
     except IOError as e:
         log.warning("Unable to find/open \"{0}\"".format(self.io))
         return False
Exemplo n.º 6
0
 def check(self):
     if self.simulation:
         return True
     try:
         with open(self.io) as file:
             return True
     except IOError as e:
         log.warning("Unable to find/open \"{0}\"".format(self.io))
         return False