def test_get_config_defaults(self): cfg = config.get_config(ini_file='non-existent') self.assertEquals('z48', cfg.get('sampler', 'type')) self.assertEquals('localhost', cfg.get('osc', 'host')) self.assertEquals(6575, cfg.getint('osc', 'port')) self.assertEquals(6575, cfg.getint('osc_client', 'port')) self.assertEquals('INFO', cfg.get('logging', 'level'))
def __init__(self, *args, **kw): # todo postpone sampler init common.AksyFS().__init__() fuse.Fuse.__init__(self, *args, **kw) self.multithreaded = True cfg = config.get_config() self.sampler_type = cfg.get('sampler', 'type') self.connector = config.get_value(cfg, 'sampler', 'connector') self.file_class = AksyFile stat_home = os.stat(os.path.expanduser('~')) common.StatInfo.set_owner(stat_home[stat.ST_UID], stat_home[stat.ST_GID])
def test_get_config(self): cfg = config.get_config(INI_FILE) self.assertEquals('z48', cfg.get('sampler', 'type')) self.assertEquals('localhost', cfg.get('osc', 'host')) self.assertEquals(6576, cfg.getint('osc', 'port'))
# package aksy import logging, logging.config, logging.handlers, time, os.path, sys from aksy.config import get_config # initialize logging logger = logging.getLogger('aksy') level = getattr(logging, get_config().get('logging', 'level')) logger.setLevel(level) logdir = os.path.expanduser('~/.aksy/logs') if not os.path.exists(logdir): os.makedirs(logdir) script_name = os.path.basename(sys.argv[0]) handler = logging.FileHandler(os.path.expanduser('~/.aksy/logs/%s_%s.log' % (script_name, time.strftime("%Y%m%d")))) formatter = logging.Formatter(fmt="%(asctime)s %(levelname)s %(name)s:%(lineno)d %(message)s") handler.setFormatter(formatter) logger.addHandler(handler)
# package aksy import logging, logging.config, logging.handlers, time, os.path, sys from aksy.config import get_config # initialize logging logger = logging.getLogger('aksy') level = getattr(logging, get_config().get('logging', 'level')) logger.setLevel(level) logdir = os.path.expanduser('~/.aksy/logs') if not os.path.exists(logdir): os.makedirs(logdir) script_name = os.path.basename(sys.argv[0]) handler = logging.FileHandler( os.path.expanduser('~/.aksy/logs/%s_%s.log' % (script_name, time.strftime("%Y%m%d")))) formatter = logging.Formatter( fmt="%(asctime)s %(levelname)s %(name)s:%(lineno)d %(message)s") handler.setFormatter(formatter) logger.addHandler(handler)