Index: branches/ariel/xmldumps-backup/worker.py |
— | — | @@ -160,6 +160,8 @@ |
161 | 161 | |
162 | 162 | def defaultServer(self): |
163 | 163 | # if this fails what do we do about it? Not a bleeping thing. *ugh* FIXME!! |
| 164 | + if (not exists( self.config.php ) ): |
| 165 | + raise BackupError("php command %s not found" % self.config.php); |
164 | 166 | command = "%s -q %s/maintenance/getSlaveServer.php --wiki=%s --group=dump" % MiscUtils.shellEscape(( |
165 | 167 | self.config.php, self.config.wikiDir, self.dbName)) |
166 | 168 | return RunSimpleCommand.runAndReturn(command, self.errorCallback).strip() |
— | — | @@ -169,6 +171,8 @@ |
170 | 172 | |
171 | 173 | def buildSqlCommand(self, query, pipeto = None): |
172 | 174 | """Put together a command to execute an sql query to the server for this DB.""" |
| 175 | + if (not exists( self.config.mysql ) ): |
| 176 | + raise BackupError("mysql command %s not found" % self.config.mysql); |
173 | 177 | command = [ [ "/bin/echo", "%s" % query ], |
174 | 178 | [ "%s" % self.config.mysql, "-h", |
175 | 179 | "%s" % self.dbServer, |
— | — | @@ -183,6 +187,8 @@ |
184 | 188 | def buildSqlDumpCommand(self, table, pipeto = None): |
185 | 189 | """Put together a command to dump a table from the current DB with mysqldump |
186 | 190 | and save to a gzipped sql file.""" |
| 191 | + if (not exists( self.config.mysqldump ) ): |
| 192 | + raise BackupError("mysqldump command %s not found" % self.config.mysqldump); |
187 | 193 | command = [ [ "%s" % self.config.mysqldump, "-h", |
188 | 194 | "%s" % self.dbServer, "-u", |
189 | 195 | "%s" % self.config.dbUser, |
— | — | @@ -215,6 +221,8 @@ |
216 | 222 | def getDBTablePrefix(self): |
217 | 223 | """Get the prefix for all tables for the specific wiki ($wgDBprefix)""" |
218 | 224 | # FIXME later full path |
| 225 | + if (not exists( self.config.php ) ): |
| 226 | + raise BackupError("php command %s not found" % self.config.php); |
219 | 227 | command = "echo 'print $wgDBprefix; ' | %s -q %s/maintenance/eval.php --wiki=%s" % MiscUtils.shellEscape(( |
220 | 228 | self.config.php, self.config.wikiDir, self.dbName)) |
221 | 229 | return RunSimpleCommand.runAndReturn(command, self.errorCallback).strip() |
— | — | @@ -953,11 +961,15 @@ |
954 | 962 | # returns 0 on success, 1 on error |
955 | 963 | def saveTable(self, table, outfile): |
956 | 964 | """Dump a table from the current DB with mysqldump, save to a gzipped sql file.""" |
| 965 | + if (not exists( self.config.gzip ) ): |
| 966 | + raise BackupError("gzip command %s not found" % self.config.gzip); |
957 | 967 | commands = self.dbServerInfo.buildSqlDumpCommand(table, self.config.gzip) |
958 | 968 | return self.saveCommand(commands, outfile) |
959 | 969 | |
960 | 970 | def saveSql(self, query, outfile): |
961 | 971 | """Pass some SQL commands to the server for this DB and save output to a gzipped file.""" |
| 972 | + if (not exists( self.config.gzip ) ): |
| 973 | + raise BackupError("gzip command %s not found" % self.config.gzip); |
962 | 974 | command = self.dbServerInfo.buildSqlCommand(query, self.config.gzip) |
963 | 975 | return self.saveCommand(command, outfile) |
964 | 976 | |
— | — | @@ -1354,8 +1366,14 @@ |
1355 | 1367 | outputFilename = runner.dumpDir.publicPath(outputFileBasename) |
1356 | 1368 | chunkNum = 0 |
1357 | 1369 | recombines = [] |
| 1370 | + if (not exists( runner.config.head ) ): |
| 1371 | + raise BackupError("head command %s not found" % runner.config.head); |
1358 | 1372 | head = runner.config.head |
| 1373 | + if (not exists( runner.config.tail ) ): |
| 1374 | + raise BackupError("tail command %s not found" % runner.config.tail); |
1359 | 1375 | tail = runner.config.tail |
| 1376 | + if (not exists( runner.config.grep ) ): |
| 1377 | + raise BackupError("grep command %s not found" % runner.config.grep); |
1360 | 1378 | grep = runner.config.grep |
1361 | 1379 | |
1362 | 1380 | # we assume the result is always going to be run in a subshell. |
— | — | @@ -1486,6 +1504,8 @@ |
1487 | 1505 | current = self.buildCurrentOutputFilename(runner, chunk) |
1488 | 1506 | articles = self.buildArticlesOutputFilename(runner, chunk) |
1489 | 1507 | |
| 1508 | + if (not exists( runner.config.php ) ): |
| 1509 | + raise BackupError("php command %s not found" % runner.config.php); |
1490 | 1510 | command = [ "%s" % runner.config.php, |
1491 | 1511 | "-q", "%s/maintenance/dumpBackup.php" % runner.config.wikiDir, |
1492 | 1512 | "--wiki=%s" % runner.dbName, |
— | — | @@ -1591,6 +1611,8 @@ |
1592 | 1612 | if not len(inputFiles): |
1593 | 1613 | self.setStatus("failed") |
1594 | 1614 | raise BackupError("No input files for %s found" % self.name) |
| 1615 | + if (not exists( runner.config.gzip ) ): |
| 1616 | + raise BackupError("gzip command %s not found" % runner.config.gzip); |
1595 | 1617 | compressionCommand = runner.config.gzip |
1596 | 1618 | compressionCommand = "%s > " % runner.config.gzip |
1597 | 1619 | uncompressionCommand = [ "%s" % runner.config.gzip, "-dc" ] |
— | — | @@ -1629,6 +1651,8 @@ |
1630 | 1652 | def run(self, runner): |
1631 | 1653 | self.cleanupOldFiles(runner) |
1632 | 1654 | logging = self.buildOutputFilename(runner) |
| 1655 | + if (not exists( runner.config.php ) ): |
| 1656 | + raise BackupError("php command %s not found" % runner.config.php); |
1633 | 1657 | command = [ "%s" % runner.config.php, |
1634 | 1658 | "-q", "%s/maintenance/dumpBackup.php" % runner.config.wikiDir, |
1635 | 1659 | "--wiki=%s" % runner.dbName, |
— | — | @@ -1676,6 +1700,8 @@ |
1677 | 1701 | commands.append(series) |
1678 | 1702 | error = runner.runCommand(commands, callbackStderr=self.progressCallback, callbackStderrArg=runner) |
1679 | 1703 | |
| 1704 | + if (not exists( runner.config.checkforbz2footer ) ): |
| 1705 | + raise BackupError("checkforbz2footer command %s not found" % runner.config.checkforbz2footer); |
1680 | 1706 | checkforbz2footer = "%s" % runner.config.checkforbz2footer |
1681 | 1707 | if exists(checkforbz2footer): |
1682 | 1708 | # check to see if any of the output files are truncated |
— | — | @@ -1704,6 +1730,8 @@ |
1705 | 1731 | def buildFilters(self, runner, chunk = 0): |
1706 | 1732 | """Construct the output filter options for dumpTextPass.php""" |
1707 | 1733 | xmlbz2 = self._path(runner, "bz2", chunk) |
| 1734 | + if (not exists( runner.config.bzip2 ) ): |
| 1735 | + raise BackupError("bzip2 command %s not found" % runner.config.bzip2); |
1708 | 1736 | if runner.config.bzip2[-6:] == "dbzip2": |
1709 | 1737 | bz2mode = "dbzip2" |
1710 | 1738 | else: |
— | — | @@ -1748,6 +1776,8 @@ |
1749 | 1777 | else: |
1750 | 1778 | spawn = None |
1751 | 1779 | |
| 1780 | + if (not exists( runner.config.php ) ): |
| 1781 | + raise BackupError("php command %s not found" % runner.config.php); |
1752 | 1782 | dumpCommand = [ "%s" % runner.config.php, |
1753 | 1783 | "-q", "%s/maintenance/dumpTextPass.php" % runner.config.wikiDir, |
1754 | 1784 | "--wiki=%s" % runner.dbName, |
— | — | @@ -1770,9 +1800,13 @@ |
1771 | 1801 | return self._pageID[fileName] |
1772 | 1802 | pageID = None |
1773 | 1803 | pipeline = [] |
| 1804 | + if (not exists( runner.config.bzip2 ) ): |
| 1805 | + raise BackupError("bzip2 command %s not found" % runner.config.bzip2); |
1774 | 1806 | uncompressionCommand = [ "%s" % runner.config.bzip2, "-dc", fileName ] |
1775 | 1807 | pipeline.append(uncompressionCommand) |
1776 | 1808 | # warning: we figure any header (<siteinfo>...</siteinfo>) is going to be less than 2000 lines! |
| 1809 | + if (not exists( runner.config.head ) ): |
| 1810 | + raise BackupError("head command %s not found" % runner.config.head); |
1777 | 1811 | head = runner.config.head |
1778 | 1812 | headEsc = MiscUtils.shellEscape(head) |
1779 | 1813 | pipeline.append([ head, "-2000"]) |
— | — | @@ -2006,6 +2040,8 @@ |
2007 | 2041 | if not len(inputFiles): |
2008 | 2042 | self.setStatus("failed") |
2009 | 2043 | raise BackupError("No input files for %s found" % self.name) |
| 2044 | + if (not exists( runner.config.bzip2 ) ): |
| 2045 | + raise BackupError("bzip2 command %s not found" % runner.config.bzip2); |
2010 | 2046 | compressionCommand = runner.config.bzip2 |
2011 | 2047 | compressionCommand = "%s > " % runner.config.bzip2 |
2012 | 2048 | uncompressionCommand = [ "%s" % runner.config.bzip2, "-dc" ] |
— | — | @@ -2068,6 +2104,10 @@ |
2069 | 2105 | xml7z = self.buildOutputFilename(runner, chunk) |
2070 | 2106 | |
2071 | 2107 | # FIXME need shell escape |
| 2108 | + if (not exists( runner.config.bzip2 ) ): |
| 2109 | + raise BackupError("bzip2 command %s not found" % runner.config.bzip2); |
| 2110 | + if (not exists( runner.config.sevenzip ) ): |
| 2111 | + raise BackupError("7zip command %s not found" % runner.config.sevenzip); |
2072 | 2112 | commandPipe = [ [ "%s -dc %s | %s a -si %s" % (runner.config.bzip2, xmlbz2, runner.config.sevenzip, xml7z) ] ] |
2073 | 2113 | commandSeries = [ commandPipe ] |
2074 | 2114 | return(commandSeries) |
— | — | @@ -2153,6 +2193,8 @@ |
2154 | 2194 | if not len(inputFiles): |
2155 | 2195 | self.setStatus("failed") |
2156 | 2196 | raise BackupError("No input files for %s found" % self.name) |
| 2197 | + if (not exists( runner.config.sevenzip ) ): |
| 2198 | + raise BackupError("sevenzip command %s not found" % runner.config.sevenzip); |
2157 | 2199 | compressionCommand = "%s a -si" % runner.config.sevenzip |
2158 | 2200 | uncompressionCommand = [ "%s" % runner.config.sevenzip, "e", "-so" ] |
2159 | 2201 | |
— | — | @@ -2174,6 +2216,8 @@ |
2175 | 2217 | self._chunks = chunks |
2176 | 2218 | |
2177 | 2219 | def buildCommand(self, runner, chunk = 0): |
| 2220 | + if (not exists( runner.config.php ) ): |
| 2221 | + raise BackupError("php command %s not found" % runner.config.php); |
2178 | 2222 | command = [ "%s" % runner.config.php, |
2179 | 2223 | "-q", "%s/maintenance/dumpBackup.php" % runner.config.wikiDir, |
2180 | 2224 | "--wiki=%s" % runner.dbName, |
— | — | @@ -2276,6 +2320,8 @@ |
2277 | 2321 | if not len(inputFiles): |
2278 | 2322 | self.setStatus("failed") |
2279 | 2323 | raise BackupError("No input files for %s found" % self.name) |
| 2324 | + if (not exists( runner.config.cat ) ): |
| 2325 | + raise BackupError("cat command %s not found" % runner.config.cat); |
2280 | 2326 | compressionCommand = "%s > " % runner.config.cat |
2281 | 2327 | uncompressionCommand = [ "%s" % runner.config.cat ] |
2282 | 2328 | recombineCommandString = self.buildRecombineCommandString(runner, inputFiles, outputFile, compressionCommand, uncompressionCommand, "<feed>" ) |