r99203 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99202‎ | r99203 | r99204 >
Date:09:36, 7 October 2011
Author:ariel
Status:deferred
Tags:
Comment:
last het deploy fix (for active abstract filter); remove some comment cruft; clean up old symlinks in latest only for the given job; don't barf with exception if we are asked to get files from dump dir that hasn't been created
Modified paths:
  • /branches/ariel/xmldumps-backup/worker.py (modified) (history)

Diff [purge]

Index: branches/ariel/xmldumps-backup/worker.py
@@ -179,14 +179,26 @@
180180 return(" ".join(MultiVersion.MWScriptAsArray(config, maintenanceScript)))
181181
182182 def MWScriptAsArray(config, maintenanceScript):
183 - MWScriptLocation = os.path.join(config.wikiDir,"..","multiversion","MWScript.php")
 183+ MWScriptLocation = os.path.join(config.wikiDir,"multiversion","MWScript.php")
184184 if exists(MWScriptLocation):
185185 return [ MWScriptLocation, maintenanceScript ]
186186 else:
187187 return [ "%s/maintenance/%s" % (config.wikiDir, maintenanceScript) ]
188188
 189+ def MWVersion(config, dbName):
 190+ getVersionLocation = os.path.join(config.wikiDir,"multiversion","getMWVersion")
 191+ if exists(getVersionLocation):
 192+ # run the command for the wiki and get the version
 193+ command = getVersionLocation + " " + dbName
 194+ version = RunSimpleCommand.runAndReturn(command)
 195+ if version:
 196+ version = version.rstrip()
 197+ return version
 198+ return None
 199+
189200 MWScriptAsString = staticmethod(MWScriptAsString)
190201 MWScriptAsArray = staticmethod(MWScriptAsArray)
 202+ MWVersion = staticmethod(MWVersion)
191203
192204 class DbServerInfo(object):
193205 def __init__(self, wiki, dbName, errorCallback = None):
@@ -200,7 +212,6 @@
201213 if (not exists( self.wiki.config.php ) ):
202214 raise BackupError("php command %s not found" % self.wiki.config.php)
203215 commandList = MultiVersion.MWScriptAsArray(self.wiki.config, "getSlaveServer.php")
204 -# command = "%s -q %s/maintenance/getSlaveServer.php --wiki=%s --group=dump" % MiscUtils.shellEscape((
205216 for i in range(0,len(commandList)):
206217 phpCommand = MiscUtils.shellEscape(self.wiki.config.php)
207218 dbName = MiscUtils.shellEscape(self.dbName)
@@ -267,7 +278,6 @@
268279 if (not exists( self.wiki.config.php ) ):
269280 raise BackupError("php command %s not found" % self.wiki.config.php)
270281 commandList = MultiVersion.MWScriptAsArray(self.wiki.config, "eval.php")
271 -# command = "echo 'print $wgDBprefix; ' | %s -q %s/maintenance/eval.php --wiki=%s" % MiscUtils.shellEscape((
272282 for i in range(0,len(commandList)):
273283 phpCommand = MiscUtils.shellEscape(self.wiki.config.php)
274284 dbName = MiscUtils.shellEscape(self.dbName)
@@ -891,11 +901,14 @@
892902 if not date:
893903 date = self._wiki.date
894904 directory = os.path.join(self._wiki.publicDir(), date)
895 - dirTimeStamp = os.stat(directory).st_mtime
896 - if (not date in self._dirCache or dirTimeStamp > self._dirCacheTime[date]):
 905+ if exists(directory):
 906+ dirTimeStamp = os.stat(directory).st_mtime
 907+ if (not date in self._dirCache or dirTimeStamp > self._dirCacheTime[date]):
 908+ return True
 909+ else:
 910+ return False
 911+ else:
897912 return True
898 - else:
899 - return False
900913
901914 # warning: date can also be "latest"
902915 def getFilesInDir(self, date = None):
@@ -903,15 +916,18 @@
904917 date = self._wiki.date
905918 if (self.dirCacheOutdated(date)):
906919 directory = os.path.join(self._wiki.publicDir(),date)
907 - dirTimeStamp = os.stat(directory).st_mtime
908 - files = os.listdir(directory)
909 - fileObjs = []
910 - for f in files:
911 - fileObj = DumpFilename(self._wiki)
912 - fileObj.newFromFilename(f)
913 - fileObjs.append(fileObj)
914 - self._dirCache[date] = fileObjs
915 - self._dirCacheTime[date] = dirTimeStamp
 920+ if exists(directory):
 921+ dirTimeStamp = os.stat(directory).st_mtime
 922+ files = os.listdir(directory)
 923+ fileObjs = []
 924+ for f in files:
 925+ fileObj = DumpFilename(self._wiki)
 926+ fileObj.newFromFilename(f)
 927+ fileObjs.append(fileObj)
 928+ self._dirCache[date] = fileObjs
 929+ self._dirCacheTime[date] = dirTimeStamp
 930+ else:
 931+ self._dirCache[date] = []
