From b364eef36462937a2edd278ba020224ce7360fa4 Mon Sep 17 00:00:00 2001
From: Vuolter <vuolter@gmail.com>
Date: Sat, 11 May 2013 01:20:09 +0200
Subject: Added plugin DeleteFinished, version 0.1

---
 module/plugins/hooks/DeleteFinished.py | 48 ++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 module/plugins/hooks/DeleteFinished.py

(limited to 'module/plugins')

diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py
new file mode 100644
index 000000000..6098db9a5
--- /dev/null
+++ b/module/plugins/hooks/DeleteFinished.py
@@ -0,0 +1,48 @@
+  # -*- coding: utf-8 -*-
+
+"""
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 3 of the License,
+    or (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+    See the GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+    @author: Walter Purcaro
+"""
+
+from module.plugins.Hook import Hook
+from time import time
+
+
+class DeleteFinished(Hook):
+    __name__ = "DeleteFinished"
+    __version__ = "0.1"
+    __description__ = "Automatically delete finished packages from queue"
+    __config__ = [
+        ("activated", "bool", "Activated", "False"),
+        ("interval", "int", "Delete every (hours)", "48")
+    ]
+    __author_name__ = ("Walter Purcaro")
+    __author_mail__ = ("vuolter@gmail.com")
+
+    event_map = {"periodical": "check"}
+
+    def check(self):
+        now = time.time()
+        deletetime = self.getConfig("interval") * 3600 + self.info["lastdelete"]
+        if now >= deletetime:
+            self.core.api.deleteFinished()
+            self.logDebug("called self.core.api.deleteFinished()")
+            self.info["lastdelete"] = now
+
+    def setup(self):
+        now = time.time()
+        self.info = {"lastdelete": now}
+        self.interval = 3600
-- 
cgit v1.2.3


From a133bdfe5e673479f3441afa7ae2f7c337753852 Mon Sep 17 00:00:00 2001
From: Vuolter <vuolter@gmail.com>
Date: Sat, 11 May 2013 19:28:38 +0200
Subject: Version 0.2: fixes

---
 module/plugins/hooks/DeleteFinished.py | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

(limited to 'module/plugins')

diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py
index 6098db9a5..be83d6ced 100644
--- a/module/plugins/hooks/DeleteFinished.py
+++ b/module/plugins/hooks/DeleteFinished.py
@@ -23,19 +23,18 @@ from time import time
 
 class DeleteFinished(Hook):
     __name__ = "DeleteFinished"
-    __version__ = "0.1"
+    __version__ = "0.2"
     __description__ = "Automatically delete finished packages from queue"
     __config__ = [
         ("activated", "bool", "Activated", "False"),
-        ("interval", "int", "Delete every (hours)", "48")
+        ("interval", "int", "Delete every (hours)", "72")
     ]
     __author_name__ = ("Walter Purcaro")
     __author_mail__ = ("vuolter@gmail.com")
 
-    event_map = {"periodical": "check"}
-
-    def check(self):
-        now = time.time()
+    #: event_map don't load periodical anyway
+    def periodical(self):
+        now = time()
         deletetime = self.getConfig("interval") * 3600 + self.info["lastdelete"]
         if now >= deletetime:
             self.core.api.deleteFinished()
@@ -43,6 +42,6 @@ class DeleteFinished(Hook):
             self.info["lastdelete"] = now
 
     def setup(self):
-        now = time.time()
+        now = time()
         self.info = {"lastdelete": now}
         self.interval = 3600
-- 
cgit v1.2.3