def child_callback(self, child_id, record): """ \brief Processes records received by the child node \param child_id identifier of the child that received the record \param record dictionary representing the received record """ if record.is_last(): # XXX SEND ALL self.status.completed(child_id) return key = self.key.get_field_names() # DISTINCT not implemented, just forward the record if not key: Log.critical("No key associated to UNION operator") self.send(record) return # Send records that have no key if not Record.has_fields(record, key): Log.info( "UNION::child_callback sent record without key '%(key)s': %(record)r", **locals()) self.send(record) return key_value = Record.get_value(record, key) if key_value in self.key_map: Log.debug("UNION::child_callback merged duplicate records: %r" % record) prev_record = self.key_map[key_value] for k, v in record.items(): if not k in prev_record: prev_record[k] = v continue if isinstance(v, list): if not prev_record[k]: prev_record[k] = list( ) # with failures it can occur that this is None prev_record[k].extend(v) # DUPLICATES ? #else: # if not v == previous[k]: # print "W: ignored conflictual field" # # else: nothing to do else: self.key_map[key_value] = record
def check_python_daemon(self): """ \brief Check whether python-daemon is properly installed \return True if everything is file, False otherwise """ # http://www.python.org/dev/peps/pep-3143/ ret = False try: import daemon getattr(daemon, "DaemonContext") ret = True except AttributeError, e: print e # daemon and python-daemon conflict with each other Log.critical( "Please install python-daemon instead of daemon. Remove daemon first." )
class Daemon(object): __metaclass__ = Singleton DEFAULTS = { # Running "uid": os.getuid(), "gid": os.getgid(), "working_directory": "/", "debugmode": False, "no_daemon": False, "pid_filename": "/var/run/%s.pid" % Options().get_name() } #------------------------------------------------------------------------- # Checks #------------------------------------------------------------------------- def check_python_daemon(self): """ \brief Check whether python-daemon is properly installed \return True if everything is file, False otherwise """ # http://www.python.org/dev/peps/pep-3143/ ret = False try: import daemon getattr(daemon, "DaemonContext") ret = True except AttributeError, e: print e # daemon and python-daemon conflict with each other Log.critical( "Please install python-daemon instead of daemon. Remove daemon first." ) except ImportError: Log.critical( "Please install python-daemon - easy_install python-daemon.")