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

Delta Between Two Patch Sets: sitescripts/stats/bin/logprocessor.py

Issue 6231865702744064: Issue 2239 - Make logprocessor close files and wait for subprocesses (Closed)
Left Patch Set: Created March 31, 2015, 10:06 a.m.
Right Patch Set: Removed usage of non-existing attribute Created April 1, 2015, 10:29 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2015 Eyeo GmbH 4 # Copyright (C) 2006-2015 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 command[1:1] = ["-P", str(parseresult.port)] 59 command[1:1] = ["-P", str(parseresult.port)]
60 ssh_process = subprocess.Popen(command, stdout=subprocess.PIPE) 60 ssh_process = subprocess.Popen(command, stdout=subprocess.PIPE)
61 self._processes.push(ssh_process) 61 self._processes.push(ssh_process)
62 self._file = ssh_process.stdout 62 self._file = ssh_process.stdout
63 elif parseresult.scheme in ("http", "https"): 63 elif parseresult.scheme in ("http", "https"):
64 self._file = urllib.urlopen(path) 64 self._file = urllib.urlopen(path)
65 elif os.path.exists(path): 65 elif os.path.exists(path):
66 self._file = open(path, "rb") 66 self._file = open(path, "rb")
67 else: 67 else:
68 raise IOError("Path '%s' not recognized" % path) 68 raise IOError("Path '%s' not recognized" % path)
69
70 self._files.append(result)
71 69
72 if path.endswith(".gz"): 70 if path.endswith(".gz"):
73 # Built-in gzip module doesn't support streaming (fixed in Python 3.2) 71 # Built-in gzip module doesn't support streaming (fixed in Python 3.2)
74 gzip_process = subprocess.Popen(["gzip", "-cd"], stdin=self._file, stdout= subprocess.PIPE) 72 gzip_process = subprocess.Popen(["gzip", "-cd"], stdin=self._file, stdout= subprocess.PIPE)
75 self._processes.append(gzip_process) 73 self._processes.append(gzip_process)
76 self._file, self._inner_file = gzip_process.stdout, self._file 74 self._file, self._inner_file = gzip_process.stdout, self._file
77 75
78 def __getattr__(self, name): 76 def __getattr__(self, name):
79 return getattr(self._file, name) 77 return getattr(self._file, name)
80 78
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 parser.add_argument("mirror_name", nargs="?", help="Name of the mirror server that the file belongs to") 564 parser.add_argument("mirror_name", nargs="?", help="Name of the mirror server that the file belongs to")
567 parser.add_argument("server_type", nargs="?", help="Server type like download, update or subscription") 565 parser.add_argument("server_type", nargs="?", help="Server type like download, update or subscription")
568 parser.add_argument("log_file", nargs="?", help="Log file path, can be a local file path, http:// or ssh:// URL") 566 parser.add_argument("log_file", nargs="?", help="Log file path, can be a local file path, http:// or ssh:// URL")
569 args = parser.parse_args() 567 args = parser.parse_args()
570 568
571 if args.mirror_name and args.server_type and args.log_file: 569 if args.mirror_name and args.server_type and args.log_file:
572 sources = [(args.mirror_name, args.server_type, args.log_file)] 570 sources = [(args.mirror_name, args.server_type, args.log_file)]
573 else: 571 else:
574 sources = get_stats_files() 572 sources = get_stats_files()
575 parse_sources(sources, args.factor, args.verbose) 573 parse_sources(sources, args.factor, args.verbose)
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld