r101625 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101624‎ | r101625 | r101626 >
Date:14:29, 2 November 2011
Author:ariel
Status:deferred
Tags:
Comment:
add forcerun option which will do a run even if a completed run exists for the given date; fix status check (which in turn fixes retrieving max revid of previous good run)
Modified paths:
  • /branches/ariel/xmldumps-backup/incrementals/IncrDumpLib.py (modified) (history)
  • /branches/ariel/xmldumps-backup/incrementals/generateincrementals.py (modified) (history)

Diff [purge]

Index: branches/ariel/xmldumps-backup/incrementals/IncrDumpLib.py
@@ -85,11 +85,10 @@
8686 self.statusFile = StatusFile(self._config, self.date, self.wikiName)
8787
8888 def getStatus(self, date = None):
 89+ status = ""
8990 if exists(self.statusFile.getPath(date)):
9091 status = FileUtils.readFile(self.statusFile.getPath(date)).rstrip()
91 - if status == "done":
92 - return True
93 - return False
 92+ return(status)
9493
9594 def setStatus(self, status):
9695 FileUtils.writeFileInPlace(self.statusFile.getPath(),status, self._config.fileperms)
Index: branches/ariel/xmldumps-backup/incrementals/generateincrementals.py
@@ -27,7 +27,7 @@
2828 self.OK = 0
2929
3030 class IncrDump(object):
31 - def __init__(self,config, date, wikiName, doStubs, doRevs, dryrun, verbose):
 31+ def __init__(self,config, date, wikiName, doStubs, doRevs, dryrun, verbose, forcerun):
3232 self._config = config
3333 self.date = date
3434 self.wikiName = wikiName
@@ -35,6 +35,7 @@
3636 self.doStubs = doStubs
3737 self.doRevs = doRevs
3838 self.dryrun = dryrun
 39+ self.forcerun = forcerun
3940 self.maxRevIDFile = MaxRevIDFile(self._config, self.date, self.wikiName)
4041 self.statusInfo = StatusInfo(self._config, self.date, self.wikiName)
4142 self.stubFile = StubFile(self._config, self.date, self.wikiName)
@@ -54,7 +55,7 @@
5556 if not exists(self.incrDir.getIncDir(self.wikiName)):
5657 os.makedirs(self.incrDir.getIncDir(self.wikiName))
5758 status = self.statusInfo.getStatus()
58 - if status == "done":
 59+ if status == "done" and not forcerun:
5960 if (self.verbose):
6061 print "wiki",self.wikiName,"skipped, adds/changes dump already complete"
6162 return retCodes.OK
@@ -170,20 +171,21 @@
171172 return False
172173
173174 class IncrDumpLoop(object):
174 - def __init__(self, config, date, doStubs, doRevs, dryrun, verbose):
 175+ def __init__(self, config, date, doStubs, doRevs, dryrun, verbose, forcerun):
175176 self._config = config
176177 self.date = date
177178 self.doStubs = doStubs
178179 self.doRevs = doRevs
179180 self.dryrun = dryrun
180181 self.verbose = verbose
 182+ self.forcerun = forcerun
181183
182184 def doRunOnAllWikis(self):
183185 retCodes = DumpResults()
184186 failures = 0
185187 todos = 0
186188 for w in self._config.allWikisList:
187 - dump = IncrDump(config, date, w, doStubs, doRevs, dryrun, self.verbose)
 189+ dump = IncrDump(self._config, self.date, w, self.doStubs, self.doRevs, self.dryrun, self.verbose, self.forcerun)
188190 result = dump.doOneWiki()
189191 if result == retCodes.FAILED:
190192 failures = failures + 1
@@ -212,6 +214,7 @@
213215 print "--configfile: Specify an alternate config file to read. Default file is 'dumpincr.conf' in the current directory."
214216 print "--date: (Re)run incremental of a given date (use with care)."
215217 print "--dryrun: Don't actually dump anything but print the commands that would be run."
 218+ print "--forcerun: Do the run even if there is already a successful run in place."
216219 print "--revsonly: Do only the stubs part of the dumps."
217220 print "--stubsonly: Do only the revision text part of the dumps."
218221 print "--verbose: Print error messages and other informative messages (normally the"
@@ -227,10 +230,11 @@
228231 doRevs = True
229232 dryrun = False
230233 verbose = False
 234+ forcerun = False
231235
232236 try:
233237 (options, remainder) = getopt.gnu_getopt(sys.argv[1:], "",
234 - ['date=', 'configfile=', 'stubsonly', 'revsonly', 'dryrun', 'verbose' ])
 238+ ['date=', 'configfile=', 'stubsonly', 'revsonly', 'dryrun', 'verbose', 'forcerun' ])
235239 except:
236240 usage("Unknown option specified")
237241
@@ -247,6 +251,8 @@
248252 dryrun = True
249253 elif opt == "--verbose":
250254 verbose = True
 255+ elif opt == "--forcerun":
 256+ forcerun = True
251257
252258 if not doRevs and not doStubs:
253259 usage("You may not specify stubsonly and revsonly options together.")
@@ -263,5 +269,5 @@
264270 dump = IncrDump(config, date, remainder[0], doStubs, doRevs, dryrun, verbose)
265271 dump.doOneWiki()
266272 else:
267 - dump = IncrDumpLoop(config, date, doStubs, doRevs, dryrun, verbose)
 273+ dump = IncrDumpLoop(config, date, doStubs, doRevs, dryrun, verbose, forcerun)
268274 dump.doAllWikisTilDone(3)

Status & tagging log