r97946 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97945‎ | r97946 | r97947 >
Date:18:56, 23 September 2011
Author:ariel
Status:deferred
Tags:
Comment:
fold in mwscript wrapper for calls to various php maintenance scripts
Modified paths:
  • /branches/ariel/xmldumps-backup/worker.py (modified) (history)

Diff [purge]

Index: branches/ariel/xmldumps-backup/worker.py
@@ -154,6 +154,20 @@
155155 return 0
156156 return chunks
157157
 158+class MultiVersion(object):
 159+ def MWScriptAsString(config, maintenanceScript):
 160+ return(" ".join(MultiVersion.MWScriptAsArray(config, maintenanceScript)))
 161+
 162+ def MWScriptAsArray(config, maintenanceScript):
 163+ MWScriptLocation = os.path.join(config.wikiDir,"..","multiversion","MWScript.php")
 164+ if exists(MWScriptLocation):
 165+ return [ MWScriptLocation, maintenanceScript ]
 166+ else:
 167+ return [ "%s/maintenance/%s" % (config.wikiDir, maintenanceScript) ]
 168+
 169+ MWScriptAsString = staticmethod(MWScriptAsString)
 170+ MWScriptAsArray = staticmethod(MWScriptAsArray)
 171+
158172 class DbServerInfo(object):
159173 def __init__(self, wiki, dbName, errorCallback = None):
160174 self.wiki = wiki
@@ -165,8 +179,14 @@
166180 # if this fails what do we do about it? Not a bleeping thing. *ugh* FIXME!!
167181 if (not exists( self.wiki.config.php ) ):
168182 raise BackupError("php command %s not found" % self.wiki.config.php)
169 - command = "%s -q %s/maintenance/getSlaveServer.php --wiki=%s --group=dump" % MiscUtils.shellEscape((
170 - self.wiki.config.php, self.wiki.config.wikiDir, self.dbName))
 183+ commandList = MultiVersion.MWScriptAsArray(self.wiki.config, "getSlaveServer.php")
 184+# command = "%s -q %s/maintenance/getSlaveServer.php --wiki=%s --group=dump" % MiscUtils.shellEscape((
 185+ for i in range(0,len(commandList)):
 186+ phpCommand = MiscUtils.shellEscape(self.wiki.config.php)
 187+ dbName = MiscUtils.shellEscape(self.dbName)
 188+ commandList[i] = MiscUtils.shellEscape(commandList[i])
 189+ command = " ".join(commandList)
 190+ command = "%s -q %s --wiki=%s --group=dump" % (phpCommand, command, dbName)
171191 return RunSimpleCommand.runAndReturn(command, self.errorCallback).strip()
172192
173193 def selectDatabaseServer(self):
@@ -226,8 +246,14 @@
227247 # FIXME later full path
228248 if (not exists( self.wiki.config.php ) ):
229249 raise BackupError("php command %s not found" % self.wiki.config.php)
230 - command = "echo 'print $wgDBprefix; ' | %s -q %s/maintenance/eval.php --wiki=%s" % MiscUtils.shellEscape((
231 - self.wiki.config.php, self.wiki.config.wikiDir, self.dbName))
 250+ commandList = MultiVersion.MWScriptAsArray(self.wiki.config, "eval.php")
 251+# command = "echo 'print $wgDBprefix; ' | %s -q %s/maintenance/eval.php --wiki=%s" % MiscUtils.shellEscape((
 252+ for i in range(0,len(commandList)):
 253+ phpCommand = MiscUtils.shellEscape(self.wiki.config.php)
 254+ dbName = MiscUtils.shellEscape(self.dbName)
 255+ commandList[i] = MiscUtils.shellEscape(commandList[i])
 256+ command = " ".join(commandList)
 257+ command = "echo 'print $wgDBprefix; ' | %s -q %s --wiki=%s" % (phpCommand, command, dbName)
232258 return RunSimpleCommand.runAndReturn(command, self.errorCallback).strip()
233259
234260
@@ -2637,15 +2663,17 @@
26382664 articlesFile = runner.dumpDir.filenamePublicPath(f)
26392665 historyFile = runner.dumpDir.filenamePublicPath(DumpFilename(runner.wiki, f.date, self.historyDumpName, f.fileType, f.fileExt, f.chunk, f.checkpoint, f.temp))
26402666 currentFile = runner.dumpDir.filenamePublicPath(DumpFilename(runner.wiki, f.date, self.currentDumpName, f.fileType, f.fileExt, f.chunk, f.checkpoint, f.temp))
2641 - command = [ "%s" % runner.wiki.config.php,
2642 - "-q", "%s/maintenance/dumpBackup.php" % runner.wiki.config.wikiDir,
2643 - "--wiki=%s" % runner.dbName,
2644 - "--full", "--stub", "--report=10000",
2645 - "%s" % runner.forceNormalOption(),
2646 - "--output=gzip:%s" % historyFile,
2647 - "--output=gzip:%s" % currentFile,
2648 - "--filter=latest", "--output=gzip:%s" % articlesFile,
2649 - "--filter=latest", "--filter=notalk", "--filter=namespace:!NS_USER" ]
 2667+ scriptCommand = MultiVersion.MWScriptAsArray(runner.wiki.config, "dumpBackup.php")
 2668+ command = [ "%s" % runner.wiki.config.php, "-q" ]
 2669+ command.extend(scriptCommand)
 2670+ command.extend(["--wiki=%s" % runner.dbName,
 2671+ "--full", "--stub", "--report=10000",
 2672+ "%s" % runner.forceNormalOption(),
 2673+ "--output=gzip:%s" % historyFile,
 2674+ "--output=gzip:%s" % currentFile,
 2675+ "--filter=latest", "--output=gzip:%s" % articlesFile,
 2676+ "--filter=latest", "--filter=notalk", "--filter=namespace:!NS_USER"
 2677+ ])
