sms via sipgate working sipgate-sms-working
authorSandro Knauß <knauss@netzguerilla.net>
Sun, 07 Feb 2010 06:13:37 +0100
changeset 30 5253631a8dd3
parent 29 49ffb1f6cdbf
child 31 4d26236c51bd
sms via sipgate working
.hgignore
iro/anbieter/content.py
iro/anbieter/sipgate.py
iro/iro.py
iro/test.py
iro/user.py
--- a/.hgignore	Sun Feb 07 05:12:57 2010 +0100
+++ b/.hgignore	Sun Feb 07 06:13:37 2010 +0100
@@ -2,3 +2,7 @@
 *~
 *.pyc
 *.conf
+.*.swp
+*orig
+*.log
+MyIro
--- a/iro/anbieter/content.py	Sun Feb 07 05:12:57 2010 +0100
+++ b/iro/anbieter/content.py	Sun Feb 07 06:13:37 2010 +0100
@@ -15,11 +15,14 @@
 from email.header import Header
 
 class content:
-	def __init__(self,content):
-		self.content=content
-	
-	def sendto(self,anbieter,recipients):
-		pass
+    def __init__(self,content):
+        self.content=content
+
+    def sendto(self,anbieter,recipients):
+        pass
+
+    def getContent(self):
+        return self.content
 
 class SMS(content):
 	def __init__(self,cont):
--- a/iro/anbieter/sipgate.py	Sun Feb 07 05:12:57 2010 +0100
+++ b/iro/anbieter/sipgate.py	Sun Feb 07 06:13:37 2010 +0100
@@ -43,10 +43,10 @@
 
     def sendSMS(self,sms,recipients):
         """send SMS with $sms to $recipients"""
-        logger.debug('sipgate.sendSMS(%s,%s)'%(sms,  str(recipients)))
+        logger.debug('sipgate.sendSMS(%s,%s)'%(sms.getContent(),  str(recipients)))
         args={
                 "TOS" : "text",
-                "Content" : sms.content
+                "Content" : sms.getContent()
                 }
         self.__send(args,recipients)
 
@@ -94,9 +94,9 @@
         for recipient in recipients:
             try:
                 tel = telnumber(recipient)
-                
+
                 if tel in sended:                                                                           #only send message once per recipient
-                  continue
+                    continue
                 sended.append(tel)
 
                 args["RemoteUri"]="sip:%s%s@sipgate.net"%(tel.land,tel.number)
--- a/iro/iro.py	Sun Feb 07 05:12:57 2010 +0100
+++ b/iro/iro.py	Sun Feb 07 06:13:37 2010 +0100
@@ -14,7 +14,7 @@
 import logging,multiprocessing
 #logging anfangen
 logger=logging.getLogger("iro")
-logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)s(%(processName)s)-%(levelname)s: %(message)s')
+logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)s()-%(levelname)s: %(message)s')
 
 
 # Server code
--- a/iro/test.py	Sun Feb 07 05:12:57 2010 +0100
+++ b/iro/test.py	Sun Feb 07 06:13:37 2010 +0100
@@ -2,7 +2,7 @@
 
 import unittest, ConfigParser
 import iro
-from job import MessageJob
+from job import SMSJob, FAXJob, MailJob
 from joblist import Joblist
 from providerlist import Providerlist
 import threading, xmlrpclib
@@ -38,7 +38,10 @@
     class MyManager(BaseManager):
         pass
     
-    MyManager.register('MessageJob', MessageJob) 
+    MyManager.register('SMSJob', SMSJob) 
+    MyManager.register('FAXob', FAXJob) 
+    MyManager.register('MailJob',MailJob) 
+    MyManager.register('Providerlist',Providerlist) 
     manager = MyManager()
     manager.start()
     
@@ -120,8 +123,8 @@
         self.assertEqual(admin.status(),{id1: {'status': ['init',{}], 'name':   'test'},
                         id2: {'status': ['init',{}], 'name':   'test2'}} )
         
-        self.assertRaises(xmlrpclib.Fault, client2.status, id1)
-        self.assertRaises(xmlrpclib.Fault, client1.status, id2)
+        self.assertEqual(client2.status(id1), {})
+        self.assertEqual(client1.status(id2), {})
         
     def testGetProvider(self):
         servstr="https://test:test@localhost:8000"
--- a/iro/user.py	Sun Feb 07 05:12:57 2010 +0100
+++ b/iro/user.py	Sun Feb 07 06:13:37 2010 +0100
@@ -72,7 +72,7 @@
             job=self.jobs[id]
             job.stop()
         except:
-            raise String("No Job with ID: %i" %(id))
+            raise NoID(id)
         job.stop()