def __init__(self,a_coll_start=0,a_coll_stop=0,a_acq_start=0,a_acq_stop=0,a_real = None): """ Constructor. Args: a_coll_start,a_coll_stop,a_acq_start,a_acq_stop as ISO String Dates a_live as ISO Period Returns: a Decimal to avoid carrying numerical arithemic inprecision errors To get a float do float(Decimal) and To get an int int(Decimal) Raises: exception if cannot connect to the server """ super(NobleGasDecayCorrector,self).__init__() self._coll_stop = -1 self._coll_start = -1 self._acq_stop = -1 self._acq_start = -1 self._a_real = -1 self._t_count = -1 self._t_real = -1 self._t_live = -1 self._t_prep = -1 self.set_time_information(a_coll_start, a_coll_stop, a_acq_start, a_acq_stop, a_real) self._log = LoggerFactory.get_logger(self)
def __init__(self,a_args): super(Runner,self).__init__() # create an empty shell Conf object self._conf = self._load_configuration(a_args) self._log = LoggerFactory.get_logger("Runner") # setup the prod database and connect to it self._ngDatabase = self._conf.get("NobleGazDatabaseAccess","hostname") self._ngUser = self._conf.get("NobleGazDatabaseAccess","user") self._ngPassword = self._conf.get("NobleGazDatabaseAccess","password") self._ngActivateTimer = self._conf.getboolean("NobleGazDatabaseAccess","activateTimer",True) # create DB connector self._ngMainConn = DatabaseConnector(self._ngDatabase,self._ngUser,self._ngPassword,self._ngActivateTimer) # setup the archive database and connect to it self._ArchiveDatabaseAccess = self._conf.get("ArchiveDatabaseAccess","hostname") self._archiveUser = self._conf.get("ArchiveDatabaseAccess","user") self._archivePassword = self._conf.get("ArchiveDatabaseAccess","password") self._archiveActivateTimer = self._conf.getboolean("ArchiveDatabaseAccess","activateTimer",True) # create DB connector self._ngArchConn = DatabaseConnector(self._ArchiveDatabaseAccess,self._archiveUser,self._archivePassword,self._archiveActivateTimer) #connect to the DBs self._ngMainConn.connect() self._ngArchConn.connect()
def __init__(self, a_template_dir='/home/aubert/dev/src-reps/java-balivernes/RNpicker/etc/conf/templates', \ a_template_name='SpalaxArrHtml-v1.0.html'): self._env = Environment(loader=FileSystemLoader(a_template_dir)) self._template = self._env.get_template(a_template_name) self._context = {} self._log = LoggerFactory.get_logger(self)
def print_general_exception(a_exception, a_parsed_args): """ print general exception. Complex case depending on the passed options and the fact the console handler might not have been instanciated. """ # check that the console hanlder has been set by the factory if LoggerFactory.is_console_handler_set(): LoggerFactory.get_logger("Runner").error( "%s. For more information see the log file %s.\nTry `generate_NG_arr --help (or -h)' for more information." % (a_exception, Conf.get_instance().get("Logging", "fileLogging", "/tmp/rnpicker.log")) ) if a_parsed_args.get("verbose", 1) == 3: a_logger = LoggerFactory.get_logger("Runner").error else: a_logger = Runner.log_in_file a_logger("Traceback: %s." % (get_exception_traceback())) else: # cannot get general logger so print print ("Fatal Error: Traceback: %s." % (get_exception_traceback()))
def __init__( self, aDataPath, aID, aRemoteOffset, aRemoteSize, aRemoteHostname=None, aRemoteScript=None, aRemoteUser=None, aLocalDir=None, a_DoNotUseCache=False, a_LocalFilename=None, ): # my variables super(RemoteArchiveDataSource, self).__init__(aDataPath, aID, aRemoteOffset, aRemoteSize) # get reference to the conf object self._conf = Conf.get_instance() self._remoteScript = ( self._conf.get("RemoteAccess", "archiveAccessScript") if aRemoteScript == None else aRemoteScript ) self._remoteHostname = ( self._conf.get("RemoteAccess", "archiveAccessHost") if aRemoteHostname == None else aRemoteHostname ) self._remoteUser = ( self._conf.get("RemoteAccess", "archiveAccessUser", self._getCurrentUser()) if aRemoteUser == None else aRemoteUser ) self._localDir = self._conf.get("RemoteAccess", "localDir") if aLocalDir == None else aLocalDir self._cachingActivated = ( self._conf.getboolean("RemoteAccess", "activateDataFileCaching") if (self._conf.has_option("RemoteAccess", "activateDataFileCaching") and a_DoNotUseCache == False) else False ) self._localFilename = ( "%s_%s.%s" % (os.path.basename(self._remotePath), self._id, self._getExtension(self._remotePath)) if a_LocalFilename == None else a_LocalFilename ) self._getRemoteFile() self._log = LoggerFactory.get_logger(self)
def __init__(self,a_server_host,a_server_port=25,a_login=None,a_password=None,a_debugging_level=0): super(DataEmailer,self).__init__() self._server_host = a_server_host # set to SMTP default if no ports are given self._server_port = a_server_port if (a_server_port != None) else 25 self._login = a_login self._password = a_password self._debug_level = a_debugging_level self._smtp_server = None self._log = LoggerFactory.get_logger(self)
def __init__(self,aDatabase,aUser,aPassword,aTimeReqs=False): self._database = aDatabase self._user = aUser self._password = aPassword self._activateTimer = aTimeReqs self._connected = False; #IGNORE:W0104 self._url = None self._createUrl() self._engine = None self._conn = None self._log = LoggerFactory.get_logger(self)
def __init__(self, aDataPath, aID, aOffset, aSize, aRemoteHostname=None, aRemoteScript=None, aRemoteUser=None): super(RemoteFSDataSource, self).__init__(aDataPath, aID, aOffset, aSize) self._remoteScript = ( self._conf.get("RemoteAccess", "prodAccessScript") if aRemoteScript == None else aRemoteScript ) self._remoteHostname = ( self._conf.get("RemoteAccess", "prodAccessHost") if aRemoteHostname == None else aRemoteHostname ) self._remoteUser = ( self._conf.get("RemoteAccess", "prodAccessUser", self._getCurrentUser()) if aRemoteUser == None else aRemoteUser ) self._getRemoteFile() self._log = LoggerFactory.get_logger(self)
def __init__(self, aDataPath, aID, aRemoteOffset, aRemoteSize): self.len = 0 self.buflist = [] self.pos = 0 self.closed = False self.softspace = 0 # my variables # get reference to the conf object self._conf = Conf.get_instance() self._remotePath = aDataPath self._id = aID self._localDir = self._conf.get("RemoteAccess", "localDir") self._cachingActivated = self._conf.getboolean("RemoteAccess", "activateDataFileCaching", False) self._localFilename = ( self._conf.get("RemoteAccess", "localFilename") if self._conf.has_option("RemoteAccess", "localFilename") else None ) self._fd = None # these two options are only read in the ArchiveDataSource for the moment. # This should be generalized to all Files and the hierachy might disapear ? # where to point in the file self._remoteOffset = aRemoteOffset # Size to read self._remoteSize = aRemoteSize self._log = LoggerFactory.get_logger(self)
def __init__(self, a_args): super(Runner, self).__init__() # create an empty shell Conf object self._conf = Conf.get_instance() self._log = LoggerFactory.get_logger("Runner") # setup the prod database and connect to it self._ngDatabase = self._conf.get("NobleGazDatabaseAccess", "hostname") self._ngUser = self._conf.get("NobleGazDatabaseAccess", "user") self._ngPassword = self._conf.get("NobleGazDatabaseAccess", "password") self._ngActivateTimer = self._conf.getboolean("NobleGazDatabaseAccess", "activateTimer", True) if self._conf.getboolean("NobleGazDatabaseAccess", "obfuscatePassword", False): self._ngPassword = ctbto.common.utils.deobfuscate_string(self._ngPassword) # create DB connector self._ngMainConn = DatabaseConnector(self._ngDatabase, self._ngUser, self._ngPassword, self._ngActivateTimer) # setup the archive database and connect to it self._ArchiveDatabaseAccess = self._conf.get("ArchiveDatabaseAccess", "hostname") self._archiveUser = self._conf.get("ArchiveDatabaseAccess", "user") self._archivePassword = self._conf.get("ArchiveDatabaseAccess", "password") if self._conf.getboolean("ArchiveDatabaseAccess", "obfuscatePassword", False): self._archivePassword = ctbto.common.utils.deobfuscate_string(self._archivePassword) self._archiveActivateTimer = self._conf.getboolean("ArchiveDatabaseAccess", "activateTimer", True) # create DB connector self._ngArchConn = DatabaseConnector( self._ArchiveDatabaseAccess, self._archiveUser, self._archivePassword, self._archiveActivateTimer ) # connect to the DBs self._ngMainConn.connect() self._ngArchConn.connect()
def log_in_file(self,aMessage): """ to log in the file as the ROOT logger """ log = LoggerFactory.get_logger("ROOT") log.info(aMessage)
usage() sys.exit(2) except ConfAccessError, e: # Not Runner set print print("Error - %s"%(e.get_message_error())) if parsed_args.get('verbose',1) == 3: print("Traceback: %s."%(get_exception_traceback())) usage() sys.exit(2) except LoggingSetupError, e: # Not Runner set print print("Error - %s"%(e.get_message_error())) sys.exit(2) except Exception, e: #IGNORE:W0703,W0702 try: LoggerFactory.get_logger("Runner").error("Error: %s. For more information see the log file %s.\nTry `generate_arr --help (or -h)' for more information."%(e,Conf.get_instance().get('Logging','fileLogging','/tmp/rnpicker.log'))) if parsed_args.get('verbose',1) == 3: a_logger = LoggerFactory.get_logger("Runner") else: a_logger = Runner.log_in_file a_logger("Traceback: %s."%(get_exception_traceback())) except: print("Fatal error that could not be logged properly. print Traceback in stdout: %s."%(get_exception_traceback())) #IGNORE:W0702 finally: sys.exit(3) sys.exit(0) if __name__ == "__main__":
def __init__(self,aDbConnector=None): self._dbConnector = aDbConnector self._callbackObj = None self._log = LoggerFactory.get_logger(self)
def __init__(self,): """ constructor """ # get reference to the conf object self._conf = Conf.get_instance() self._log = LoggerFactory.get_logger(self)