def handle_accept(self): newsock, addr = self.accept() if self._connIsAllowedFrom(addr[0]): logging.debug('Replying to interactive query from %s' % addr[0]) InteractiveConnectionHandler(newsock) else: logging.info('Interactive query from %s rejected by rule' % addr[0])
def trace_actual(aFunc): ''' Trace entry, exit and exceptions. ''' def loggedFunc(*args, **kwargs): _log_suffix = "" try: _log_prefix = aFunc.__module__ + ".py/" + aFunc.__class__.__name__ _log_prefix += '.' + aFunc.__name__ except AttributeError: _log_prefix = aFunc.__module__ + ".py/" + aFunc.__name__ _msg = _log_prefix + " - Entry point " + _log_suffix logging.debug(_msg) try: result = aFunc(*args, **kwargs) except Exception, e: _msg = _log_prefix + " - Exit point (Exception \"" + str( e) + "\") " _msg += _log_suffix logging.debug(_msg) raise _msg = _log_prefix + " - Exit point " + _log_suffix logging.debug(_msg) return result
def trace_actual(aFunc): ''' Trace entry, exit and exceptions. ''' def loggedFunc(*args, **kwargs ): _log_suffix = "" try : _log_prefix = aFunc.__module__ + ".py/" + aFunc.__class__.__name__ _log_prefix += '.' + aFunc.__name__ except AttributeError : _log_prefix = aFunc.__module__ + ".py/" + aFunc.__name__ _msg = _log_prefix + " - Entry point " + _log_suffix logging.debug( _msg) try: result = aFunc(*args, **kwargs ) except Exception, e: _msg = _log_prefix + " - Exit point (Exception \"" + str(e) + "\") " _msg += _log_suffix logging.debug(_msg) raise _msg = _log_prefix + " - Exit point " + _log_suffix logging.debug(_msg) return result
def handle_accept(self): newsock, addr = self.accept() if self._connIsAllowedFrom(addr[0]): logging.debug('Replying to XML dump query from %s' % addr[0]) writer = XmlWriter() newsock.sendall(writer.getXml()) newsock.close() else: logging.info('XML dump query from %s rejected by rule' % addr[0])
def loggedFunc(self, *args, **kwargs ): _log_suffix = "" try : _log_prefix = self.__module__ + ".py/" + self.__class__.__name__ _log_prefix += '.' + aFunc.__name__ except AttributeError : _log_prefix = aFunc.__module__ + ".py/" + aFunc.__name__ _msg = _log_prefix + " - Entry point " + _log_suffix logging.debug( _msg) try: result= aFunc(self, *args, **kwargs ) except Exception, e: _msg = _log_prefix + " - Exit point (Exception \"" + str(e) + "\") " _msg += _log_suffix logging.debug(_msg) raise
ignore_fds.append(fileHandler.stream.fileno()) logging.getLogger().addHandler(fileHandler) # Determine if the service should be daemonized based on the debug level. if 5 > _lverbosity: daemonize(ignore_fds) logging.info('Gmetad application started.') # Create a PID file if the command line parameter was specified. pffd = None if gmetadConfig[GmetadConfig.PIDFILE] is not None: try: pffd = open(gmetadConfig[GmetadConfig.PIDFILE], 'w') pffd.write('%d\n' % os.getpid()) logging.debug('Wrote pid %d to pidfile %s' % (os.getpid(), gmetadConfig[GmetadConfig.PIDFILE])) pffd.close() pffd = open(gmetadConfig[GmetadConfig.PIDFILE], 'r') except Exception as e: logging.error('Unable to write PID %d to %s (%s)' % (os.getpid(), gmetadConfig[GmetadConfig.PIDFILE], e)) sys.exit() # Switch to non-priviledged user if running as root if not os.getuid(): setuid() # Initialize the data store with the notifier and summery threads and plugins dataStore = DataStore() readers = [] xmlSocket = XmlSocket()
ignore_fds.append(fileHandler.stream.fileno()) logging.getLogger().addHandler(fileHandler) # Determine if the service should be daemonized based on the debug level. if 5 > _lverbosity: daemonize(ignore_fds) logging.info('Gmetad application started.') # Create a PID file if the command line parameter was specified. pffd = None if gmetadConfig[GmetadConfig.PIDFILE] is not None: try: pffd = open(gmetadConfig[GmetadConfig.PIDFILE], 'w') pffd.write('%d\n' % os.getpid()) logging.debug('Wrote pid %d to pidfile %s' % (os.getpid(), gmetadConfig[GmetadConfig.PIDFILE])) pffd.close() pffd = open(gmetadConfig[GmetadConfig.PIDFILE], 'r') except Exception, e: logging.error('Unable to write PID %d to %s (%s)' % (os.getpid(), gmetadConfig[GmetadConfig.PIDFILE], e)) sys.exit() # Switch to non-priviledged user if running as root if not os.getuid(): setuid() # Initialize the data store with the notifier and summery threads and plugins dataStore = DataStore() readers = [] xmlSocket = XmlSocket()