commit 19d6c84b39354b57278f731e87fe182042d5680a
Author: Radek Pazdera <rpazdera(a)redhat.com>
Date: Thu Nov 8 16:17:52 2012 +0100
Config: Adding cache expiration_period to slave config
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
Common/Config.py | 26 ++++++++++++++++++++++++++
lnst-slave.conf | 1 +
2 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/Common/Config.py b/Common/Config.py
index 41438a6..9cd18b0 100644
--- a/Common/Config.py
+++ b/Common/Config.py
@@ -56,6 +56,8 @@ class Config():
self.options['cache']['dir'] = os.path.abspath(os.path.join(
os.path.dirname(sys.argv[0]), './cache'))
+ self.options['cache']['expiration_period'] = 7*24*60*60 # 1 week
+
def get_config(self):
return self.options
@@ -126,6 +128,9 @@ class Config():
for option in config:
if option == 'cache_dir':
section['dir'] = self.optionPath(config[option], cfg_path)
+ elif option == 'expiration_period':
+ value = self.optionTimeval(config[option])
+ section['expiration_period'] = value
else:
msg = "Unknown option: %s in section cache" % option
raise ConfigError(msg)
@@ -200,3 +205,24 @@ class Config():
dirs.append(norm_path)
return dirs
+
+ def optionTimeval(self, option):
+ timeval_re = "^(([0-9]+)days?)?\s*(([0-9]+)hours?)?\s*" \
+ "(([0-9]+)minutes?)?\s*(([0-9]+)seconds?)?$"
+ timeval_match = re.match(timeval_re, option)
+ if timeval_match:
+ values = timeval_match.groups()
+ timeval = 0
+ if values[1]:
+ timeval += int(values[1])*24*60*60
+ if values[3]:
+ timeval += int(values[3])*60*60
+ if values[5]:
+ timeval += int(values[5])*60
+ if values[7]:
+ timeval += int(values[7])
+ else:
+ msg = "Incorrect timeval format."
+ raise ConfigError(msg)
+
+ return timeval
diff --git a/lnst-slave.conf b/lnst-slave.conf
index 6a9bfe1..924d0c7 100644
--- a/lnst-slave.conf
+++ b/lnst-slave.conf
@@ -1,2 +1,3 @@
[cache]
cache_dir = ./cache
+expiration_period = 7days
Show replies by date