diff -r 703bba757605 -r af637235ca81 pgtoolkit/toolbase.py --- a/pgtoolkit/toolbase.py Fri Jan 25 18:04:17 2013 +0100 +++ b/pgtoolkit/toolbase.py Thu Jan 31 11:02:04 2013 +0100 @@ -36,22 +36,22 @@ def init_logging(self): # logging + format = ColoredFormatter(highlight(1,7,0)+'%(asctime)s %(levelname)-5s'+highlight(0)+' %(message)s', '%H:%M:%S') handler = logging.StreamHandler() - format = ColoredFormatter(highlight(1,7,0)+'%(asctime)s %(levelname)-5s'+highlight(0)+' %(message)s', '%H:%M:%S') handler.setFormatter(format) handler.setLevel(logging.DEBUG) self.log = logging.getLogger('main') self.log.addHandler(handler) self.log.setLevel(logging.DEBUG) - logger_notices = logging.getLogger('pgmanager_notices') - logger_notices.addHandler(handler) - logger_notices.setLevel(logging.DEBUG) + log_notices = logging.getLogger('pgmanager_notices') + log_notices.addHandler(handler) + log_notices.setLevel(logging.DEBUG) if self.args.debug: - logger_sql = logging.getLogger('pgmanager_sql') - logger_sql.addHandler(handler) - logger_sql.setLevel(logging.DEBUG) + log_sql = logging.getLogger('pgmanager_sql') + log_sql.addHandler(handler) + log_sql.setLevel(logging.DEBUG) def prepare_conn_from_metadb(self, name, lookup_name): '''Create connection in pgmanager using meta DB. @@ -80,12 +80,19 @@ dsn=dsn) return True - def prepare_conns_from_cmdline_args(self, *pgm_names): + def prepare_conns(self, **kwargs): + """Create connections in PgManager. + + Keyword arguments meaning: + key: connection name for use in PgManager + value: connection name in config or meta DB + + """ if self.config.meta_db: self.pgm.create_conn(name='meta', dsn=self.config.meta_db) - for name in pgm_names: - lookup_name = self.args.__dict__[name] + for name in kwargs: + lookup_name = kwargs[name] found = self.prepare_conn_from_config(name, lookup_name) if not found and self.config.meta_db: found = self.prepare_conn_from_metadb(name, lookup_name) @@ -103,7 +110,7 @@ def init(self): ToolBase.init(self) - self.prepare_conns_from_cmdline_args('target') + self.prepare_conns(target=self.args.target) class SrcDstTool(ToolBase): @@ -118,7 +125,7 @@ ToolBase.init(self) if self.is_reversed(): self.args.src, self.args.dst = self.args.dst, self.args.src - self.prepare_conns_from_cmdline_args('src', 'dst') + self.prepare_conns(src=self.args.src, dst=self.args.dst) def is_reversed(self): return 'reverse' in self.args and self.args.reverse