Ejemplo n.º 1
0
def initJobConfigs():
    global JOB_CONFIGS
    if JOB_CONFIGS is None:
        log         = getLogger()
        cfg         = getConfig()
        log.info("initializing job configurations")
        jobdir      = getConfig().get('global', 'jobdir')
        JOB_CONFIGS = dict()
        if os.path.isdir(jobdir):
            for entry in os.listdir(jobdir):
                name, ext = os.path.splitext(entry)
                filename  = os.path.join(jobdir, entry)
                if os.path.isfile(filename) and ext == '.conf':
                    JOB_CONFIGS[name] = name
        else:
            log.error("job directory doesn't exist: {0}".format(jobdir))
Ejemplo n.º 2
0
def initClientConfigs():
    global CLIENT_CONFIGS
    if CLIENT_CONFIGS is None:
        log            = getLogger()
        cfg            = getConfig()
        log.info("initializing client configurations")
        clientdir      = getConfig().get('global', 'clientdir')
        CLIENT_CONFIGS = dict()
        if os.path.isdir(clientdir):
            for entry in os.listdir(clientdir):
                name, ext = os.path.splitext(entry)
                filename  = os.path.join(clientdir, entry)
                if os.path.isfile(filename) and ext == '.conf':
                    CLIENT_CONFIGS[name] = name
        else:
            log.error("client directory doesn't exist: {0}".format(clientdir))
Ejemplo n.º 3
0
 def __init_config__(self):
     jobdir  = getConfig().get('global', 'jobdir')
     jobfile = os.path.join(jobdir, self.name+".conf")
     getLogger().info("loading job configuration: " + self.name)
     self.read(jobfile)
     if not self.has_section('job'):
         msg = "invalid job configuration"
         getLogger().error(msg)
         raise ValueError, msg
Ejemplo n.º 4
0
 def __init__(self, section):
     self.config  = getConfig()
     self.section = section
     self.log     = getLogger('storage')
     self.joblist = list()
     if not self.config.has_section(self.section):
         msg = "unknown section: "+section
         self.log.error(msg)
         raise ValueError, msg
Ejemplo n.º 5
0
 def __init_config__(self):
     clientdir  = getConfig().get('global', 'clientdir')
     clientfile = os.path.join(clientdir, self.name+".conf")
     getLogger().info("loading client configuration: " + self.name)
     self.read(clientfile)
     if not (self.has_section('client') and self.has_option('client', 'address')):
         msg = "invalid job configuration"
         getLogger().error(msg)
         raise ValueError, msg
Ejemplo n.º 6
0
def initLogger(verbose=False, debug=False):
    global LOG, LOG_BASE, LOG_HANDLER
    if LOG is None:
        cfg      = getConfig()
        LOG_BASE = "rpync."+getConfigType()
        # Set up console formatter and handler
        console_formatter = logging.Formatter("%(name)s %(levelname)s: %(message)s")
        console_handler   = logging.StreamHandler()
        if verbose:
            console_handler.setLevel(logging.DEBUG if debug else logging.INFO)
        else:
            console_handler.setLevel(logging.ERROR)
        console_handler.setFormatter(console_formatter)
        # Set up file formatter and handler
        file_formatter = logging.Formatter("[%(asctime)s] %(name)s %(levelname)s: %(message)s")
        file_handler   = logging.FileHandler(cfg.get('global', 'logfile'),'wb')
        file_handler.setLevel(logging.DEBUG if debug else logging.INFO)
        file_handler.setFormatter(file_formatter)
        # Initialize logger
        LOG          = logging.getLogger(LOG_BASE)
        LOG_HANDLERS = (console_handler, file_handler)
        LOG.setLevel(logging.DEBUG)
        LOG.addHandler(console_handler)
        LOG.addHandler(file_handler)
Ejemplo n.º 7
0
def initStorage():
    global STORAGE_INSTANCE
    if STORAGE_INSTANCE is None:
        getLogger().info("initializing storage")
        STORAGE_INSTANCE = createStorage(getConfig(), SECTION)
Ejemplo n.º 8
0
 def startFactory(self):
     BaseServerProtocolFactory.startFactory(self)
     # Bootstrap
     self.config = getConfig()
     self.log = getLogger()
     self.log.info("version {0}".format(rpync.__version__))