Changeset 2138
- Timestamp:
- 09/04/2008 09:00:53 (4 years ago)
- File:
-
- 1 edited
-
box/trunk/contrib/bbreporter/bbreporter.py (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/contrib/bbreporter/bbreporter.py
r2137 r2138 83 83 log_file="/var/log/syslog", email_to=None, 84 84 email_from="report@boxbackup", rotate=False, 85 verbose=False, stats=False, sort=False ):85 verbose=False, stats=False, sort=False, debug=False): 86 86 87 87 # Config options … … 94 94 self.usage_stats = stats 95 95 self.sort_files = sort 96 96 self.debug = debug 97 97 98 # Regex's 98 99 self.re_automatic_backup = re.compile(" *AutomaticBackup *= *no", re.I) … … 103 104 self.reset() 104 105 105 106 def _debug(self, msg): 107 if self.debug: 108 sys.stderr.write("[bbreporter.py Debug]: %s\n" % msg) 109 106 110 def reset(self): 107 111 # Reset report data to default values … … 120 124 try: 121 125 self._determine_operating_mode() 126 127 if self.lazy_mode: 128 self._debug("Operating in LAZY MODE.") 129 else: 130 self._debug("Operating in SNAPSHOT MODE.") 131 122 132 except IOError: 123 133 raise BoxBackupReporter.BoxBackupReporterError("Error: "+\ … … 227 237 # so we only capture the most recent session. 228 238 if not self.lazy_mode or self.start_datetime == "Unknown": 239 self._debug("Reset start dtime with old time: %s." % 240 self.start_datetime) 241 242 # Reset ourselves 229 243 self.reset() 244 245 # Reset our temporary variables which we store 246 # the files in. 247 patched_files = {} 248 uploaded_files = {} 249 synced_files = {} 250 230 251 self.start_datetime = data[1]+" "+data[0]+ " "+data[2] 252 self._debug("Reset start dtime with new time %s." % 253 self.start_datetime) 231 254 232 255 # If we find the backup-finish event then set the end_datetime. 233 256 elif data[6].find("backup-finish") > -1: 234 257 self.end_datetime = data[1] + " " + data[0] + " " + data[2] 258 self._debug("Set end dtime: %s" % self.end_datetime) 235 259 236 260 # Only log the events if we have our start time. … … 447 471 "\t\t\t\t\t'bbackupquery usage' in the report.\n") 448 472 473 stderr(" --sort\t\t\t\tSorts the file lists in verbose mode.\n") 474 475 stderr(" --debug\t\t\t\tEnables debug output.\n") 476 449 477 stderr(" --verbose\t\t\t\tList every file that was backed up to\n"+\ 450 478 "\t\t\t\t\tthe server, default is to just display\n"+\ … … 464 492 stats = False 465 493 sort = False 466 494 debug = False 467 495 # Parse the options 468 496 try: 469 opts, args = getopt.getopt(sys.argv[1:], " osrvhl:c:t:f:",497 opts, args = getopt.getopt(sys.argv[1:], "dosrvhl:c:t:f:", 470 498 ["help", "logfile=", "configfile=","email-to=", 471 "email-from=","rotate","verbose","stats","sort"]) 499 "email-from=","rotate","verbose","stats","sort", 500 "debug"]) 472 501 except getopt.GetoptError: 473 502 usage() … … 491 520 elif(opt in ("--sort", "-o")): 492 521 sort = True 522 elif(opt in ("--debug", "-d")): 523 debug = True 493 524 elif(opt in ("--help", "-h")): 494 525 usage() … … 497 528 # Run the reporter 498 529 bbr = BoxBackupReporter(configfile, logfile, email_to, email_from, 499 rotate, verbose, stats, sort )530 rotate, verbose, stats, sort, debug) 500 531 try: 501 532 bbr.run()
Note: See TracChangeset
for help on using the changeset viewer.
