merging fax
authorSandro Knauß <knauss@netzguerilla.net>
Sun, 07 Feb 2010 05:12:57 +0100
changeset 29 49ffb1f6cdbf
parent 28 cf54cc3373f2 (diff)
parent 26 f6eb3f425b0c (current diff)
child 30 5253631a8dd3
child 33 2b3f1b9a1e48
merging fax
iro/user.py
--- a/iro/.eric4project/iro.e4q	Sun Nov 15 19:08:08 2009 +0100
+++ b/iro/.eric4project/iro.e4q	Sun Feb 07 05:12:57 2010 +0100
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE UserProject SYSTEM "UserProject-4.0.dtd">
 <!-- eric4 user project file for project iro -->
-<!-- Saved: 2009-11-13, 01:39:58 -->
+<!-- Saved: 2009-11-24, 02:01:06 -->
 <!-- Copyright (C) 2009 Sandro Knauß, bugs@sandroknauss.de -->
 <UserProject version="4.0">
 </UserProject>
\ No newline at end of file
--- a/iro/.eric4project/iro.e4t	Sun Nov 15 19:08:08 2009 +0100
+++ b/iro/.eric4project/iro.e4t	Sun Feb 07 05:12:57 2010 +0100
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE Tasks SYSTEM "Tasks-4.2.dtd">
 <!-- eric4 tasks file for project iro -->
-<!-- Saved: 2009-11-13, 01:39:58 -->
+<!-- Saved: 2009-11-24, 02:01:07 -->
 <Tasks version="4.2">
 </Tasks>
\ No newline at end of file
--- a/iro/MyIro_daemon	Sun Nov 15 19:08:08 2009 +0100
+++ b/iro/MyIro_daemon	Sun Feb 07 05:12:57 2010 +0100
@@ -1,6 +1,6 @@
 #! /bin/sh
 NAME="IRO"
-DEAMON=/home/sandy/svn/daemon/MyIro
+DEAMON=/home/sandy/svn/iro/MyIro
 DEAMON_OPTS=""
 PID=/home/sandy/var/run/$NAME.pid
 
--- a/iro/anbieter/content.py	Sun Nov 15 19:08:08 2009 +0100
+++ b/iro/anbieter/content.py	Sun Feb 07 05:12:57 2010 +0100
@@ -12,6 +12,7 @@
 #along with this program; if not, see <http://www.gnu.org/licenses/>.
 
 from email.mime.text import MIMEText
+from email.header import Header
 
 class content:
 	def __init__(self,content):
@@ -38,8 +39,9 @@
 
 class Mail(content):
     def __init__(self, subject, body):
