Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: sitescripts/stats/bin/logprocessor.py

Issue 29350318: Issue 4382 - Use new syntax to catch exceptions in sitescripts (Closed)
Patch Set: Created Aug. 30, 2016, 1:28 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 # This file is part of the Adblock Plus web scripts, 1 # This file is part of the Adblock Plus web scripts,
2 # Copyright (C) 2006-2016 Eyeo GmbH 2 # Copyright (C) 2006-2016 Eyeo GmbH
3 # 3 #
4 # Adblock Plus is free software: you can redistribute it and/or modify 4 # Adblock Plus is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 3 as 5 # it under the terms of the GNU General Public License version 3 as
6 # published by the Free Software Foundation. 6 # published by the Free Software Foundation.
7 # 7 #
8 # Adblock Plus is distributed in the hope that it will be useful, 8 # Adblock Plus is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 with codecs.open(path, 'rb', encoding='utf-8') as fileobj: 532 with codecs.open(path, 'rb', encoding='utf-8') as fileobj:
533 existing = json.load(fileobj) 533 existing = json.load(fileobj)
534 else: 534 else:
535 existing = {} 535 existing = {}
536 536
537 merge_objects(existing, file_data, factor) 537 merge_objects(existing, file_data, factor)
538 538
539 dir = os.path.dirname(path) 539 dir = os.path.dirname(path)
540 try: 540 try:
541 os.makedirs(dir) 541 os.makedirs(dir)
542 except OSError, e: 542 except OSError as e:
543 if e.errno != errno.EEXIST: 543 if e.errno != errno.EEXIST:
544 raise 544 raise
545 545
546 with codecs.open(path, 'wb', encoding='utf-8') as fileobj: 546 with codecs.open(path, 'wb', encoding='utf-8') as fileobj:
547 json.dump(existing, fileobj, indent=2, sort_keys=True) 547 json.dump(existing, fileobj, indent=2, sort_keys=True)
548 548
549 549
550 def parse_source(factor, lock, (mirror_name, server_type, log_file)): 550 def parse_source(factor, lock, (mirror_name, server_type, log_file)):
551 try: 551 try:
552 geo = pygeoip.GeoIP(get_config().get('stats', 'geoip_db'), pygeoip.MEMOR Y_CACHE) 552 geo = pygeoip.GeoIP(get_config().get('stats', 'geoip_db'), pygeoip.MEMOR Y_CACHE)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 parser.add_argument('mirror_name', nargs='?', help='Name of the mirror serve r that the file belongs to') 593 parser.add_argument('mirror_name', nargs='?', help='Name of the mirror serve r that the file belongs to')
594 parser.add_argument('server_type', nargs='?', help='Server type like downloa d, update or subscription') 594 parser.add_argument('server_type', nargs='?', help='Server type like downloa d, update or subscription')
595 parser.add_argument('log_file', nargs='?', help='Log file path, can be a loc al file path, http:// or ssh:// URL') 595 parser.add_argument('log_file', nargs='?', help='Log file path, can be a loc al file path, http:// or ssh:// URL')
596 args = parser.parse_args() 596 args = parser.parse_args()
597 597
598 if args.mirror_name and args.server_type and args.log_file: 598 if args.mirror_name and args.server_type and args.log_file:
599 sources = [(args.mirror_name, args.server_type, args.log_file)] 599 sources = [(args.mirror_name, args.server_type, args.log_file)]
600 else: 600 else:
601 sources = get_stats_files() 601 sources = get_stats_files()
602 parse_sources(sources, args.factor, args.verbose) 602 parse_sources(sources, args.factor, args.verbose)
OLDNEW
« no previous file with comments | « sitescripts/reports/web/submitReport.py ('k') | sitescripts/subscriptions/bin/updateStatusPage.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld