3737
3838def main ():
3939 parser = argparse .ArgumentParser (
40- description = DESCRIPTION ,
40+ description = DESCRIPTION ,
4141 formatter_class = argparse .RawTextHelpFormatter )#ArgumentDefaultsHelpFormatter)
4242
4343 parser .add_argument (
4444 help = """The PATH to search for tor log files, which may be '-'
4545for STDIN; each log file may end in '.xz' to enable
46- inline xz decompression""" ,
46+ inline xz decompression""" ,
4747 metavar = "PATH" ,
4848 action = "store" , dest = "searchpath" )
4949
5050 parser .add_argument ('-e' , '--expression' ,
5151 help = """Append a regex PATTERN to the list of strings used with
52- re.search to find tgen log file names in the search path""" ,
52+ re.search to find tgen log file names in the search path""" ,
5353 action = "append" , dest = "patterns" ,
5454 metavar = "PATTERN" ,
5555 default = ["torctl.*\.log" ])
@@ -61,9 +61,9 @@ def main():
6161 action = "store" , dest = "nprocesses" , type = type_nonnegative_integer ,
6262 default = 1 )
6363
64- parser .add_argument ('-p' , '--prefix' ,
64+ parser .add_argument ('-p' , '--prefix' ,
6565 help = """A STRING directory path prefix where the processed data
66- files generated by this script will be written""" ,
66+ files generated by this script will be written""" ,
6767 metavar = "STRING" ,
6868 action = "store" , dest = "prefix" ,
6969 default = os .getcwd ())
@@ -124,6 +124,7 @@ def process_tor_log(filename):
124124 name = None
125125 total_read , total_write = 0 , 0
126126 boot_succeeded = False
127+ first_second = None
127128
128129 for line in source :
129130 try :
@@ -141,6 +142,10 @@ def process_tor_log(filename):
141142 bwr = int (parts [9 ])
142143 bww = int (parts [10 ])
143144
145+ if first_second is None :
146+ first_second = second
147+ second -= first_second
148+
144149 if second not in d ['bytes_read' ]: d ['bytes_read' ][second ] = 0
145150 d ['bytes_read' ][second ] += bwr
146151 total_read += bwr
@@ -204,4 +209,3 @@ def dump(data, prefix, filename, compress=True):
204209 with open (path , 'w' ) as outf : json .dump (data , outf , sort_keys = True , separators = (',' , ': ' ), indent = 2 )
205210
206211if __name__ == '__main__' : sys .exit (main ())
207-
0 commit comments