Changeset 2137
- Timestamp:
- 07/04/2008 09:02:45 (4 years ago)
- Location:
- box/trunk/contrib/bbreporter
- Files:
-
- 1 added
- 1 edited
-
LICENSE (added)
-
bbreporter.py (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/contrib/bbreporter/bbreporter.py
r2136 r2137 5 5 # Copyright: (C) 2007 Three A IT Limited 6 6 # Author: Kenny Millington <kenny.millington@3ait.co.uk> 7 # Version: $Id: bbreporter.py,v 1.15 2007-11-14 11:13:38 kenny Exp $8 7 # 9 8 # Credit: This script is based on the ideas of BoxReport.pl by Matt Brown of … … 84 83 log_file="/var/log/syslog", email_to=None, 85 84 email_from="report@boxbackup", rotate=False, 86 verbose=False, stats=False ):85 verbose=False, stats=False, sort=False): 87 86 88 87 # Config options … … 94 93 self.verbose_report = verbose 95 94 self.usage_stats = stats 95 self.sort_files = sort 96 96 97 97 # Regex's … … 107 107 # Reset report data to default values 108 108 self.hostname = "" 109 self.patched_files = {}110 self.synced_files = {}111 self.uploaded_files = {}109 self.patched_files = [] 110 self.synced_files = [] 111 self.uploaded_files = [] 112 112 self.warnings = [] 113 113 self.errors = [] … … 198 198 def _parse_syslog(self): 199 199 lfh = open(self.log_file) 200 201 patched_files = {} 202 uploaded_files = {} 203 synced_files = {} 200 204 201 205 for line in lfh: … … 234 238 # We found a patch event, add the file to the patched_files. 235 239 if data[5] == "Uploading patch to file": 236 self.patched_files[data[6]] = ""240 patched_files[data[6]] = "" 237 241 238 242 # We found an upload event, add to uploaded files. 239 243 elif data[5] == "Uploading complete file": 240 self.uploaded_files[data[6]] = ""244 uploaded_files[data[6]] = "" 241 245 242 246 # We found another upload event. 243 247 elif data[5] == "Uploaded file": 244 self.uploaded_files[data[6]] = ""248 uploaded_files[data[6]] = "" 245 249 246 250 # We found a sync event, add the file to the synced_files. 247 251 elif data[5] == "Synchronised file": 248 s elf.synced_files[data[6]] = ""252 synced_files[data[6]] = "" 249 253 250 254 # We found a warning, add the warning to the warnings. … … 255 259 elif data[5] == "ERROR": 256 260 self.errors.append(data[6]) 257 261 262 263 self.patched_files = patched_files.keys() 264 self.uploaded_files = uploaded_files.keys() 265 self.synced_files = synced_files.keys() 266 267 # There's no point running the sort functions if we're not going 268 # to display the resultant lists. 269 if self.sort_files and self.verbose_report: 270 self.patched_files.sort() 271 self.uploaded_files.sort() 272 273 258 274 lfh.close() 259 275 … … 317 333 report.append("Uploaded Files (%d)" % len(self.uploaded_files)) 318 334 report.append("---------------------") 319 for file in self.uploaded_files .keys():335 for file in self.uploaded_files: 320 336 report.append(file) 321 337 report.append("") … … 325 341 report.append("Patched Files (%d)" % len(self.patched_files)) 326 342 report.append("---------------------") 327 for file in self.patched_files .keys():343 for file in self.patched_files: 328 344 report.append(file) 329 345 report.append("") … … 447 463 verbose = False 448 464 stats = False 465 sort = False 449 466 450 467 # Parse the options 451 468 try: 452 opts, args = getopt.getopt(sys.argv[1:], " srvhl:c:t:f:",469 opts, args = getopt.getopt(sys.argv[1:], "osrvhl:c:t:f:", 453 470 ["help", "logfile=", "configfile=","email-to=", 454 "email-from=","rotate","verbose","stats" ])471 "email-from=","rotate","verbose","stats","sort"]) 455 472 except getopt.GetoptError: 456 473 usage() … … 472 489 elif(opt in ("--stats", "-s")): 473 490 stats = True 491 elif(opt in ("--sort", "-o")): 492 sort = True 474 493 elif(opt in ("--help", "-h")): 475 494 usage() … … 478 497 # Run the reporter 479 498 bbr = BoxBackupReporter(configfile, logfile, email_to, email_from, 480 rotate, verbose, stats )499 rotate, verbose, stats, sort) 481 500 try: 482 501 bbr.run()
Note: See TracChangeset
for help on using the changeset viewer.
