iro/user.py
changeset 6 c5672760138b
parent 0 a3b6e531f0d2
child 7 07dd2663ac90
equal deleted inserted replaced
5:af2f45da3192 6:c5672760138b
     8 #without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     8 #without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
     9 #See the GNU General Public License for more details.
     9 #See the GNU General Public License for more details.
    10 
    10 
    11 #You should have received a copy of the GNU General Public License
    11 #You should have received a copy of the GNU General Public License
    12 #along with this program; if not, see <http://www.gnu.org/licenses/>.
    12 #along with this program; if not, see <http://www.gnu.org/licenses/>.
       
    13 
       
    14 class NotSupportedFeature (Exception):
       
    15     def __init__(self,name):
       
    16         self.name=name
       
    17     
       
    18     def __str__(self):
       
    19         return ("This is not a supported feature:", self.name)
       
    20 
    13 class User: 
    21 class User: 
    14     '''
    22     '''
    15     class for a xmlrpc user
    23     class for a xmlrpc user
    16     '''
    24     '''
    17     def __init__(self,jobqueue):
    25     def __init__(self,jobqueue):
    18         self.jobqueue=jobqueue
    26         self.jobqueue=jobqueue
    19         self.jobs={}
    27         self.jobs={}
       
    28         self.features=["mail", "sms", "fax", ]
    20 
    29 
    21     def status(self,id=None,detailed=False):
    30     def status(self,id=None,detailed=False):
    22         '''
    31         '''
    23         gets the status for a job
    32         gets the status for a job
    24         if the id is None all Jobs of an user are given back
    33         if the id is None all Jobs of an user are given back
    51     
    60     
    52     def startSMS(self,message,recipients):
    61     def startSMS(self,message,recipients):
    53         '''
    62         '''
    54         starts the SMS with message to recipients
    63         starts the SMS with message to recipients
    55         '''
    64         '''
       
    65         if not "sms" in self.features:
       
    66             raise NotSupportedFeature("sms")
    56         id = self.jobqueue.newSMS(message,recipients)
    67         id = self.jobqueue.newSMS(message,recipients)
    57         self.jobs[id]=self.jobqueue[id]
    68         self.jobs[id]=self.jobqueue[id]
    58         return id
    69         return id
    59         
    70     
       
    71     
       
    72     def startFAX(self):
       
    73         '''
       
    74         starts the FAX - not implemented
       
    75         '''
       
    76         raise NotSupportedFeature("fax")
       
    77 
       
    78     
    60         
    79         
    61     def startMail(self,subject,  body , recipients):
    80     def startMail(self,subject,  body , recipients):
       
    81         if not "mail" in self.features:
       
    82             raise NotSupportedFeature("mail")
    62         id = self.jobqueue.newMail(subject,  body ,recipients)
    83         id = self.jobqueue.newMail(subject,  body ,recipients)
    63         self.jobs[id]=self.jobqueue[id]
    84         self.jobs[id]=self.jobqueue[id]
    64         return id     
    85         return id    
       
    86        
       
    87     def getProvider(self, name):
       
    88         if not name in self.features:
       
    89             raise NotSupportedFeature(name)
    65         
    90         
    66 class Admin(User):
    91 class Admin(User):
    67     def __init__(self,jobqueue):
    92     def __init__(self,jobqueue):
    68         User.__init__(self, jobqueue)
    93         User.__init__(self, jobqueue)
    69         self.jobs=jobqueue.jobs
    94         self.jobs=jobqueue.jobs