-        con=MIMEText(body)
-        con['Subject']=subject
+        con=MIMEText(body.encode("utf-8"), _charset='utf-8')
+        sub=Header(subject.encode('utf-8'), 'utf-8')
+        con['Subject']=sub
         content.__init__(self, con)
   
     def sendto(self,anbieter,recipients):
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/iro/anbieter/gsm0338.py	Sun Feb 07 05:12:57 2010 +0100
@@ -0,0 +1,192 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+import codecs
+import _multibytecodec as mbc 
+
+ENCODING_NAME = "gsm0338"
+
+decoding_map= {
+unichr(0x00):unichr(0x0040), # COMMERCIAL AT
+unichr(0x01):unichr(0x00A3), # POUND SIGN
+unichr(0x02):unichr(0x0024), # DOLLAR SIGN
+unichr(0x03):unichr(0x00A5), # YEN SIGN
+unichr(0x04):unichr(0x00E8), # LATIN SMALL LETTER E WITH GRAVE
+unichr(0x05):unichr(0x00E9), # LATIN SMALL LETTER E WITH ACUTE
+unichr(0x06):unichr(0x00F9), # LATIN SMALL LETTER U WITH GRAVE
+unichr(0x07):unichr(0x00EC), # LATIN SMALL LETTER I WITH GRAVE
+unichr(0x08):unichr(0x00F2), # LATIN SMALL LETTER O WITH GRAVE
+unichr(0x09):unichr(0x00E7), # LATIN SMALL LETTER C WITH CEDILLA
+unichr(0x0A):unichr(0x000A), # LINE FEED
+unichr(0x0B):unichr(0x00D8), # LATIN CAPITAL LETTER O WITH STROKE
+unichr(0x0C):unichr(0x00F8), # LATIN SMALL LETTER O WITH STROKE
+unichr(0x0D):unichr(0x000D), # CARRIAGE RETURN
+unichr(0x0E):unichr(0x00C5), # LATIN CAPITAL LETTER A WITH RING ABOVE
+unichr(0x0F):unichr(0x00E5), # LATIN SMALL LETTER A WITH RING ABOVE
+unichr(0x10):unichr(0x0394), # GREEK CAPITAL LETTER DELTA
+unichr(0x11):unichr(0x005F), # LOW LINE
+unichr(0x12):unichr(0x03A6), # GREEK CAPITAL LETTER PHI
+unichr(0x13):unichr(0x0393), # GREEK CAPITAL LETTER GAMMA
+unichr(0x14):unichr(0x039B), # GREEK CAPITAL LETTER LAMDA
+unichr(0x15):unichr(0x03A9), # GREEK CAPITAL LETTER OMEGA
+unichr(0x16):unichr(0x03A0), # GREEK CAPITAL LETTER PI
+unichr(0x17):unichr(0x03A8), # GREEK CAPITAL LETTER PSI
+unichr(0x18):unichr(0x03A3), # GREEK CAPITAL LETTER SIGMA
+unichr(0x19):unichr(0x0398), # GREEK CAPITAL LETTER THETA
+unichr(0x1A):unichr(0x039E), # GREEK CAPITAL LETTER XI
+unichr(0x1B):unichr(0x00A0), # ESCAPE TO EXTENSION TABLE (or displayed as NBSP, see note above)
+unichr(0x1B0A):unichr(0x000C), # FORM FEED
+unichr(0x1B14):unichr(0x005E), # CIRCUMFLEX ACCENT
+unichr(0x1B28):unichr(0x007B), # LEFT CURLY BRACKET
+unichr(0x1B29):unichr(0x007D), # RIGHT CURLY BRACKET
+unichr(0x1B2F):unichr(0x005C), # REVERSE SOLIDUS
+unichr(0x1B3C):unichr(0x005B), # LEFT SQUARE BRACKET
+unichr(0x1B3D):unichr(0x007E), # TILDE
+unichr(0x1B3E):unichr(0x005D), # RIGHT SQUARE BRACKET
+unichr(0x1B40):unichr(0x007C), # VERTICAL LINE
+unichr(0x1B65):unichr(0x20AC), # EURO SIGN
+unichr(0x1C):unichr(0x00C6), # LATIN CAPITAL LETTER AE
+unichr(0x1D):unichr(0x00E6), # LATIN SMALL LETTER AE
+unichr(0x1E):unichr(0x00DF), # LATIN SMALL LETTER SHARP S (German)
+unichr(0x1F):unichr(0x00C9), # LATIN CAPITAL LETTER E WITH ACUTE
+unichr(0x20):unichr(0x0020), # SPACE
+unichr(0x21):unichr(0x0021), # EXCLAMATION MARK
+unichr(0x22):unichr(0x0022), # QUOTATION MARK
+unichr(0x23):unichr(0x0023), # NUMBER SIGN
+unichr(0x24):unichr(0x00A4), # CURRENCY SIGN
+unichr(0x25):unichr(0x0025), # PERCENT SIGN
+unichr(0x26):unichr(0x0026), # AMPERSAND
+unichr(0x27):unichr(0x0027), # APOSTROPHE
+unichr(0x28):unichr(0x0028), # LEFT PARENTHESIS
+unichr(0x29):unichr(0x0029), # RIGHT PARENTHESIS
+unichr(0x2A):unichr(0x002A), # ASTERISK
+unichr(0x2B):unichr(0x002B), # PLUS SIGN
+unichr(0x2C):unichr(0x002C), # COMMA
+unichr(0x2D):unichr(0x002D), # HYPHEN-MINUS
+unichr(0x2E):unichr(0x002E), # FULL STOP
+unichr(0x2F):unichr(0x002F), # SOLIDUS
+unichr(0x30):unichr(0x0030), # DIGIT ZERO
+unichr(0x31):unichr(0x0031), # DIGIT ONE
+unichr(0x32):unichr(0x0032), # DIGIT TWO
+unichr(0x33):unichr(0x0033), # DIGIT THREE
+unichr(0x34):unichr(0x0034), # DIGIT FOUR
+unichr(0x35):unichr(0x0035), # DIGIT FIVE
+unichr(0x36):unichr(0x0036), # DIGIT SIX
+unichr(0x37):unichr(0x0037), # DIGIT SEVEN
+unichr(0x38):unichr(0x0038), # DIGIT EIGHT
+unichr(0x39):unichr(0x0039), # DIGIT NINE
+unichr(0x3A):unichr(0x003A), # COLON
+unichr(0x3B):unichr(0x003B), # SEMICOLON
+unichr(0x3C):unichr(0x003C), # LESS-THAN SIGN
+unichr(0x3D):unichr(0x003D), # EQUALS SIGN
+unichr(0x3E):unichr(0x003E), # GREATER-THAN SIGN
+unichr(0x3F):unichr(0x003F), # QUESTION MARK
+unichr(0x40):unichr(0x00A1), # INVERTED EXCLAMATION MARK
+unichr(0x41):unichr(0x0041), # LATIN CAPITAL LETTER A
+unichr(0x42):unichr(0x0042), # LATIN CAPITAL LETTER B
+unichr(0x43):unichr(0x0043), # LATIN CAPITAL LETTER C
+unichr(0x44):unichr(0x0044), # LATIN CAPITAL LETTER D
+unichr(0x45):unichr(0x0045), # LATIN CAPITAL LETTER E
+unichr(0x46):unichr(0x0046), # LATIN CAPITAL LETTER F
+unichr(0x47):unichr(0x0047), # LATIN CAPITAL LETTER G
+unichr(0x48):unichr(0x0048), # LATIN CAPITAL LETTER H
+unichr(0x49):unichr(0x0049), # LATIN CAPITAL LETTER I
+unichr(0x4A):unichr(0x004A), # LATIN CAPITAL LETTER J
+unichr(0x4B):unichr(0x004B), # LATIN CAPITAL LETTER K
+unichr(0x4C):unichr(0x004C), # LATIN CAPITAL LETTER L
+unichr(0x4D):unichr(0x004D), # LATIN CAPITAL LETTER M
+unichr(0x4E):unichr(0x004E), # LATIN CAPITAL LETTER N
+unichr(0x4F):unichr(0x004F), # LATIN CAPITAL LETTER O
+unichr(0x50):unichr(0x0050), # LATIN CAPITAL LETTER P
+unichr(0x51):unichr(0x0051), # LATIN CAPITAL LETTER Q
+unichr(0x52):unichr(0x0052), # LATIN CAPITAL LETTER R
+unichr(0x53):unichr(0x0053), # LATIN CAPITAL LETTER S
+unichr(0x54):unichr(0x0054), # LATIN CAPITAL LETTER T
+unichr(0x55):unichr(0x0055), # LATIN CAPITAL LETTER U
+unichr(0x56):unichr(0x0056), # LATIN CAPITAL LETTER V
+unichr(0x57):unichr(0x0057), # LATIN CAPITAL LETTER W
+unichr(0x58):unichr(0x0058), # LATIN CAPITAL LETTER X
+unichr(0x59):unichr(0x0059), # LATIN CAPITAL LETTER Y
+unichr(0x5A):unichr(0x005A), # LATIN CAPITAL LETTER Z
+unichr(0x5B):unichr(0x00C4), # LATIN CAPITAL LETTER A WITH DIAERESIS
+unichr(0x5C):unichr(0x00D6), # LATIN CAPITAL LETTER O WITH DIAERESIS
+unichr(0x5D):unichr(0x00D1), # LATIN CAPITAL LETTER N WITH TILDE
+unichr(0x5E):unichr(0x00DC), # LATIN CAPITAL LETTER U WITH DIAERESIS
+unichr(0x5F):unichr(0x00A7), # SECTION SIGN
+unichr(0x60):unichr(0x00BF), # INVERTED QUESTION MARK
+unichr(0x61):unichr(0x0061), # LATIN SMALL LETTER A
+unichr(0x62):unichr(0x0062), # LATIN SMALL LETTER B
+unichr(0x63):unichr(0x0063), # LATIN SMALL LETTER C
+unichr(0x64):unichr(0x0064), # LATIN SMALL LETTER D
+unichr(0x65):unichr(0x0065), # LATIN SMALL LETTER E
+unichr(0x66):unichr(0x0066), # LATIN SMALL LETTER F
+unichr(0x67):unichr(0x0067), # LATIN SMALL LETTER G
+unichr(0x68):unichr(0x0068), # LATIN SMALL LETTER H
+unichr(0x69):unichr(0x0069), # LATIN SMALL LETTER I
+unichr(0x6A):unichr(0x006A), # LATIN SMALL LETTER J
+unichr(0x6B):unichr(0x006B), # LATIN SMALL LETTER K
+unichr(0x6C):unichr(0x006C), # LATIN SMALL LETTER L
+unichr(0x6D):unichr(0x006D), # LATIN SMALL LETTER M
+unichr(0x6E):unichr(0x006E), # LATIN SMALL LETTER N
+unichr(0x6F):unichr(0x006F), # LATIN SMALL LETTER O
+unichr(0x70):unichr(0x0070), # LATIN SMALL LETTER P
+unichr(0x71):unichr(0x0071), # LATIN SMALL LETTER Q
+unichr(0x72):unichr(0x0072), # LATIN SMALL LETTER R
+unichr(0x73):unichr(0x0073), # LATIN SMALL LETTER S
+unichr(0x74):unichr(0x0074), # LATIN SMALL LETTER T
+unichr(0x75):unichr(0x0075), # LATIN SMALL LETTER U
+unichr(0x76):unichr(0x0076), # LATIN SMALL LETTER V
+unichr(0x77):unichr(0x0077), # LATIN SMALL LETTER W
+unichr(0x78):unichr(0x0078), # LATIN SMALL LETTER X
+unichr(0x79):unichr(0x0079), # LATIN SMALL LETTER Y
+unichr(0x7A):unichr(0x007A), # LATIN SMALL LETTER Z
+unichr(0x7B):unichr(0x00E4), # LATIN SMALL LETTER A WITH DIAERESIS
+unichr(0x7C):unichr(0x00F6), # LATIN SMALL LETTER O WITH DIAERESIS
+unichr(0x7D):unichr(0x00F1), # LATIN SMALL LETTER N WITH TILDE
+unichr(0x7E):unichr(0x00FC), # LATIN SMALL LETTER U WITH DIAERESIS
+unichr(0x7F):unichr(0x00E0), # LATIN SMALL LETTER A WITH GRAVE
+}
+
+encoding_map=dict([(v,k) for (k,v) in decoding_map.items()])
+
+class Codec(codecs.Codec):
+	def encode(self,input,errors='strict'):
+		ret=""
+		for i in input:
+		  ret+=encoding_map[i]
+		return (ret,len(ret))
+	def decode(self,input,errors='strict'):
+		ret=""
+		for i in input:
+		  ret+=decoding_map[i]
+		return (ret,len(ret))
+
+
+
+class StreamWriter(Codec,mbc.MultibyteStreamWriter,codecs.StreamWriter):
+    pass
+
+class StreamReader(Codec,mbc.MultibyteStreamReader,codecs.StreamReader):
+    pass
+
+### encodings module API
+
+def getregentry():
+	return (Codec().encode,Codec().decode,StreamReader,StreamWriter)
+
+
+def gsm_search(encoding):
+	if not encoding == ENCODING_NAME:
+		return
+	return getregentry()
+	
+# Register our codec when we load the module
+codecs.register(gsm_search)
+
+if __name__ == "__main__":
+	text = "€öäüß"
+	text2 = unicode(text,"utf-8").encode("gsm0338")
+	assert(text2==u"\u1B65\x7C\x7B\x7E\x1E")
+	text=""
+	text2 = unicode(text,"utf-8").encode("gsm0338")
+	assert(text==text2)
+
--- a/iro/anbieter/sipgate.py	Sun Nov 15 19:08:08 2009 +0100
+++ b/iro/anbieter/sipgate.py	Sun Feb 07 05:12:57 2010 +0100
@@ -17,6 +17,8 @@
 import ConfigParser
 import xmlrpclib
 import base64
