--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/iro/job.py Wed Oct 28 02:35:01 2009 +0100
@@ -0,0 +1,79 @@
+# -*- coding: utf-8 -*-
+#Copyright (C) 2009 Sandro Knauß <bugs@sandroknauss.de>
+
+#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 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/>.
+
+
+class Job(object):
+ '''
+ Basic class for all jobs
+ '''
+ def __init__(self,provider,name):
+ self.provider=provider
+ self.name=name
+ self.status = "init"
+ self.dStatus={"good":[], "failed":[]}
+
+ def start(self):
+ self.status = "started"
+
+ def stop(self):
+ self.status = "stopped"
+
+ def getStatus(self,detailed):
+ if detailed and self.status == "started" or self.status == "sended":
+ return self.status, self.dStatus
+ return self.status, {}
+
+ def getName(self):
+ return self.name
+
+ def getProvider(self):
+ return self.provider
+
+ def addGood(self, good):
+ if type(good) == list:
+ self.dStatus['good']=self.dStatus['good']+good
+ else:
+ self.dStatus['good'].append(good)
+
+ def addFailed(self, failed):
+ if type(failed) == list:
+ self.dStatus['failed']=self.dStatus['failed']+failed
+ else:
+ self.dStatus['failed'].append(failed)
+
+class MessageJob(Job):
+ '''
+ A specialized class for smsjobs
+ '''
+ def __init__(self,provider,name, message,recipients):
+ self.message=message
+ self.recipients=recipients
+ Job.__init__(self,provider, name)
+
+ def stop(self):
+ pass
+
+ def start(self):
+ Job.start(self)
+ self.provider.setJob(self)
+ self.message.sendto(self.provider, self.recipients)
+ self.status="sended"
+
+ def getMessage(self):
+ return self.message
+
+ def getRecipients(self):
+ return self.recipients
+
+
+