r104139 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r104138‎ | r104139 | r104140 >
Date:08:45, 24 November 2011
Author:ariel
Status:deferred
Tags:
Comment:
be able to run with cutoff of specific date; add link to all runs for a wiki; fix error returns so they print; more verbosity for verbose option
Modified paths:
  • /branches/ariel/xmldumps-backup/incrementals/incrmonitor.py (modified) (history)

Diff [purge]

Index: branches/ariel/xmldumps-backup/incrementals/incrmonitor.py
@@ -26,8 +26,9 @@
2727 makeLink = staticmethod(makeLink)
2828
2929 class Index(object):
30 - def __init__(self, config, verbose):
 30+ def __init__(self, config, date, verbose):
3131 self._config = config
 32+ self.date = date
3233 self.indexFile = IndexFile(self._config)
3334 self.incrDir = IncrementDir(self._config)
3435 self.verbose = verbose
@@ -37,6 +38,8 @@
3839 for w in self._config.allWikisList:
3940 result = self.doOneWiki(w)
4041 if result:
 42+ if (self.verbose):
 43+ print "result for wiki ", w, "is ", result
4144 text = text + "<li>"+ result + "</li>\n"
4245 indexText = self._config.readTemplate("incrs-index.html") % { "items" : text }
4346 FileUtils.writeFileInPlace(self.indexFile.getPath(), indexText, self._config.fileperms)
@@ -48,8 +51,10 @@
4952 if (self.verbose):
5053 print "No dump for wiki ", w
5154 next
52 -
53 - incrDate = self.incrDumpsDirs.getLatestIncrDate()
 55+ if date:
 56+ incrDate = date
 57+ else:
 58+ incrDate = self.incrDumpsDirs.getLatestIncrDate()
5459 if not incrDate:
5560 if (self.verbose):
5661 print "No dump for wiki ", w
@@ -69,7 +74,8 @@
7075 except:
7176 if (self.verbose):
7277 traceback.print_exc(file=sys.stdout)
73 - return "Error encountered, no information available for wiki", w
 78+ print "Error encountered, no information available for wiki", w
 79+ return "Error encountered, no information available for wiki" + w
7480
7581 try:
7682 wikinameText = "<strong>%s</strong>" % w
@@ -85,17 +91,19 @@
8692 revsText = "revs: %s (size %s)" % (Link.makeLink(os.path.join(w, incrDate, revs.getFileName()),revsDate), revsSize)
8793 else:
8894 revsText = None
 95+ otherRunsText = "other runs: %s" % Link.makeLink(w,w)
8996 if statContents:
9097 statText = "(%s)" % (statContents)
9198 else:
9299 statText = None
93100
94101 wikiInfo = " ".join( filter( None, [ wikinameText, lockText, statText ] ) ) + "<br />"
95 - wikiInfo = wikiInfo + " &nbsp;&nbsp; " + " | ".join( filter( None, [ stubText, revsText ] ))
 102+ wikiInfo = wikiInfo + " &nbsp;&nbsp; " + " | ".join( filter( None, [ stubText, revsText, otherRunsText ] ))
96103 except:
97104 if (self.verbose):
98105 traceback.print_exc(file=sys.stdout)
99 - return "Error encountered formatting information for wiki", w
 106+ print "Error encountered formatting information for wiki", w
 107+ return "Error encountered formatting information for wiki" + w
100108
101109 return wikiInfo
102110
@@ -103,25 +111,29 @@
104112 if message:
105113 print message
106114 print "Usage: python monitor.py [options] [wikidbname]"
107 - print "Options: --configfile, --verbose"
 115+ print "Options: --configfile, --date, --verbose"
108116 print "--configfile: Specify an alternate config file to read. Default file is 'dumpincr.conf' in the current directory."
 117+ print "--date: Look at runs starting on specified date or earler"
109118 print "--verbose: Print error messages and other informative messages (normally the"
110119 print " script runs silently)."
111120 sys.exit(1)
112121
113122 if __name__ == "__main__":
114123 configFile = False
 124+ date = False
115125 verbose = False
116126
117127 try:
118128 (options, remainder) = getopt.gnu_getopt(sys.argv[1:], "",
119 - ['configfile=', 'verbose' ])
 129+ ['configfile=', 'date=', 'verbose' ])
120130 except:
121131 usage("Unknown option specified")
122132
123133 for (opt, val) in options:
124134 if opt == "--configfile":
125135 configFile = val
 136+ elif opt == "--date":
 137+ date=val
126138 elif opt == '--verbose':
127139 verbose = True
128140
@@ -130,5 +142,5 @@
131143 else:
132144 config = Config()
133145
134 - index = Index(config, verbose)
 146+ index = Index(config, date, verbose)
135147 index.doAllWikis()

Status & tagging log