+import logging
+logger=logging.getLogger("sipgate")
 
 class NoValidStatusCode(Exception):
     pass
@@ -41,6 +43,7 @@
 
     def sendSMS(self,sms,recipients):
         """send SMS with $sms to $recipients"""
+        logger.debug('sipgate.sendSMS(%s,%s)'%(sms,  str(recipients)))
         args={
                 "TOS" : "text",
                 "Content" : sms.content
@@ -49,6 +52,7 @@
 
     def sendFAX(self,fax,recipients):
         """send the PDF file $fax  to $recipients"""
+        logger.debug('sipgate.sendFAX(%s,%s)'%(fax,  str(recipients)))
         pdf=open(fax.attachments[0],"rb")
         args={
                 "TOS" : "fax",
--- a/iro/anbieter/smstrade.py	Sun Nov 15 19:08:08 2009 +0100
+++ b/iro/anbieter/smstrade.py	Sun Feb 07 05:12:57 2010 +0100
@@ -18,8 +18,12 @@
 import ConfigParser
 import xmlrpclib
 import base64
+import gsm0338
 import urllib, httplib
 
+import logging
+logger=logging.getLogger("smstrade")
+
 class UnknownStatusCode(Exception):
     def __init__(self,code):
         self.code=code
@@ -87,11 +91,10 @@
 
     def sendSMS(self,sms,recipients):
         """send SMS with $sms to $recipients"""
+        logger.debug('smstrade.sendSMS(%s,%s)'%(sms,  str(recipients)))
         sended = []
-        key = self.key
         route = unicode(self.route)
-        message = unicode(sms.content)
-        from_ = unicode(self.from_)
+        message = sms.content
         timestamp = None
         for recipient in recipients:
             try:
@@ -99,8 +102,13 @@
                 if tel in sended:                                             #only send message once per recipient
                     continue
                 sended.append(tel)	
-                to = unicode((tel.number)).strip()						                
-                smsSendStatus = self.__send(key, route, to, message, from_, timestamp)	
+                to ='00'+tel.land+tel.number
+                if tel.land == '49':
+                    route=unicode("basic")
+                else:
+                    route=unicode("economy")
+                smsSendStatus = self.__send(route, to, message, timestamp)	
+                logger.debug('smstrade._send(...)=%i(%s)'%(int(smsSendStatus),str(smsSendStatus)))
                 if int(smsSendStatus) in(100, 999):
                     self.updateStatus(arranged=recipient)
                 else:
@@ -108,39 +116,40 @@
             except (NotATelNumber,NoValidStatusCode,InternetConnectionError):
                 self.updateStatus(failed=recipient)
 
-    def __send(self, key, route, to, message, from_=None, timestamp=None):
+    def __send(self, route, to, message,  timestamp=None):
         """ This function is the main part of the request to the sms service.    
         The function has to return a unicode formated string that will represent the answer of the sms service
         to the request."""
-        parameters= {"key": key,
+        logger.debug('smstrade._send(%s,%s,%s,%s)'%( route, to, message, timestamp))
+        parameters= {"key": self.key,
                 "route": route,
                 "to": to,
                 "message": message,
+                "charset":"utf-8", 
                 "debug": self.debug,
                 }
         
-        if from_ is not None:
-            parameters["from"] = from_
+        if self.from_ is not None:
+            parameters["from"] = self.from_
         
         if timestamp is not None:
             parameters["senddate"] = unicode(timestamp)
 
         parameters["concat_sms"] = "1" if len(message) > 160 else "0"
-
-        params = urllib.urlencode(dict([k, v.encode('iso-8859-1')] for k, v in parameters.items()))
+        params = "&".join( ["%s=%s" % (urllib.quote(k),urllib.quote(v.encode("utf-8"))) for (k, v) in parameters.items()])
+        logger.debug('smstrade._send-parameters:%s\n\t->%s'%(str(parameters), str(params)) )
         headers = {"Content-type": "application/x-www-form-urlencoded",
             "Accept": "text/plain"}
         conn = httplib.HTTPConnection("%s:%i" % (self.gateway, self.gatewayPort))
         try:
             conn.request(self.method, self.script, params, headers)
             response = conn.getresponse()
-
             data = response.read()
         except socket.gaierror:
             raise InternetConnectionError("%s:%i" % (self.gateway, self.gatewayPort))
-        else:
+        finally:
             conn.close()
-
+            
         try:
             return StatusCode(int(data))
         except UnknownStatusCode:
--- a/iro/anbieter/smtp.py	Sun Nov 15 19:08:08 2009 +0100
+++ b/iro/anbieter/smtp.py	Sun Feb 07 05:12:57 2010 +0100
@@ -15,7 +15,8 @@
     default_conf = ''    # override this
 import smtplib
 import ConfigParser
-
+import logging
+logger=logging.getLogger("SMTP")
 
 class SMTP():
     def __init__(self,config_filename=None,section="smtp"):
@@ -25,6 +26,7 @@
         self.bTLS=False
         self.bSSL=False
         self.max_recipients=1
+        
 
     def read_basic_config(self,config_filename=None):
         """Read basic options from the config file"""
@@ -50,7 +52,6 @@
         except ValueError:
             self.bSSL=False
 
-
     def prepareSMTP(self):
         if self.bSSL:
             self.smtp = smtplib.SMTP_SSL(self.host,self.port)
@@ -66,18 +67,21 @@
         self.bStart=True
 
     def sendMail(self,mail,recipients):   
+        logger.debug('SMTP.sendMail(%s,%s)'%(mail,  str(recipients)))
         if not self.bStart:
             self.prepareSMTP()
 
         mail.content['From']=self.send_from
+        
         while len(recipients) > 0:
             tmp_recipients=recipients[:self.max_recipients]
-            print tmp_recipients
+            mail.content['To']=", ".join(tmp_recipients)
+            logger.debug('self.smtp.sendmail(%s,%s,%s)'%(self.send_from,  str(tmp_recipients), mail.as_string()))
             self.smtp.sendmail(self.send_from,  tmp_recipients, mail.as_string())
             self.updateStatus( arranged=tmp_recipients)
             recipients = recipients[self.max_recipients:]
         
-        self.smtp.shutdownSMTP()
+        self.shutdownSMTP()
 
 
     def updateStatus(self, arranged=None, failed=None):
--- a/iro/iro.e4p	Sun Nov 15 19:08:08 2009 +0100
+++ b/iro/iro.e4p	Sun Feb 07 05:12:57 2010 +0100
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE Project SYSTEM "Project-4.6.dtd">
 <!-- eric4 project file for project iro -->
-<!-- Saved: 2009-11-13, 01:39:58 -->
+<!-- Saved: 2009-11-23, 00:15:34 -->
 <!-- Copyright (C) 2009 Sandro Knauß, bugs@sandroknauss.de -->
 <Project version="4.6">
   <Language></Language>
@@ -18,21 +18,23 @@
     <Source>xmlrpc/__init__.py</Source>
     <Source>xmlrpc/SecureAuthentificateXMLRPCServer.py</Source>
     <Source>xmlrpc/AuthentificateXMLRPCServer.py</Source>
-    <Source>anbieter/smtp.py</Source>
-    <Source>anbieter/geonet.py</Source>
-    <Source>anbieter/__init__.py</Source>
-    <Source>anbieter/FAX_de.py</Source>
-    <Source>anbieter/sipgate.py</Source>
-    <Source>anbieter/anbieter.py</Source>
     <Source>xmlrpc/SecureUserdbXMLRPCServer.py</Source>
     <Source>worker.py</Source>
     <Source>user.py</Source>
-    <Source>anbieter/telnumber.py</Source>
-    <Source>anbieter/test.py</Source>
     <Source>test.py</Source>
     <Source>providerlist.py</Source>
     <Source>joblist.py</Source>
     <Source>job.py</Source>
+    <Source>anbieter/smtp.py</Source>
+    <Source>anbieter/geonet.py</Source>
+    <Source>anbieter/content.py</Source>
+    <Source>anbieter/__init__.py</Source>
+    <Source>anbieter/telnumber.py</Source>
+    <Source>anbieter/test.py</Source>
+    <Source>anbieter/FAX_de.py</Source>
+    <Source>anbieter/sipgate.py</Source>
+    <Source>anbieter/gsm0338.py</Source>
+    <Source>anbieter/anbieter.py</Source>
     <Source>anbieter/smstrade.py</Source>
   </Sources>
   <Forms>
--- a/iro/iro.py	Sun Nov 15 19:08:08 2009 +0100
+++ b/iro/iro.py	Sun Feb 07 05:12:57 2010 +0100
@@ -11,8 +11,13 @@
 #You should have received a copy of the GNU General Public License
 #along with this program; if not, see <http://www.gnu.org/licenses/>.
 
+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')
+
+
 # Server code
-
 from xmlrpc import SecureUserDBXMLRPCServer,UserDB
 
 from user import User, Admin
@@ -83,13 +88,15 @@
 def start(userlist):
     from multiprocessing import Queue
     from multiprocessing.managers import BaseManager
+    import multiprocessing, logging
+
     
     class MyManager(BaseManager):
         pass
     
     MyManager.register('SMSJob', SMSJob) 
     MyManager.register('FAXob', FAXJob) 
-    MyManager.register('MailJob',FAXJob) 
+    MyManager.register('MailJob',MailJob) 
     MyManager.register('Providerlist',Providerlist) 
     manager = MyManager()
     manager.start()
@@ -111,8 +118,8 @@
     provider=manager.Providerlist()
     provider.add("sipgate", sip, ["sms", "fax", ])
     provider.add("smstrade", smstrade, ["sms", ])
-    provider.add("geonet", None, ["sms", "fax", ])
-    provider.add("fax.de", None, ["sms", "fax", ])
+    #provider.add("geonet", None, ["sms", "fax", ])
+    #provider.add("fax.de", None, ["sms", "fax", ])
     provider.add("localhost", localhost, ["mail", ])
     provider.setDefault("sms","smstrade")
     provider.setDefault("fax","sipgate")
@@ -136,10 +143,17 @@
                                       certificate=cert,privatekey=key)
     server.relam="xmlrpc"
     
-    print "Server started..."
-    server.serve_forever()
-    
-    worker.terminate()
+    logger.info('Server gestartet...')
+    try:
+        server.serve_forever()
+    except KeyboardInterrupt:
+        pass
+    except:
+        logger.exception('Äh, ein Fehler ist aufgetreten')
+    finally:    
+        logger.info('Server wird beendet...')
+        queue.close()
+        worker.terminate()
 
 if __name__ == '__main__':
     userlist=[{"name":"test","password":"test",  "class":User},
--- a/iro/job.py	Sun Nov 15 19:08:08 2009 +0100
+++ b/iro/job.py	Sun Feb 07 05:12:57 2010 +0100
@@ -11,6 +11,8 @@
 #You should have received a copy of the GNU General Public License
 #along with this program; if not, see <http://www.gnu.org/licenses/>.
 
+import logging
+logger=logging.getLogger("job")
 
 class Job(object):
     '''
@@ -22,6 +24,7 @@
         self.name=name
         self.status = "init"
         self.dStatus={"good":[], "failed":[]}
+        self.id=None
 
     def start(self):
         self.status = "started"
@@ -41,12 +44,14 @@
         return None
         
     def addGood(self, good):
+        logger.debug('Job(%d)-send to %s'%(self.id, str(good)))
         if type(good) == list:
             self.dStatus['good']=self.dStatus['good']+good
         else:
             self.dStatus['good'].append(good)
     
     def addFailed(self, failed):
+        logger.debug('Job(%d)-faild to send to %s'%(self.id, str(failed)))
         if type(failed) == list:
             self.dStatus['failed']=self.dStatus['failed']+failed
         else:
@@ -64,9 +69,8 @@
     def stop(self):
         pass
     
-
-    
-    def start(self):
+    def start(self, id=None):
+        self.id=id
         Job.start(self)
         self.getProvider().setJob(self)
         self.message.sendto(self.getProvider(), self.recipients)
@@ -85,9 +89,6 @@
         
     def getProvider(self):
         return self.providerlist.getProvider("sms", self.provider)
-        
-    def start(self):
-        MessageJob.start(self)
 
 class FAXJob(MessageJob):
     def __init__(self,providerlist,provider, name, message,recipients):
--- a/iro/merlin_daemon	Sun Nov 15 19:08:08 2009 +0100
+++ b/iro/merlin_daemon	Sun Feb 07 05:12:57 2010 +0100
@@ -1,6 +1,6 @@
 #! /bin/sh
 NAME="merlin"
-DEAMON=/home/sandy/svn/daemon/$NAME
+DEAMON=/home/sandy/svn/iro/$NAME
 DEAMON_OPTS="/home/sandy/svn/iro/MyIro_daemon"
 PID=/home/sandy/var/run/$NAME.pid
 
--- a/iro/user.py	Sun Nov 15 19:08:08 2009 +0100
+++ b/iro/user.py	Sun Feb 07 05:12:57 2010 +0100
@@ -10,7 +10,8 @@
 
 #You should have received a copy of the GNU General Public License
 #along with this program; if not, see <http://www.gnu.org/licenses/>.
-
+import logging
+logger=logging.getLogger("iro.user")
 class NotSupportedFeature (Exception):
     def __init__(self,name):
         self.name=name
@@ -18,6 +19,14 @@
     def __str__(self):
         return ("This is not a supported feature:", self.name)
 
+class NoID(Exception):
+    def __init__(self,i):
+        self.i=i
+    
+    def __str__(self):
+        return ("No Job with id:", self.i)
+
+
 class User: 
     '''
     class for a xmlrpc user
@@ -32,19 +41,28 @@
         gets the status for a job
         if the id is None all Jobs of an user are given back
         '''
-        if id==None:
-            jobs=self.jobs
-        else:
-            try:
-                jobs={id:self.jobs[id]}
-            except:
-                raise String("No Job with ID: %i" %(id))
-        ret={}
-        for key in jobs:
-            job=jobs[key]
-            ret[key]={"name":job.getName(),"status":job.getStatus(detailed)}
-        
-        return ret
+        try:
+            jobs={}
+            if id==None:
+                jobs=self.jobs
+            else:
+                try:
+                    jobs={id:self.jobs[id]}
+                except:
+                    logger.error("No Job ID %s",id)
+                    #raise NoID(id)
+            ret={}
+            if not jobs:
+                return {}
+
+            for key in jobs:
+                job=jobs[key]
+                ret[key]={"name":job.getName(),"status":job.getStatus(detailed)}
+            
+            return ret
+        except:
+            logger.exception("Fehler in iro.user.status")
+            return {}
 
     def stop(self,id):
         '''
--- a/iro/worker.py	Sun Nov 15 19:08:08 2009 +0100
+++ b/iro/worker.py	Sun Feb 07 05:12:57 2010 +0100
@@ -2,6 +2,8 @@
 # Worker code
 
 from multiprocessing import Process
+import logging
+logger = logging.getLogger("iro.worker")
 import time
 
 class Worker(Process):
@@ -10,8 +12,16 @@
         self.queue=queue
         
     def run(self):
+        logger.info('Worker thread läuft nun...')
+        id=0
         while 1:
             job=self.queue.get()
             if job is None:
                 break # reached end of queue
-            job.start()
+            id+=1
+            logger.info('ein neuer Job(%d)' %(id))
+            try:
+                job.start(id)
+                logger.info('Job(%d) fertig ;)'%(id))
+            except:
+                logger.exception('Job(%d) fehlgeschlagen :('%(id))