summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormartinko2013-12-18 15:16:41 +0000
committermartinko2013-12-18 15:16:41 +0000
commit7bf9aba30603cf7eda81c5477f12b34239e4dfc1 (patch)
tree2b97ff94758c733a7fb7ac520a72ebfe9c1bfc41
parent8263f2fef55e078bfe15d026db5495c1880f0ffa (diff)
scripts/data_maintainer.py: fixes
-rwxr-xr-xscripts/data_maintainer.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/scripts/data_maintainer.py b/scripts/data_maintainer.py
index 781d21f1..de550c37 100755
--- a/scripts/data_maintainer.py
+++ b/scripts/data_maintainer.py
@@ -176,8 +176,8 @@ class DataMaintainer (skytools.DBScript):
# query for fetching the PK-s of the data set to be maintained
self.sql_pk = self.cf.get("sql_get_pk_list", "")
- if not self.sql_pk and not self.fileread:
- raise ValueError("Either fileread or sql_get_pk_list must be specified in the configuration file")
+ if (int(bool(self.sql_pk)) + int(bool(self.fileread))) in (0,2):
+ raise skytools.UsageError("Either fileread or sql_get_pk_list must be specified in the configuration file")
# query for changing data tuple ( autocommit )
self.sql_modify = self.cf.get("sql_modify")
@@ -258,7 +258,7 @@ class DataMaintainer (skytools.DBScript):
dbw.commit()
self.stat_put("duration", time.time() - self.fetch_started)
self.send_stats()
- if len(res) < self.fetchcnt or not self.looping:
+ if len(res) < self.fetchcnt or self.last_sigint:
break
if self.commit_delay > 0.0:
time.sleep(self.commit_delay)
@@ -266,7 +266,7 @@ class DataMaintainer (skytools.DBScript):
self.throttle(tcur)
self._print_count("--- Running count: %s duration: %s ---")
- if not self.looping:
+ if self.last_sigint:
self.log.info("Exiting on user request")
self.datasource.close()
@@ -304,7 +304,7 @@ class DataMaintainer (skytools.DBScript):
else:
count += 1
self.stat_increase("count")
- if not self.looping:
+ if self.last_sigint:
break
return count, item
except: # process has crashed, run sql_crash and re-raise the exception
@@ -315,7 +315,7 @@ class DataMaintainer (skytools.DBScript):
raise
def throttle(self, tcur):
- while self.looping:
+ while not self.last_sigint:
tcur.execute(self.sql_throttle)
_r = tcur.fetchall()
assert len(_r) == 1 and len(_r[0]) == 1, "Result of 'throttle' query must be 1 value"