r95406 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95405‎ | r95406 | r95407 >
Date:17:59, 24 August 2011
Author:ariel
Status:ok
Tags:
Comment:
fix dump run info file writing (again), clean up dup code in newFromFilename
Modified paths:
  • /branches/ariel/xmldumps-backup/worker.py (modified) (history)

Diff [purge]

Index: branches/ariel/xmldumps-backup/worker.py
@@ -395,7 +395,7 @@
396396 directory = self._getDumpRunInfoDirName()
397397 dumpRunInfoFilename = self._getDumpRunInfoFileName()
398398 # FileUtils.writeFile(directory, dumpRunInfoFilename, text, self.wiki.config.fileperms)
399 - FileUtils.writeFileInPlace(self.wiki.config.tempDir, dumpRunInfoFilename, text, self.wiki.config.fileperms)
 399+ FileUtils.writeFileInPlace(dumpRunInfoFilename, text, self.wiki.config.fileperms)
400400
401401 # format: name:%; updated:%; status:%
402402 def _getStatusForJobFromRunInfoFileLine(self, line, jobName):
@@ -973,6 +973,29 @@
974974 """Constructor. Arguments: the full file name including the chunk, the extension, etc BUT NOT the dir name. """
975975 self.filename = filename
976976
 977+ self.dbName = None
 978+ self.date = None
 979+ self.dumpName = None
 980+
 981+ self.basename = None
 982+ self.fileExt = None
 983+ self.fileType = None
 984+
 985+ self.filePrefix = ""
 986+ self.filePrefixLength = 0
 987+
 988+ self.isChunkFile = False
 989+ self.chunk = None
 990+ self.chunkInt = 0
 991+
 992+ self.isCheckpointFile = False
 993+ self.checkpoint = None
 994+ self.firstPageID = None
 995+ self.lastPageID = None
 996+
 997+ self.isTempFile = False
 998+ self.temp = None
 999+
9771000 # example filenames:
9781001 # elwikidb-20110729-all-titles-in-ns0.gz
9791002 # elwikidb-20110729-abstract.xml
@@ -983,32 +1006,14 @@
9841007 if self.filename.endswith("-tmp"):
9851008 self.isTempFile = True
9861009 self.temp = "-tmp"
987 - else:
988 - self.isTempFile = False
989 - self.temp = None
9901010
9911011 if ('.' in self.filename):
9921012 (fileBase, self.fileExt) = self.filename.rsplit('.',1)
9931013 if (self.temp):
9941014 self.fileExt = self.fileExt[:-4];
9951015 else:
996 - self.dbName = None
997 - self.date = None
998 - self.dumpName = None
999 - self.filePrefix = ""
1000 - self.filePrefixLength = 0
1001 - self.isChunkFile = False
1002 - self.isCheckpointFile = False
1003 - self.checkpoint = None
1004 - self.firstPageID = None
1005 - self.lastPageID = None
1006 - self.isTempFile = False
1007 - self.fileExt = None
1008 - self.fileType = None
10091016 return False
10101017
1011 - # FIXME could have -tmp at the end, when do we look for that??
1012 -
10131018 if not self.isExt(self.fileExt):
10141019 self.fileType = self.fileExt
10151020 # self.fileExt = None
@@ -1019,35 +1024,17 @@
10201025
10211026 # some files are not of this form, we skip them
10221027 if not '-' in fileBase:
1023 - self.dbName = None
1024 - self.date = None
1025 - self.dumpName = None
1026 - self.filePrefix = ""
1027 - self.filePrefixLength = 0
1028 - self.isChunkFile = False
1029 - self.isCheckpointFile = False
1030 - self.checkpoint = None
1031 - self.firstPageID = None
1032 - self.lastPageID = None
1033 - self.isTempFile = False
1034 - self.temp = None
10351028 return False
10361029
10371030 (self.dbName, self.date, self.dumpName) = fileBase.split('-',2)
10381031 if not self.date or not self.dumpName:
1039 - self.dbName = None
1040 - self.date = None
10411032 self.dumpName = fileBase
1042 - self.filePrefix = ""
1043 - self.filePrefixLength = 0
10441033 else:
10451034 self.filePrefix = "%s-%s-" % (self.dbName, self.date)
10461035 self.filePrefixLength = len(self.filePrefix)
10471036
10481037 if self.filename.startswith(self.filePrefix):
10491038 self.basename = self.filename[self.filePrefixLength:]
1050 - else:
1051 - self.basename = None
10521039
10531040 self.checkpointPattern = "-p(?P<first>[0-9]+)p(?P<last>[0-9]+)\." + self.fileExt + "$"
10541041 self.compiledCheckpointPattern = re.compile(self.checkpointPattern)
@@ -1060,11 +1047,6 @@
10611048 self.checkpoint = "p" + self.firstPageID + "p" + self.lastPageID
10621049 if self.fileType and self.fileType.endswith("-" + self.checkpoint):
10631050 self.fileType = self.fileType[:-1 * ( len(self.checkpoint) + 1 ) ]
1064 - else:
1065 - self.isCheckpointFile = False
1066 - self.checkpoint = None
1067 - self.firstPageID = None
1068 - self.lastPageID = None
10691051
10701052 self.chunkPattern = "(?P<chunk>[0-9]+)$"
10711053 self.compiledChunkPattern = re.compile(self.chunkPattern)
@@ -1075,10 +1057,6 @@
10761058 self.chunkInt = int(self.chunk)
10771059 # the dumpName has the chunk in it so lose it
10781060 self.dumpName = self.dumpName.rstrip('0123456789')
1079 - else:
1080 - self.isChunkFile = False
1081 - self.chunk = None
1082 - self.chunkInt = 0
10831061
10841062 return True
10851063

Status & tagging log