Browse Source

Fix retrying; also don't process case at all if ->REVIEW fails.

tags/v0.1^2
Ben Kurtovic 12 years ago
parent
commit
674dcb8c4f
1 changed files with 9 additions and 6 deletions
  1. +9
    -6
      earwigbot/tasks/drn_clerkbot.py

+ 9
- 6
earwigbot/tasks/drn_clerkbot.py View File

@@ -120,7 +120,8 @@ class DRNClerkBot(Task):
notices = self.clerk(conn, cases) notices = self.clerk(conn, cases)
if self.shutoff_enabled(): if self.shutoff_enabled():
return return
self.save(page, cases, kwargs, start)
if not self.save(page, cases, kwargs, start):
return
self.send_notices(site, notices) self.send_notices(site, notices)
if action in ["all", "update_chart"]: if action in ["all", "update_chart"]:
if self.shutoff_enabled(): if self.shutoff_enabled():
@@ -425,7 +426,8 @@ class DRNClerkBot(Task):
"""Check whether a case is old enough to be set to "review".""" """Check whether a case is old enough to be set to "review"."""
age = (datetime.utcnow() - case.file_time).total_seconds() age = (datetime.utcnow() - case.file_time).total_seconds()
if age > 60 * 60 * 24 * 4: if age > 60 * 60 * 24 * 4:
return self.update_status(case, self.STATUS_REVIEW)
self.update_status(case, self.STATUS_REVIEW)
return True
return False return False


def update_status(self, case, new): def update_status(self, case, new):
@@ -438,10 +440,9 @@ class DRNClerkBot(Task):
case.status = new case.status = new
log = u" {0}: {1} -> {2}" log = u" {0}: {1} -> {2}"
self.logger.debug(log.format(case.id, old_n, new_n)) self.logger.debug(log.format(case.id, old_n, new_n))
return True
return
log = u"Avoiding {0} {1} -> {2} because we already did this ('{3}')" log = u"Avoiding {0} {1} -> {2} because we already did this ('{3}')"
self.logger.info(log.format(case.id, old_n, new_n, case.title)) self.logger.info(log.format(case.id, old_n, new_n, case.title))
return False


def read_signatures(self, text): def read_signatures(self, text):
"""Return a list of all parseable signatures in the body of a case. """Return a list of all parseable signatures in the body of a case.
@@ -609,7 +610,7 @@ class DRNClerkBot(Task):
counter += 1 counter += 1
if newtext == text: if newtext == text:
self.logger.info(u"Nothing to edit on [[{0}]]".format(page.title)) self.logger.info(u"Nothing to edit on [[{0}]]".format(page.title))
return
return True


worktime = time() - start worktime = time() - start
if worktime < 60: if worktime < 60:
@@ -620,12 +621,14 @@ class DRNClerkBot(Task):
if page.get() != text: if page.get() != text:
log = "Someone has edited the page while we were working; restarting" log = "Someone has edited the page while we were working; restarting"
self.logger.warn(log) self.logger.warn(log)
return self.run(**kwargs)
self.run(**kwargs)
return False
summary = self.clerk_summary.replace("$3", str(counter)) summary = self.clerk_summary.replace("$3", str(counter))
summary = summary.replace("$4", "" if counter == 1 else "s") summary = summary.replace("$4", "" if counter == 1 else "s")
page.edit(newtext, summary, minor=True, bot=True) page.edit(newtext, summary, minor=True, bot=True)
log = u"Saved page [[{0}]] ({1} updates)" log = u"Saved page [[{0}]] ({1} updates)"
self.logger.info(log.format(page.title, counter)) self.logger.info(log.format(page.title, counter))
return True


def send_notices(self, site, notices): def send_notices(self, site, notices):
"""Send out any templated notices to users or pages.""" """Send out any templated notices to users or pages."""


Loading…
Cancel
Save