26502678
26512679 if (f.chunk):
26522680 # set up start end end pageids for this piece
@@ -2760,12 +2788,13 @@
27612789 logging = runner.dumpDir.filenamePublicPath(files[0])
27622790 if (not exists( runner.wiki.config.php ) ):
27632791 raise BackupError("php command %s not found" % runner.wiki.config.php)
2764 - command = [ "%s" % runner.wiki.config.php,
2765 - "-q", "%s/maintenance/dumpBackup.php" % runner.wiki.config.wikiDir,
2766 - "--wiki=%s" % runner.dbName,
 2792+ scriptCommand = MultiVersion.MWScriptAsArray(runner.wiki.config, "dumpBackup.php")
 2793+ command = [ "%s" % runner.wiki.config.php, "-q" ]
 2794+ command.extend(scriptCommand)
 2795+ command.extend(["--wiki=%s" % runner.dbName,
27672796 "--logs", "--report=10000",
27682797 "%s" % runner.forceNormalOption(),
2769 - "--output=gzip:%s" % logging ]
 2798+ "--output=gzip:%s" % logging ])
27702799 pipeline = [ command ]
27712800 series = [ pipeline ]
27722801 error = runner.runCommand([ series ], callbackStderr=self.progressCallback, callbackStderrArg=runner)
@@ -2839,6 +2868,7 @@
28402869 commands.append(series)
28412870 else:
28422871 for f in inputFiles:
 2872+ print "input file ", f.filename, "for buildcommand from xml dump"
28432873 # we should convert the input file to an output file I guess
28442874 # we write regular files
28452875 outputFile = DumpFilename(self.wiki, f.date, f.dumpName, f.fileType, self.fileExt)
@@ -3003,16 +3033,18 @@
30043034 else:
30053035 checkpointTime = ""
30063036 checkpointFile = ""
3007 - dumpCommand = [ "%s" % self.wiki.config.php,
3008 - "-q", "%s/maintenance/dumpTextPass.php" % self.wiki.config.wikiDir,
3009 - "--wiki=%s" % runner.dbName,
3010 - "%s" % stubOption,
3011 - "%s" % prefetch,
3012 - "%s" % runner.forceNormalOption(),
3013 - "%s" % checkpointTime,
3014 - "%s" % checkpointFile,
3015 - "--report=1000",
3016 - "%s" % spawn ]
 3037+ scriptCommand = MultiVersion.MWScriptAsArray(runner.wiki.config, "dumpTextPass.php")
 3038+ dumpCommand = [ "%s" % self.wiki.config.php, "-q" ]
 3039+ dumpCommand.extend(scriptCommand)
 3040+ dumpCommand.extend(["--wiki=%s" % runner.dbName,
 3041+ "%s" % stubOption,
 3042+ "%s" % prefetch,
 3043+ "%s" % runner.forceNormalOption(),
 3044+ "%s" % checkpointTime,
 3045+ "%s" % checkpointFile,
 3046+ "--report=1000",
 3047+ "%s" % spawn
 3048+ ])
30173049
30183050 dumpCommand = filter(None, dumpCommand)
30193051 command = dumpCommand
@@ -3384,12 +3416,13 @@
33853417 def buildCommand(self, runner, f):
33863418 if (not exists( runner.wiki.config.php ) ):
33873419 raise BackupError("php command %s not found" % runner.wiki.config.php)
3388 - command = [ "%s" % runner.wiki.config.php,
3389 - "-q", "%s/maintenance/dumpBackup.php" % runner.wiki.config.wikiDir,
3390 - "--wiki=%s" % runner.dbName,
 3420+ scriptCommand = MultiVersion.MWScriptAsArray(runner.wiki.config, "dumpBackup.php")
 3421+ command = [ "%s" % runner.wiki.config.php, "-q" ]
 3422+ command.extend(scriptCommand)
 3423+ command.extend([ "--wiki=%s" % runner.dbName,
33913424 "--plugin=AbstractFilter:%s/extensions/ActiveAbstract/AbstractFilter.php" % runner.wiki.config.wikiDir,
33923425 "--current", "--report=1000", "%s" % runner.forceNormalOption(),
3393 - ]
 3426+ ])
33943427
33953428 for v in self._variants():
33963429 variantOption = self._variantOption(v)

Status & tagging log