iwla

iwla Commit Details

Date:2017-05-25 21:03:46 (4 years 1 month ago)
Author:Grégory Soutadé
Branch:dev, master
Commit:4bc2c1ad4ba1f1f2cf560722ec247e4ee51e5233
Parents: d08085faf0cb566190e52362ba28a9f81c6925a9
Message:Add --dry-run (-D) argument

Changes:
Mdisplay.py (2 diffs)
Miwla.py (9 diffs)

File differences

display.py
351351
352352
353353
354
355
354356
355357
356358
......
398400
399401
400402
401
402
403
404
405
406
407
408
403
404
405
406
407
408
409
410
411
409412
410413
411414
self.logger.debug('Write %s' % (filename))
if self.iwla.dry_run: return
f = codecs.open(filename, 'w', 'utf-8')
f.write(u'<!DOCTYPE html>')
f.write(u'<html>')
self.pages.append(page)
def build(self, root):
display_root = self.iwla.getConfValue('DISPLAY_ROOT', '')
if not os.path.exists(display_root):
os.makedirs(display_root)
for res_path in self.iwla.getResourcesPath():
target = os.path.abspath(res_path)
link_name = os.path.join(display_root, res_path)
if not os.path.exists(link_name):
os.symlink(target, link_name)
if not self.iwla.dry_run:
display_root = self.iwla.getConfValue('DISPLAY_ROOT', '')
if not os.path.exists(display_root):
os.makedirs(display_root)
for res_path in self.iwla.getResourcesPath():
target = os.path.abspath(res_path)
link_name = os.path.join(display_root, res_path)
if not os.path.exists(link_name):
os.symlink(target, link_name)
for page in self.pages:
page.build(root, filters=self.filters)
iwla.py
133133
134134
135135
136
136
137137
138138
139139
......
141141
142142
143143
144
144145
145146
146147
......
155156
156157
157158
158
159
160
161
162
159163
160164
161165
......
243247
244248
245249
250
246251
247252
248253
......
556561
557562
558563
564
559565
560566
561567
......
622628
623629
624630
625
631
626632
627633
628634
......
853859
854860
855861
862
863
864
865
856866
857867
858868
......
872882
873883
874884
875
885
876886
877887
878888
......
880890
881891
882892
883
893
884894
885895
886896
API_VERSION = 1
IWLA_VERSION = '0.5-dev'
def __init__(self, logLevel):
def __init__(self, logLevel, dry_run):
self.meta_infos = {}
self.analyse_started = False
self.current_analysis = {}
self.cache_plugins = {}
self.display = DisplayHTMLBuild(self)
self.valid_visitors = None
self.dry_run = dry_run
self.log_format_extracted = re.sub(r'([^\$\w])', r'\\\g<1>', conf.log_format)
self.log_format_extracted = re.sub(r'\$(\w+)', '(?P<\g<1>>.+)', self.log_format_extracted)
logging.basicConfig(format='%(name)s %(message)s', level=logLevel)
self.logger = logging.getLogger(self.__class__.__name__)
self.logger.info('==> Start')
if self.dry_run:
self.logger.info('==> Start (DRY RUN)')
else:
self.logger.info('==> Start')
try:
t = gettext.translation('iwla', localedir=conf.locales_path, languages=[conf.locale], codeset='utf8')
self.logger.info('\tUsing locale %s' % (conf.locale))
return gzip.open(filename, prot)
def _serialize(self, obj, filename):
if self.dry_run: return
base = os.path.dirname(filename)
if not os.path.exists(base):
os.makedirs(base)
if not os.path.exists(gz_path) or\
os.stat(path).st_mtime >= build_time:
if self.dry_run: return
with open(path, 'rb') as f_in, gzip.open(gz_path, 'wb') as f_out:
f_out.write(f_in.read())
self._callPlugins(conf.POST_HOOK_DIRECTORY)
path = self.getDBFilename(cur_time)
if os.path.exists(path):
if os.path.exists(path) and not self.dry_run:
os.remove(path)
self.logger.info("==> Serialize to %s" % (path))
default=False,
help='Only generate display')
parser.add_argument('-D', '--dry-run', dest='dry_run', action='store_true',
default=False,
help='Process log but don\'t write files (database and HTML) to disk')
args = parser.parse_args()
# Load user conf
else:
conf.__dict__.update({k:v})
if args.clean_output:
if args.clean_output and not args.dry_run:
if os.path.exists(conf.DB_ROOT): shutil.rmtree(conf.DB_ROOT)
if os.path.exists(conf.DISPLAY_ROOT): shutil.rmtree(conf.DISPLAY_ROOT)
if not isinstance(loglevel, int):
raise ValueError('Invalid log level: %s' % (args.loglevel))
iwla = IWLA(loglevel)
iwla = IWLA(loglevel, args.dry_run)
required_conf = ['analyzed_filename', 'domain_name']
if not validConfRequirements(required_conf, iwla, 'Main Conf'):

Archive Download the corresponding diff file

Branches

Tags