r86333 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86332‎ | r86333 | r86334 >
Date:18:45, 18 April 2011
Author:ariel
Status:deferred
Tags:
Comment:
add ability to insert notice on index.html page from specific wiki run from command line
Modified paths:
  • /branches/ariel/xmldumps-backup/report.html (modified) (history)
  • /branches/ariel/xmldumps-backup/worker.py (modified) (history)

Diff [purge]

Index: branches/ariel/xmldumps-backup/worker.py
@@ -698,7 +698,7 @@
699699 # everything that has to do with reporting the status of a piece
700700 # of a dump is collected here
701701 class Status(object):
702 - def __init__(self, wiki, dumpDir, date, items, checksums, errorCallback=None):
 702+ def __init__(self, wiki, dumpDir, date, items, checksums, notice="", errorCallback=None):
703703 self.wiki = wiki
704704 self.config = wiki.config
705705 self.dbName = wiki.dbName
@@ -707,6 +707,7 @@
708708 self.checksums = checksums
709709 self.date = date
710710 # this is just a glorified name for "give me a logging facility"
 711+ self.htmlNotice = notice
711712 self.errorCallback = errorCallback
712713 self.failCount = 0
713714
@@ -740,6 +741,7 @@
741742 else:
742743 return html
743744
 745+ # FIXME add capacity for special notice here.
744746 def reportDatabaseStatusDetailed(self, done=False):
745747 """Put together a status page for this database, with all its component dumps."""
746748 statusItems = [self.reportItem(item) for item in self.items]
@@ -748,6 +750,7 @@
749751 return self.config.readTemplate("report.html") % {
750752 "db": self.dbName,
751753 "date": self.date,
 754+ "notice": self.htmlNotice,
752755 "status": self.reportStatusSummaryLine(done),
753756 "previous": self.reportPreviousDump(done),
754757 "items": html,
@@ -842,7 +845,7 @@
843846
844847 class Runner(object):
845848
846 - def __init__(self, wiki, date=None, prefetch=True, spawn=True, job=None, restart=False, loggingEnabled=False):
 849+ def __init__(self, wiki, date=None, prefetch=True, spawn=True, job=None, restart=False, notice="", loggingEnabled=False):
847850 self.wiki = wiki
848851 self.config = wiki.config
849852 self.dbName = wiki.dbName
@@ -851,6 +854,7 @@
852855 self.chunkInfo = Chunk(wiki, self.dbName, self.logAndPrint)
853856 self.restart = restart
854857 self.loggingEnabled = loggingEnabled
 858+ self.htmlNotice = notice
855859 self.log = None
856860
857861 if date:
@@ -880,7 +884,7 @@
881885 # some or all of these dumpItems will be marked to run
882886 self.dumpItemList = DumpItemList(self.wiki, self.prefetch, self.spawn, self.date, self.chunkInfo);
883887
884 - self.status = Status(self.wiki, self.dumpDir, self.date, self.dumpItemList.dumpItems, self.checksums, self.logAndPrint)
 888+ self.status = Status(self.wiki, self.dumpDir, self.date, self.dumpItemList.dumpItems, self.checksums, self.htmlNotice, self.logAndPrint)
885889
886890 def logQueueReader(self,log):
887891 if not log:
@@ -2160,10 +2164,13 @@
21612165 if message:
21622166 print message
21632167 print "Usage: python worker.py [options] [wikidbname]"
2164 - print "Options: --configfile, --date, --job, --force, --noprefetch, --nospawn, --restartfrom, --log"
 2168+ print "Options: --configfile, --date, --job, --notice, --force, --noprefetch, --nospawn, --restartfrom, --log"
21652169 print "--configfile: Specify an alternative configuration file to read."
21662170 print " Default config file name: wikidump.conf"
21672171 print "--date: Rerun dump of a given date (probably unwise)"
 2172+ print "--notice: Text message that will be inserted in the per-dump-run index.html"
 2173+ print " file; use this when rerunning some job and you want to notify the"
 2174+ print " potential downloaders of problems, for example."
21682175 print "--job: Run just the specified step or set of steps; for the list,"
21692176 print " give the option --job help"
21702177 print " This option requires specifiying a wikidbname on which to run."
@@ -2192,10 +2199,11 @@
21932200 jobRequested = None
21942201 enableLogging = False
21952202 log = None
 2203+ htmlNotice = ""
21962204
21972205 try:
21982206 (options, remainder) = getopt.gnu_getopt(sys.argv[1:], "",
2199 - ['date=', 'job=', 'configfile=', 'force', 'noprefetch', 'nospawn', 'restartfrom', 'log'])
 2207+ ['date=', 'job=', 'configfile=', 'notice=', 'force', 'noprefetch', 'nospawn', 'restartfrom', 'log'])
22002208 except:
22012209 usage("Unknown option specified")
22022210
@@ -2216,6 +2224,8 @@
22172225 restart = True
22182226 elif opt == "--log":
22192227 enableLogging = True
 2228+ elif opt == "--notice":
 2229+ htmlNotice = val
22202230
22212231 if jobRequested and (len(remainder) == 0):
22222232 usage("--job option requires the name of a wikidb to be specified")
@@ -2242,7 +2252,7 @@
22432253 wiki = findAndLockNextWiki(config)
22442254
22452255 if wiki:
2246 - runner = Runner(wiki, date, prefetch, spawn, jobRequested, restart, enableLogging)
 2256+ runner = Runner(wiki, date, prefetch, spawn, jobRequested, restart, htmlNotice, enableLogging)
22472257 if (restart):
22482258 print "Running %s, restarting from job %s..." % (wiki.dbName, jobRequested)
22492259 elif (jobRequested):
Index: branches/ariel/xmldumps-backup/report.html
@@ -46,6 +46,10 @@
4747 color: Maroon;
4848 font-weight: bold;
4949 }
 50+ .notice {
 51+ color: Maroon;
 52+ font-weight: normal;
 53+ }
5054 .waiting {
5155 color: Silver; /* Gray ? */
5256 }
@@ -66,7 +70,9 @@
6771 See <a href="http://meta.wikimedia.org/wiki/Data_dumps">Meta:Data dumps</a>
6872 for documentation on the provided data formats.
6973 </p>
70 -
 74+
 75+ <p class="notice">%(notice)s</p>
 76+
7177 <p>See <a href="../../%(index)s">all databases list</a>.</p>
7278
7379 <p class="previous">

Status & tagging log