Index: branches/ariel/xmldumps-backup/incrementals/incrmonitor.py |
— | — | @@ -26,8 +26,9 @@ |
27 | 27 | makeLink = staticmethod(makeLink) |
28 | 28 | |
29 | 29 | class Index(object): |
30 | | - def __init__(self, config, verbose): |
| 30 | + def __init__(self, config, date, verbose): |
31 | 31 | self._config = config |
| 32 | + self.date = date |
32 | 33 | self.indexFile = IndexFile(self._config) |
33 | 34 | self.incrDir = IncrementDir(self._config) |
34 | 35 | self.verbose = verbose |
— | — | @@ -37,6 +38,8 @@ |
38 | 39 | for w in self._config.allWikisList: |
39 | 40 | result = self.doOneWiki(w) |
40 | 41 | if result: |
| 42 | + if (self.verbose): |
| 43 | + print "result for wiki ", w, "is ", result |
41 | 44 | text = text + "<li>"+ result + "</li>\n" |
42 | 45 | indexText = self._config.readTemplate("incrs-index.html") % { "items" : text } |
43 | 46 | FileUtils.writeFileInPlace(self.indexFile.getPath(), indexText, self._config.fileperms) |
— | — | @@ -48,8 +51,10 @@ |
49 | 52 | if (self.verbose): |
50 | 53 | print "No dump for wiki ", w |
51 | 54 | next |
52 | | - |
53 | | - incrDate = self.incrDumpsDirs.getLatestIncrDate() |
| 55 | + if date: |
| 56 | + incrDate = date |
| 57 | + else: |
| 58 | + incrDate = self.incrDumpsDirs.getLatestIncrDate() |
54 | 59 | if not incrDate: |
55 | 60 | if (self.verbose): |
56 | 61 | print "No dump for wiki ", w |
— | — | @@ -69,7 +74,8 @@ |
70 | 75 | except: |
71 | 76 | if (self.verbose): |
72 | 77 | traceback.print_exc(file=sys.stdout) |
73 | | - return "Error encountered, no information available for wiki", w |
| 78 | + print "Error encountered, no information available for wiki", w |
| 79 | + return "Error encountered, no information available for wiki" + w |
74 | 80 | |
75 | 81 | try: |
76 | 82 | wikinameText = "<strong>%s</strong>" % w |
— | — | @@ -85,17 +91,19 @@ |
86 | 92 | revsText = "revs: %s (size %s)" % (Link.makeLink(os.path.join(w, incrDate, revs.getFileName()),revsDate), revsSize) |
87 | 93 | else: |
88 | 94 | revsText = None |
| 95 | + otherRunsText = "other runs: %s" % Link.makeLink(w,w) |
89 | 96 | if statContents: |
90 | 97 | statText = "(%s)" % (statContents) |
91 | 98 | else: |
92 | 99 | statText = None |
93 | 100 | |
94 | 101 | wikiInfo = " ".join( filter( None, [ wikinameText, lockText, statText ] ) ) + "<br />" |
95 | | - wikiInfo = wikiInfo + " " + " | ".join( filter( None, [ stubText, revsText ] )) |
| 102 | + wikiInfo = wikiInfo + " " + " | ".join( filter( None, [ stubText, revsText, otherRunsText ] )) |
96 | 103 | except: |
97 | 104 | if (self.verbose): |
98 | 105 | traceback.print_exc(file=sys.stdout) |
99 | | - return "Error encountered formatting information for wiki", w |
| 106 | + print "Error encountered formatting information for wiki", w |
| 107 | + return "Error encountered formatting information for wiki" + w |
100 | 108 | |
101 | 109 | return wikiInfo |
102 | 110 | |
— | — | @@ -103,25 +111,29 @@ |
104 | 112 | if message: |
105 | 113 | print message |
106 | 114 | print "Usage: python monitor.py [options] [wikidbname]" |
107 | | - print "Options: --configfile, --verbose" |
| 115 | + print "Options: --configfile, --date, --verbose" |
108 | 116 | print "--configfile: Specify an alternate config file to read. Default file is 'dumpincr.conf' in the current directory." |
| 117 | + print "--date: Look at runs starting on specified date or earler" |
109 | 118 | print "--verbose: Print error messages and other informative messages (normally the" |
110 | 119 | print " script runs silently)." |
111 | 120 | sys.exit(1) |
112 | 121 | |
113 | 122 | if __name__ == "__main__": |
114 | 123 | configFile = False |
| 124 | + date = False |
115 | 125 | verbose = False |
116 | 126 | |
117 | 127 | try: |
118 | 128 | (options, remainder) = getopt.gnu_getopt(sys.argv[1:], "", |
119 | | - ['configfile=', 'verbose' ]) |
| 129 | + ['configfile=', 'date=', 'verbose' ]) |
120 | 130 | except: |
121 | 131 | usage("Unknown option specified") |
122 | 132 | |
123 | 133 | for (opt, val) in options: |
124 | 134 | if opt == "--configfile": |
125 | 135 | configFile = val |
| 136 | + elif opt == "--date": |
| 137 | + date=val |
126 | 138 | elif opt == '--verbose': |
127 | 139 | verbose = True |
128 | 140 | |
— | — | @@ -130,5 +142,5 @@ |
131 | 143 | else: |
132 | 144 | config = Config() |
133 | 145 | |
134 | | - index = Index(config, verbose) |
| 146 | + index = Index(config, date, verbose) |
135 | 147 | index.doAllWikis() |