916932 return(self._dirCache[date])
917933
918934 # list all files that exist, filtering by the given args.
@@ -1874,32 +1890,33 @@
18751891 self.symLinks.cleanupSymLinks()
18761892
18771893 for item in self.dumpItemList.dumpItems:
1878 - dumpNames = item.getDumpName()
1879 - if type(dumpNames).__name__!='list':
1880 - dumpNames = [ dumpNames ]
 1894+ if (item.toBeRun()):
 1895+ dumpNames = item.getDumpName()
 1896+ if type(dumpNames).__name__!='list':
 1897+ dumpNames = [ dumpNames ]
18811898
1882 - if (item._chunksEnabled):
1883 - # if there is a specific chunk, we want to only clear out
1884 - # old files for that piece, because new files for the other
1885 - # pieces may not have been generated yet.
1886 - chunk = item._chunkToDo
1887 - else:
1888 - chunk = None
 1899+ if (item._chunksEnabled):
 1900+ # if there is a specific chunk, we want to only clear out
 1901+ # old files for that piece, because new files for the other
 1902+ # pieces may not have been generated yet.
 1903+ chunk = item._chunkToDo
 1904+ else:
 1905+ chunk = None
18891906
1890 - checkpoint = None
1891 - if (item._checkpointsEnabled):
1892 - if (item.checkpointFile):
1893 - # if there's a specific checkpoint file we are
1894 - # rerunning, we would only clear out old copies
1895 - # of that very file. meh. how likely is it that we
1896 - # have one? these files are time based and the start/end pageids
1897 - # are going to fluctuate. whatever
1898 - checkpoint = item.checkpointFile.checkpoint
 1907+ checkpoint = None
 1908+ if (item._checkpointsEnabled):
 1909+ if (item.checkpointFile):
 1910+ # if there's a specific checkpoint file we are
 1911+ # rerunning, we would only clear out old copies
 1912+ # of that very file. meh. how likely is it that we
 1913+ # have one? these files are time based and the start/end pageids
 1914+ # are going to fluctuate. whatever
 1915+ checkpoint = item.checkpointFile.checkpoint
18991916
1900 - for d in dumpNames:
1901 - self.symLinks.removeSymLinksFromOldRuns(self.wiki.date, d, chunk, checkpoint )
 1917+ for d in dumpNames:
 1918+ self.symLinks.removeSymLinksFromOldRuns(self.wiki.date, d, chunk, checkpoint )
19021919
1903 - self.feeds.cleanupFeeds()
 1920+ self.feeds.cleanupFeeds()
19041921
19051922 def makeDir(self, dir):
19061923 if self._makeDirEnabled:
@@ -1974,6 +1991,7 @@
19751992 # earlier dates. checkpoint ranges change, and configuration of chunks changes too, so maybe
19761993 # old files still exist and the links need to be removed because we have newer files for the
19771994 # same phase of the dump.
 1995+
19781996 if (self._enabled):
19791997 latestDir = self.dumpDir.latestDir()
19801998 files = os.listdir(latestDir)
@@ -2854,7 +2872,6 @@
28552873 # we don't checkpoint the checkpoint file.
28562874 self._checkpointsEnabled = False
28572875 self.pageIDRange = pageIDRange
2858 -
28592876 Dump.__init__(self, name, desc)
28602877
28612878 def getDumpNameBase(self):
@@ -2898,9 +2915,6 @@
28992916 commands.append(series)
29002917 else:
29012918 for f in inputFiles:
2902 - print "input file ", f.filename, "for buildcommand from xml dump"
2903 - # we should convert the input file to an output file I guess
2904 - # we write regular files
29052919 outputFile = DumpFilename(self.wiki, f.date, f.dumpName, f.fileType, self.fileExt)
29062920 series = self.buildCommand(runner, f)
29072921 commands.append(series)
@@ -3449,10 +3463,15 @@
34503464 scriptCommand = MultiVersion.MWScriptAsArray(runner.wiki.config, "dumpBackup.php")
34513465 command = [ "%s" % runner.wiki.config.php, "-q" ]
34523466 command.extend(scriptCommand)
 3467+ version = MultiVersion.MWVersion(runner.wiki.config, runner.dbName)
 3468+ if version:
 3469+ abstractFilterCommand = "--plugin=AbstractFilter:%s/%s/extensions/ActiveAbstract/AbstractFilter.php" % (runner.wiki.config.wikiDir, version)
 3470+ else:
 3471+ abstractFilterCommand = "--plugin=AbstractFilter:%s/extensions/ActiveAbstract/AbstractFilter.php" % runner.wiki.config.wikiDir
34533472 command.extend([ "--wiki=%s" % runner.dbName,
3454 - "--plugin=AbstractFilter:%s/extensions/ActiveAbstract/AbstractFilter.php" % runner.wiki.config.wikiDir,
3455 - "--current", "--report=1000", "%s" % runner.forceNormalOption(),
3456 - ])
 3473+ abstractFilterCommand,
 3474+ "--current", "--report=1000", "%s" % runner.forceNormalOption(),
 3475+ ])
34573476
34583477 for v in self._variants():
34593478 variantOption = self._variantOption(v)

Status & tagging log