Replace -c argument by config file. Now clean output is -C
This commit is contained in:
parent
b1f1158589
commit
37a33f1291
21
iwla.py
21
iwla.py
|
@ -34,7 +34,6 @@ from calendar import monthrange
|
|||
from datetime import date, datetime
|
||||
|
||||
import default_conf as conf
|
||||
import conf as user_conf
|
||||
|
||||
from iplugin import *
|
||||
from display import *
|
||||
|
@ -659,8 +658,9 @@ class IWLA(object):
|
|||
self.meta_infos['stats'][year] = {}
|
||||
self.meta_infos['stats'][year][month] = duplicated_stats
|
||||
|
||||
self.logger.info("==> Serialize to %s" % (conf.META_PATH))
|
||||
self._serialize(self.meta_infos, conf.META_PATH)
|
||||
meta_path = os.path.join(conf.DB_ROOT, conf.META_FILENAME)
|
||||
self.logger.info("==> Serialize to %s" % (meta_path))
|
||||
self._serialize(self.meta_infos, meta_path)
|
||||
|
||||
self._generateDisplay()
|
||||
|
||||
|
@ -767,9 +767,11 @@ class IWLA(object):
|
|||
self.args = args
|
||||
self.start_time = datetime.now()
|
||||
|
||||
meta_path = os.path.join(conf.DB_ROOT, conf.META_FILENAME)
|
||||
if os.path.exists(meta_path):
|
||||
self.logger.info('==> Load previous database')
|
||||
|
||||
self.meta_infos = self._deserialize(conf.META_PATH) or self._clearMeta()
|
||||
self.meta_infos = self._deserialize(meta_path) or self._clearMeta()
|
||||
if self.meta_infos['last_time']:
|
||||
if args.reset:
|
||||
self._reset()
|
||||
|
@ -842,7 +844,11 @@ class FileIter(object):
|
|||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='Intelligent Web Log Analyzer')
|
||||
|
||||
parser.add_argument('-c', '--clean-output', dest='clean_output', action='store_true',
|
||||
parser.add_argument('-c', '--config-file', dest='config_file',
|
||||
default='conf.py', type=str,
|
||||
help='Config file to use (default conf.py)')
|
||||
|
||||
parser.add_argument('-C', '--clean-output', dest='clean_output', action='store_true',
|
||||
default=False,
|
||||
help='Clean output before starting')
|
||||
|
||||
|
@ -875,6 +881,11 @@ if __name__ == '__main__':
|
|||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.config_file.endswith('.py'):
|
||||
args.config_file = args.config_file[:-3]
|
||||
|
||||
user_conf = importlib.import_module(args.config_file)
|
||||
|
||||
# Load user conf
|
||||
for (k,v) in user_conf.__dict__.items():
|
||||
if k.endswith('_append'):
|
||||
|
|
Loading…
Reference in New Issue
Block a user