diff -r b31978c0c043 -r 6acae4210716 iro/offer/smstrade.py --- a/iro/offer/smstrade.py Sat Jul 27 13:29:15 2019 +0200 +++ b/iro/offer/smstrade.py Sat Jul 27 13:34:22 2019 +0200 @@ -25,7 +25,7 @@ import urllib from functools import partial from decimal import Decimal -#import copy +import copy from ..config import Option from ..model.status import Status @@ -68,7 +68,13 @@ self.code = code self.exID = exID - self.costs = Decimal(costs) + try: + self.costs = Decimal(costs) + except: + if not costs.strip(): + self.costs = Decimal("0.0") + else: + raise self.count = int(count) def __str__(self): @@ -121,8 +127,9 @@ raise RejectRecipient(recipient) to ='00'+recipient.land+recipient.number - - s = self.__send(route, to, sms) + + s = self.__send(route, to, sms) + s.costs = Decimal('0.0728') if int(s) in (100,): return Status(self,route, exID=s.exID, costs=s.costs, count=s.count) elif int(s) in (70,71,): @@ -171,15 +178,16 @@ ps[p] = parameters[p] params = urllib.urlencode(ps) - #dp=copy.deepcopy(ps) - #dp["key"]="" - #print 'smstrade._send-parameters:%s\n\t->%s'%(str(dp), urllib.urlencode(dp)) - + dp=copy.deepcopy(ps) + dp["key"]="" + print 'smstrade._send-parameters:%s\n\t->%s'%(str(dp), urllib.urlencode(dp)) + response = urllib.urlopen(self.url, params) data = response.readlines() + print "result:%s"%(data) if len(data) == 1: return StatusCode(int(data[0])) - return StatusCode(int(data[0]),exID=data[1],costs=data[2],count=data[3]) + return StatusCode(int(data[0]),exID=data[1].strip(),costs=data[2],count=data[3]) def getSendFunc(self, typ, route): """returns a partial :meth:`send` methed with bounded route, if typ and route is valid."""