diff --git a/apps/click2dial/example.py b/apps/click2dial/example.py index 8548d463..fc3d7a70 100644 --- a/apps/click2dial/example.py +++ b/apps/click2dial/example.py @@ -10,6 +10,8 @@ # of the R-Uri to correctly route it to the destination. ######################################################################## +from xmlrpclib import * + proxy = "192.168.100.10" xmlrpc_url = "http://127.0.0.1:8090" @@ -24,12 +26,11 @@ auth_realm = "iptel.org" announce_file = "default_en" -from xmlrpclib import * s = ServerProxy(xmlrpc_url) s.dial_auth_b2b( - "click2dial", announce_file, - "sip:" + caller_user + "@" + caller_domain, - "sip:" + callee_user + "@" + callee_domain, + "click2dial", announce_file, + "sip:" + caller_user + "@" + caller_domain, + "sip:" + callee_user + "@" + callee_domain, "sip:" + caller_user + "@" + proxy + ";sw_domain=" + caller_domain, "sip:" + callee_user + "@" + proxy + ";sw_domain=" + callee_domain, auth_realm, auth_user, auth_pass) diff --git a/apps/conf_auth/conf_auth.py b/apps/conf_auth/conf_auth.py index 3a1ef2dd..ec8d5965 100644 --- a/apps/conf_auth/conf_auth.py +++ b/apps/conf_auth/conf_auth.py @@ -20,11 +20,13 @@ connected = 2 HINT_TIMER = 1 CONF_TIMER = 2 + def loopedTTS(str): af = IvrAudioFile.tts(str) af.loop = True return af + class IvrDialog(IvrDialogBase): welcome_msg = None auth_ok_msg = None @@ -37,7 +39,7 @@ class IvrDialog(IvrDialogBase): conf_to = '' conf_uri = '' conf_duration = 0 - + def sessionInfo(self): print("IVR Session info:") print(" user: ", self.dialog.user) @@ -59,7 +61,7 @@ class IvrDialog(IvrDialogBase): def onSessionStart(self): self.sessionInfo() self.setNoRelayonly() - self.welcome_msg = IvrAudioFile.tts("Welcome to the conferencing server. "+ \ + self.welcome_msg = IvrAudioFile.tts("Welcome to the conferencing server. " + "Please enter your PIN number, followed by the star key.") self.auth_ok_msg = IvrAudioFile.tts("Your PIN number is correct, you will be connected now.") # self.auth_fail_msg = IvrAudioFile.tts("Sorry, you have entered an invalid PIN number. " + \ @@ -68,22 +70,22 @@ class IvrDialog(IvrDialogBase): self.enqueue(self.welcome_msg,None) - def onBye(self): + def onBye(self): self.stopSession() def onDtmf(self,key,duration): if self.state == collect: self.flush() if key == 10: - + c = xmlrpclib.ServerProxy(server_path ) - erg = c.AuthorizeConference(self.dialog.remote_uri, + erg = c.AuthorizeConference(self.dialog.remote_uri, self.dialog.local_party, self.keys) debug('result of authentication: '+ str(erg)) if erg[0] == 'OK': self.flush() - self.enqueue(self.auth_ok_msg, None) + self.enqueue(self.auth_ok_msg, None) self.conf_to = erg[1] self.conf_uri = erg[2] self.conf_duration = erg[3] @@ -95,9 +97,9 @@ class IvrDialog(IvrDialogBase): self.auth_fail_msg.open(erg[1], ivr.AUDIO_READ) #self.flush() self.enqueue(self.auth_fail_msg, None) - + self.setTimer(HINT_TIMER, HINT_TIMEOUT) - else: + else: self.keys += str(key) debug("added key, PIN = " + self.keys) self.setTimer(HINT_TIMER, HINT_TIMEOUT) @@ -123,4 +125,3 @@ class IvrDialog(IvrDialogBase): self.terminateOtherLeg() self.bye() self.stopSession() - diff --git a/apps/examples/db_announce/announcement.py b/apps/examples/db_announce/announcement.py index dec79532..9371ee31 100644 --- a/apps/examples/db_announce/announcement.py +++ b/apps/examples/db_announce/announcement.py @@ -11,7 +11,8 @@ # Use, copying, modification, and distribution without written # permission is not allowed. -import os, MySQLdb +import os +import MySQLdb from log import * from ivr import * diff --git a/apps/examples/ivr_examples/b2b_out.py b/apps/examples/ivr_examples/b2b_out.py index 988f6f71..4f322a61 100644 --- a/apps/examples/ivr_examples/b2b_out.py +++ b/apps/examples/ivr_examples/b2b_out.py @@ -1,15 +1,17 @@ -# (outgoing) ivr b2bua example # +# (outgoing) ivr b2bua example # + from log import * from ivr import * + class IvrDialog(IvrDialogBase): - + def onSessionStart(self): info("starting b2bua app ...") - self.setNoRelayonly() + self.setNoRelayonly() self.audio_msg = IvrAudioFile() self.audio_msg.open("/home/stefan/sub_nautilus.wav", AUDIO_READ) self.setTimer(1, 10) @@ -21,10 +23,10 @@ class IvrDialog(IvrDialogBase): def onTimer(self, timerid): self.disconnectMedia() debug('hello kitty') - self.connectCallee(self.dialog.local_party,self.dialog.local_uri, \ + self.connectCallee(self.dialog.local_party, self.dialog.local_uri, self.dialog.remote_party,self.dialog.remote_uri,) return - def onBye(self): + def onBye(self): self.stopSession() diff --git a/apps/examples/ivr_examples/b2bua.py b/apps/examples/ivr_examples/b2bua.py index 77951f51..a6e4cd01 100644 --- a/apps/examples/ivr_examples/b2bua.py +++ b/apps/examples/ivr_examples/b2bua.py @@ -1,26 +1,28 @@ -# +# # ivr b2bua script example # + from log import * from ivr import * WELLCOME_MSG = "wav/default_en.wav" CALLEE_URI = "sip:music@iptel.org" + class IvrDialog(IvrDialogBase): - + def onSessionStart(self): info("starting b2bua test ...") self.setNoRelayonly() - + self.welcome_msg = IvrAudioFile() self.welcome_msg.open(WELLCOME_MSG, AUDIO_READ) self.enqueue(self.welcome_msg,None) def onEmptyQueue(self): - + info("connecting to To: " + CALLEE_URI + " R-URI: " + CALLEE_URI) info("\n\n\n original headers are: ---->%s<----\n\n\n" % self.invite_req.hdrs) self.invite_req.hdrs += "P-SomeMoreFunky: headervalue\r\n" @@ -32,5 +34,5 @@ class IvrDialog(IvrDialogBase): return - def onBye(self): + def onBye(self): self.stopSession() diff --git a/apps/examples/ivr_examples/call_center.py b/apps/examples/ivr_examples/call_center.py index 039c76d5..39d09331 100644 --- a/apps/examples/ivr_examples/call_center.py +++ b/apps/examples/ivr_examples/call_center.py @@ -16,6 +16,7 @@ beeping = 1 connecting = 2 connected = 3 + class IvrDialog(IvrDialogBase): def onSessionStart(self): @@ -40,7 +41,7 @@ class IvrDialog(IvrDialogBase): return return - + def onOtherReply(self, code, reason): debug('call_center: got reply: ' + str(code) + ' ' + reason) diff --git a/apps/examples/ivr_examples/db_balance.py b/apps/examples/ivr_examples/db_balance.py index f1041f26..b424f21c 100644 --- a/apps/examples/ivr_examples/db_balance.py +++ b/apps/examples/ivr_examples/db_balance.py @@ -4,7 +4,7 @@ # mysql> create database business; # mysql> create table business.accounts (user VARCHAR(100), bal_int INT, bal_decimal INT); # -# set TTS=y in apps/ivr/Makefile.defs, or rewrite with +# set TTS=y in apps/ivr/Makefile.defs, or rewrite with # enqueuing the parts of the sentence, like # self.ttsfile1 = IvrAudioFile() # self.ttsfile1.open("your_account_balance.wav", AUDIO_READ) @@ -23,6 +23,7 @@ db = MySQLdb.connection(host="127.0.0.1", user="root", passwd="sa07", db="busine # or, when using config file db_balance.conf: #db = MySQLdb.connection(host=config["db_host"], user=config["db_user"], passwd=config["db_pwd"], db=config["db_db"]) + class IvrDialog(IvrDialogBase) : ttsfile = None @@ -30,13 +31,13 @@ class IvrDialog(IvrDialogBase) : db.query("select bal_int, bal_decimal from accounts where user='%s'" % self.dialog.user) r = db.store_result() res = r.fetch_row(1) - if len(res): - self.ttsfile = IvrAudioFile().tts("Your account balance is %i dollars and %i cents" % \ + if len(res): + self.ttsfile = IvrAudioFile().tts("Your account balance is %i dollars and %i cents" % (int(res[0][0]), int(res[0][1]))) else: self.ttsfile = IvrAudioFile().tts("Sorry, I do not know your account balance.") self.enqueue(self.ttsfile, None) - + def onEmptyQueue(self): self.bye() self.stopSession() diff --git a/apps/examples/ivr_examples/play.py b/apps/examples/ivr_examples/play.py index 93a1eed1..e145bfdc 100644 --- a/apps/examples/ivr_examples/play.py +++ b/apps/examples/ivr_examples/play.py @@ -6,6 +6,7 @@ from log import * from ivr import * from p_app_param.p_app_param import * + class IvrDialog(IvrDialogBase): def onInvite(self, hdrs): @@ -19,20 +20,20 @@ class IvrDialog(IvrDialogBase): if not self.file: self.file = "/tmp/default.wav" return True - + def onSessionStart(self): self.announcement = IvrAudioFile() self.announcement.open(self.file, ivr.AUDIO_READ, False) self.enqueue(self.announcement, None) return - + def onEmptyQueue(self): if not self.queueIsEmpty(): return self.bye() self.stopSession() return - + def onBye(self): self.stopSession() return diff --git a/apps/examples/ivr_examples/rec.py b/apps/examples/ivr_examples/rec.py index 2485f005..852da2de 100644 --- a/apps/examples/ivr_examples/rec.py +++ b/apps/examples/ivr_examples/rec.py @@ -1,9 +1,11 @@ # # just recording to file # + from log import * from ivr import * + class IvrDialog(IvrDialogBase) : def onSessionStart(self) : diff --git a/apps/examples/ivr_examples/test_mp3.py b/apps/examples/ivr_examples/test_mp3.py index c8e0156e..4326d5c8 100644 --- a/apps/examples/ivr_examples/test_mp3.py +++ b/apps/examples/ivr_examples/test_mp3.py @@ -4,6 +4,8 @@ from log import * from ivr import * + + class IvrDialog(IvrDialogBase): def onSessionStart(self): @@ -12,4 +14,3 @@ class IvrDialog(IvrDialogBase): self.enqueue(self.voice_msg, None) self.voice_msg.open("record.mp3", AUDIO_WRITE, False) self.enqueue(None, self.voice_msg) - diff --git a/apps/examples/ivr_examples/tmpfile.py b/apps/examples/ivr_examples/tmpfile.py index f2d63bfb..841683a2 100644 --- a/apps/examples/ivr_examples/tmpfile.py +++ b/apps/examples/ivr_examples/tmpfile.py @@ -1,10 +1,12 @@ # # using IvrAudioFile fpopen # + from log import * from ivr import * import os + class IvrDialog(IvrDialogBase): def onSessionStart(self): diff --git a/apps/examples/mixin_announce/mix_announce.py b/apps/examples/mixin_announce/mix_announce.py index fc38199a..7b39be79 100644 --- a/apps/examples/mixin_announce/mix_announce.py +++ b/apps/examples/mixin_announce/mix_announce.py @@ -2,6 +2,7 @@ from log import * from ivr import * + class IvrDialog(IvrDialogBase): mixin = None announcement = None diff --git a/apps/examples/py_sems_ex/early_media.py b/apps/examples/py_sems_ex/early_media.py index b170037b..41da9112 100644 --- a/apps/examples/py_sems_ex/early_media.py +++ b/apps/examples/py_sems_ex/early_media.py @@ -1,4 +1,7 @@ -import base64, time, os, sip +import base64 +import time +import os +import sip from py_sems_log import * from py_sems import * @@ -37,7 +40,7 @@ class PySemsScript(PySemsDialog): if self.dlg.reply(req, 183, "OK", "application/sdp", sdp_reply, "") != 0: self.setStopped() - except: + except Exception: self.dlg.reply(req, 500, "File not found", "", "", "") self.ann = None self.setStopped() @@ -100,7 +103,7 @@ class PySemsScript(PySemsDialog): code_i = int(code) if (code_i < 300) or (code_i > 699): debug("Invalid reply code: %d", code_i) - except: + except Exception: debug("Invalid reply code: %s", code) debug("Replying %d %s" % (code_i, reason)) diff --git a/apps/examples/py_sems_ex/jukecall.py b/apps/examples/py_sems_ex/jukecall.py index 24ac3f34..d10096c1 100644 --- a/apps/examples/py_sems_ex/jukecall.py +++ b/apps/examples/py_sems_ex/jukecall.py @@ -1,4 +1,7 @@ -import base64, time, os, sip +import base64 +import time +import os +import sip from py_sems_log import * from py_sems import * @@ -49,7 +52,7 @@ class PySemsScript(PySemsB2ABDialog): self.ann = AmAudioFile() try: self.ann.open(ann_file) - except: + except Exception: self.dlg.reply(req, 500, "File not found", "", "", "") self.ann = None self.setStopped() diff --git a/apps/examples/tutorial/annc_service/annc_service.py b/apps/examples/tutorial/annc_service/annc_service.py index 0d39a5e1..63f66f8d 100644 --- a/apps/examples/tutorial/annc_service/annc_service.py +++ b/apps/examples/tutorial/annc_service/annc_service.py @@ -1,5 +1,5 @@ # -# Simple implementation of (a part) of RFC4240 +# Simple implementation of (a part) of RFC4240 # announcement service. # # supported parameters: @@ -15,6 +15,7 @@ from os import unlink TIMEOUT_TIMER_ID = 1 DELAY_TIMER_ID = 2 + class IvrDialog(IvrDialogBase): announcement=None @@ -23,13 +24,13 @@ class IvrDialog(IvrDialogBase): delay=0 duration=-1 play="" - delete_onbye = False + delete_onbye = False repeat_left = 0 def onSessionStart(self,hdrs): debug("configuration: %s" % repr(config)) - debug("local_uri = " + self.dialog.local_uri); + debug("local_uri = " + self.dialog.local_uri) # we use urlsplit as urlparse only returns the # parameters of the last path params = urlsplit(self.dialog.local_uri)[2].split(";") diff --git a/apps/examples/tutorial/cc_acc_xmlrpc/server/xmlrpcserver.py b/apps/examples/tutorial/cc_acc_xmlrpc/server/xmlrpcserver.py index 365633fe..0617e627 100644 --- a/apps/examples/tutorial/cc_acc_xmlrpc/server/xmlrpcserver.py +++ b/apps/examples/tutorial/cc_acc_xmlrpc/server/xmlrpcserver.py @@ -6,6 +6,7 @@ import string server = SimpleXMLRPCServer(("localhost", 8000)) server.register_introspection_functions() + class MyFuncs: def getCredit(self, arg): print("Function getCredit") @@ -28,5 +29,6 @@ class MyFuncs: print(" credit: ", credit) return credit + server.register_instance(MyFuncs()) server.serve_forever() diff --git a/apps/examples/tutorial/ivr_announce/ivr_announce.py b/apps/examples/tutorial/ivr_announce/ivr_announce.py index a055ce15..d11ed174 100644 --- a/apps/examples/tutorial/ivr_announce/ivr_announce.py +++ b/apps/examples/tutorial/ivr_announce/ivr_announce.py @@ -2,6 +2,7 @@ from log import * from ivr import * + class IvrDialog(IvrDialogBase): announcement = None diff --git a/apps/ivr/moc/ivr.py b/apps/ivr/moc/ivr.py index fa658f28..965b95c6 100644 --- a/apps/ivr/moc/ivr.py +++ b/apps/ivr/moc/ivr.py @@ -4,9 +4,11 @@ config = dict() AUDIO_READ = 0 AUDIO_WRITE = 1 + def getHeader(str1,str2): pass + class IvrDialogBase: def enqueue(self,a1,a2): @@ -17,10 +19,11 @@ class IvrDialogBase: def bye(self): pass - + def stopSession(self): pass + class IvrAudioFile: def open(self,filename,mode): diff --git a/apps/ivr/py/log.py b/apps/ivr/py/log.py index f5f62b81..4af960eb 100644 --- a/apps/ivr/py/log.py +++ b/apps/ivr/py/log.py @@ -7,33 +7,39 @@ L_WARN = 1 L_INFO = 2 L_DBG = 3 + def log(level, msg, args): - if args != None: + if args is not None: tmp_msg = msg % args else: tmp_msg = msg - + ivr.log(level,"Ivr-Python: " + tmp_msg + "\n") def error(msg, args=None): log(L_ERR, msg, args) + def warn(msg, args=None): log(L_WARN, msg, args) + def info(msg, args=None): log(L_INFO, msg, args) - + + def debug(msg, args=None): log(L_DBG, msg, args) def stacktrace(tb): - if tb: last_file = stacktrace(tb.tb_next) - else: return + if tb: + last_file = stacktrace(tb.tb_next) + else: + return f = tb.tb_frame.f_code.co_filename line = tb.tb_frame.f_lineno @@ -53,7 +59,6 @@ def log_excepthook(exception, value, tb): error('********** end of Ivr-Python exception report *********') - # init code sys.excepthook = log_excepthook debug("Python-Ivr logging started") diff --git a/apps/mailbox/imap_mailbox/MailboxURL.py b/apps/mailbox/imap_mailbox/MailboxURL.py index c00f05eb..792be352 100644 --- a/apps/mailbox/imap_mailbox/MailboxURL.py +++ b/apps/mailbox/imap_mailbox/MailboxURL.py @@ -1,7 +1,8 @@ import re -class InvalidMailboxURL(Exception): + +class InvalidMailboxURL(Exception): def __init__(self,value): self.value = value @@ -11,7 +12,6 @@ class InvalidMailboxURL(Exception): class MailboxURL: - url = "" user = "" passwd = "" @@ -23,7 +23,6 @@ class MailboxURL: self.url = url self._parse() - def _parse(self): m = re.match('imap://(.+):(.+)@(.+):([0-9]+)/(.+)',self.url) if m is None: @@ -42,5 +41,3 @@ class MailboxURL: ("host:\t%s\n" % self.host) + \ ("port:\t%i\n" % self.port) + \ ("path:\t%s\n" % self.path) - - diff --git a/apps/mailbox/imap_mailbox/imap4ext.py b/apps/mailbox/imap_mailbox/imap4ext.py index f946b4cc..60915732 100644 --- a/apps/mailbox/imap_mailbox/imap4ext.py +++ b/apps/mailbox/imap_mailbox/imap4ext.py @@ -1,4 +1,6 @@ -import os,base64,time +import os +import base64 +import time from imaplib import IMAP4 from MailboxURL import * @@ -20,7 +22,7 @@ class IMAP4_MsgBODY: uid = '' parts = [] ct = '' - + def __init__(self,imap,uid): self.uid = '' @@ -40,16 +42,16 @@ class IMAP4_MsgBODY: (t,d) = imap.uid('fetch',self.uid,'(BODY.PEEK[%i])' % (part+1)) if (t != "OK") or (len(d[0]) != 2): - raise IMAP4.error("could not retrieve part %s/%i" \ + raise IMAP4.error("could not retrieve part %s/%i" % (self.uid, part+1)) - + msg = d[0][1] msg = base64.decodestring(msg) if filename is None: out_file = os.tmpfile() else: out_file = open(filename,'w+') - + out_file.write(msg) out_file.seek(0) @@ -59,11 +61,10 @@ class IMAP4_MsgBODY: out_file.close() return None - def _parse_body_desc(self,desc): (_dummy,s) = self._parenthesis2seq(desc)[1] - + self.uid = s[1] if type(s[3][0]) is not str: @@ -78,7 +79,6 @@ class IMAP4_MsgBODY: self.parts.append(s[3]) self.ct = s[3][0] - def _parenthesis2seq(self,s,ibeg=0): seq = [] @@ -90,7 +90,7 @@ class IMAP4_MsgBODY: (i,tmp_seq) = self._parenthesis2seq(s,i+1) elmt_beg = i seq.append(tmp_seq) - + elif s[i] == ')': if elmt_beg < i: seq.append(s[elmt_beg:i]) @@ -110,7 +110,6 @@ class IMAP4_MsgBODY: return (i,seq) - class IMAP4_Mailbox: url = None @@ -123,25 +122,22 @@ class IMAP4_Mailbox: def __del__(self): - if self.imap != None: + if self.imap is not None: self.imap.logout() self.imap = None - def createBox(self): self._login() - debug("Creating account: " + \ + debug("Creating account: " + repr(IMAPCALL(self.imap.create(self.url.path)))) - def deleteBox(self): self._login() - debug("Deleting account: " + \ + debug("Deleting account: " + repr(IMAPCALL(self.imap.delete(self.url.path)))) - def uploadMsg(self,msg): self._login() IMAPCALL(self.imap.append(self.url.path,None,time.gmtime(),msg)) @@ -179,9 +175,8 @@ class IMAP4_Mailbox: IMAPCALL(self.imap.close()) return msg_list - def downloadWAV(self,msg_uid): - + self._login() IMAPCALL(self.imap.select(self.url.path)) body = IMAP4_MsgBODY(self.imap,msg_uid) @@ -194,13 +189,12 @@ class IMAP4_Mailbox: IMAPCALL(self.imap.close()) return fp - def downloadWAVs(self,search_criterion,file_prefix): self._login() IMAPCALL(self.imap.select(self.url.path)) - + (t,d) = self.imap.uid('SEARCH',search_criterion) IMAPCALL((t,d)) @@ -208,27 +202,26 @@ class IMAP4_Mailbox: for i in d[0].split(): body = IMAP4_MsgBODY(self.imap,i) - + for p in range(len(body.parts)): - + if body.part_ct(p).upper() == 'AUDIO/X-WAV': - + filename = file_prefix + '-' + body.uid + '.wav' msg_list.append(filename) body.fetch2file(self.imap,p,filename) - + IMAPCALL(self.imap.close()) return msg_list def _login(self): - if self.imap != None: + if self.imap is not None: return self.imap = IMAP4(self.url.host,self.url.port) try: IMAPCALL(self.imap.login(self.url.user,self.url.passwd)) - except: + except IMAP4.error: self.imap = None raise - diff --git a/apps/mailbox/mailbox.py b/apps/mailbox/mailbox.py index d4aa00ab..0992dcb0 100644 --- a/apps/mailbox/mailbox.py +++ b/apps/mailbox/mailbox.py @@ -1,4 +1,5 @@ -import base64,time +import base64 +import time from log import * from ivr import * @@ -16,7 +17,7 @@ class IvrDialog(IvrDialogBase): def onSessionStart(self): debug("config: %s" % repr(config)) - self.mailbox = IMAP4_Mailbox(getAppParam("Mailbox-URL")); + self.mailbox = IMAP4_Mailbox(getAppParam("Mailbox-URL")) debug("***** Mailbox Url: ******\n" + str(self.mailbox.url)) self.announcement = IvrAudioFile() @@ -32,27 +33,21 @@ class IvrDialog(IvrDialogBase): self.enqueue(self.announcement,None) self.enqueue(self.beep,None) self.enqueue(None,self.voice_msg) - - + def onBye(self): - + self.stopSession() self.saveMsg() - def onEmptyQueue(self): - - self.bye() self.stopSession() self.saveMsg() - def onDtmf(self,key,duration): - - pass + pass def saveMsg(self): @@ -71,5 +66,5 @@ class IvrDialog(IvrDialogBase): enc_msg #debug("msg = <%s>",msg); - + self.mailbox.uploadMsg(msg) diff --git a/apps/mailbox/mailbox_query.py b/apps/mailbox/mailbox_query.py index 14e5b929..b99c1241 100644 --- a/apps/mailbox/mailbox_query.py +++ b/apps/mailbox/mailbox_query.py @@ -1,4 +1,5 @@ -import os,weakref +import os +import weakref from log import * from ivr import * @@ -18,34 +19,28 @@ class VoiceMsg: self._mb = mb self._audio = None - def _load(self): self._fp = self._mb.downloadWAV(self._uid) self._audio = IvrAudioFile() self._audio.fpopen("tmp.wav",AUDIO_READ,self._fp) - def audio(self): - if self._audio == None: + if self._audio is None: self._load() - - return self._audio + return self._audio def save(self): self._mb.saveMsg(self._uid) - def delete(self): self._mb.deleteMsg(self._uid) - - class IvrDialog(IvrDialogBase): def __init__(self): @@ -59,12 +54,11 @@ class IvrDialog(IvrDialogBase): self.cur_msg = 0 self.exit = False - - self.key_enabled = False + self.key_enabled = False def loadVoiceLib(self): - + self.voice_lib = dict() # Parts for the welcome text @@ -95,23 +89,21 @@ class IvrDialog(IvrDialogBase): # Menu will be looped until a key is pressed self.voice_lib['msg_menu'].loop = True - def loadMsgList(self,criterion): msg_list = List() name_list = self.mailbox.getWavMsgList(criterion) for n in name_list: msg_list.append(VoiceMsg(n,self.mailbox)) - - return msg_list + return msg_list def onSessionStart(self): self.__init__() self.loadVoiceLib() - self.mailbox = IMAP4_Mailbox(getAppParam("Mailbox-URL")); + self.mailbox = IMAP4_Mailbox(getAppParam("Mailbox-URL")) debug("***** Mailbox Url: ******\n" + str(self.mailbox.url)) self.new_msgs = self.loadMsgList('UNSEEN') @@ -119,20 +111,20 @@ class IvrDialog(IvrDialogBase): if (len(self.new_msgs) == 0) and \ (len(self.saved_msgs) == 0): - + self.enqueue(self.voice_lib['no_msg'],None) self.enqueue(self.voice_lib['bye'],None) self.exit = True return - + self.enqueue(self.voice_lib['you_have'],None) if len(self.new_msgs) > 0: - + self.enqueue(self.voice_lib['new_msg'],None) self.msg_list = weakref.proxy(self.new_msgs) self.cur_list = weakref.ref(self.new_msgs) - + if len(self.saved_msgs) > 0: self.enqueue(self.voice_lib['and'],None) self.enqueue(self.voice_lib['saved_msg'],None) @@ -142,13 +134,11 @@ class IvrDialog(IvrDialogBase): self.cur_list = weakref.ref(self.saved_msgs) self.enqueueCurMsg() - def onBye(self): - + self.stopSession() - def onEmptyQueue(self): if self.exit: @@ -156,7 +146,6 @@ class IvrDialog(IvrDialogBase): self.bye() self.stopSession() - def onDtmf(self,key,duration): if not self.key_enabled: @@ -166,7 +155,6 @@ class IvrDialog(IvrDialogBase): if key == 1: self.flush() - elif key == 2: self.key_enabled = False @@ -174,7 +162,7 @@ class IvrDialog(IvrDialogBase): self.msg_list[self.cur_msg].save() self.enqueue(self.voice_lib['msg_saved'],None) self.cur_msg += 1 - + elif key == 3: self.key_enabled = False self.flush() @@ -183,27 +171,26 @@ class IvrDialog(IvrDialogBase): self.cur_msg += 1 else: return - + if not self.enqueueCurMsg(): debug("self.cur_list() is self.new_msgs = %s" % repr(self.cur_list() is self.new_msgs)) debug("len(self.saved_msgs) = %i" % len(self.saved_msgs)) - + if (self.cur_list() is self.new_msgs) and \ len(self.saved_msgs) > 0: - + self.cur_msg = 0 - + self.msg_list = weakref.proxy(self.saved_msgs) self.cur_list = weakref.ref(self.saved_msgs) - + self.enqueue(self.voice_lib['saved_msg'],None) self.enqueueCurMsg() else: self.enqueue(self.voice_lib['bye'],None) self.exit = True - def enqueueCurMsg(self): if self.cur_msg >= len(self.msg_list): @@ -213,10 +200,10 @@ class IvrDialog(IvrDialogBase): self.enqueue(self.voice_lib['next_msg'],None) else: self.enqueue(self.voice_lib['first_msg'],None) - + self.enqueue(self.msg_list[self.cur_msg].audio(),None) self.enqueue(self.voice_lib['msg_menu'],None) - + self.key_enabled = True return True diff --git a/apps/mobile_push/load_test/call_gen.py b/apps/mobile_push/load_test/call_gen.py index 724f558b..3d0eb83f 100755 --- a/apps/mobile_push/load_test/call_gen.py +++ b/apps/mobile_push/load_test/call_gen.py @@ -1,5 +1,6 @@ #!/usr/bin/env python -from xmlrpclib import * + +from xmlrpclib import * + s = ServerProxy('http://127.0.0.1:8092') print(s.setTarget(100, 1, 0, '4', '192.168.5.110', 2, 0, 30, 40)) - diff --git a/apps/mobile_push/load_test/example_server.py b/apps/mobile_push/load_test/example_server.py index 8187bd83..f7a68cab 100644 --- a/apps/mobile_push/load_test/example_server.py +++ b/apps/mobile_push/load_test/example_server.py @@ -11,6 +11,7 @@ class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler): s.send_response(200) s.send_header("Content-type", "text/html") s.end_headers() + def do_GET(s): """Respond to a GET request.""" s.send_response(200) @@ -23,6 +24,7 @@ class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler): s.wfile.write("

You accessed path: %s

" % s.path) s.wfile.write("") + if __name__ == '__main__': server_class = BaseHTTPServer.HTTPServer httpd = server_class((HOST_NAME, PORT_NUMBER), MyHandler) @@ -33,4 +35,3 @@ if __name__ == '__main__': pass httpd.server_close() print(time.asctime(), "Server Stops - %s:%s" % (HOST_NAME, PORT_NUMBER)) - diff --git a/apps/mobile_push/load_test/reg_client.py b/apps/mobile_push/load_test/reg_client.py index 3bce8400..28029e63 100755 --- a/apps/mobile_push/load_test/reg_client.py +++ b/apps/mobile_push/load_test/reg_client.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -from xmlrpclib import * +from xmlrpclib import * from random import * import time @@ -16,5 +16,5 @@ while True: else: print(s.createRegistration(n, str(n), str(n), '192.168.5.110')) r.add(n) - - time.sleep(.1) \ No newline at end of file + + time.sleep(.1) diff --git a/apps/pin_collect/pin_collect.py b/apps/pin_collect/pin_collect.py index 7afff5af..ec0a39a9 100644 --- a/apps/pin_collect/pin_collect.py +++ b/apps/pin_collect/pin_collect.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- + from log import * from ivr import * @@ -13,6 +14,7 @@ connect_failed = 2 HINT_TIMER = 1 HINT_TIMEOUT = 10 # seconds until hint msg is played + class IvrDialog(IvrDialogBase): # messages to be played to the caller welcome_msg = None @@ -28,9 +30,8 @@ class IvrDialog(IvrDialogBase): # cseq of transfer request transfer_cseq = None # remote_uri of dialog - dlg_remote_uri = None + dlg_remote_uri = None - def sessionInfo(self): debug("IVR Session info:") debug(" user: " + self.dialog.user) @@ -52,10 +53,10 @@ class IvrDialog(IvrDialogBase): def onSessionStart(self): self.sessionInfo() self.setNoRelayonly() - + self.welcome_msg = IvrAudioFile() self.welcome_msg.open(config['welcome_msg'],AUDIO_READ) - + self.pin_msg = IvrAudioFile() self.pin_msg.open(config['pin_msg'],AUDIO_READ) @@ -78,7 +79,7 @@ class IvrDialog(IvrDialogBase): try: c = xmlrpclib.ServerProxy(config['auth_xmlrpc_url']) erg = c.authorize(self.dialog.user, self.keys) - + debug('result of authentication: '+ str(erg)) if erg == 'OK': self.state = connect @@ -86,27 +87,27 @@ class IvrDialog(IvrDialogBase): self.dlg_remote_uri = self.dialog.remote_uri debug("saved remote_uri "+ self.dlg_remote_uri) self.transfer_cseq = self.dialog.cseq - self.redirect("sip:" + self.dialog.user + "@" + \ + self.redirect("sip:" + self.dialog.user + "@" + self.dialog.domain) else: self.flush() self.keys = '' - if self.auth_fail_msg == None: + if self.auth_fail_msg is None: self.auth_fail_msg = IvrAudioFile() self.auth_fail_msg.open(config['auth_fail_msg'],AUDIO_READ) self.enqueue(self.auth_fail_msg,None) - except: + except Exception: self.dlg_remote_uri = self.dialog.remote_uri - self.state = connect_failed + self.state = connect_failed self.fail_msg = IvrAudioFile() self.fail_msg.open(config['fail_msg'],AUDIO_READ) self.enqueue(self.fail_msg,None) - + elif config['auth_mode'] == 'REFER': self.state = connect self.removeTimer(HINT_TIMER) self.transfer_cseq = self.dialog.cseq - self.refer("sip:" + self.dialog.user + "+" + self.keys + "@" + \ + self.refer("sip:" + self.dialog.user + "+" + self.keys + "@" + self.dialog.domain, 20) else: self.state = connect @@ -114,11 +115,9 @@ class IvrDialog(IvrDialogBase): self.dlg_remote_uri = self.dialog.remote_uri debug("saved remote_uri "+ self.dlg_remote_uri) self.transfer_cseq = self.dialog.cseq - self.redirect("sip:" + self.dialog.user + "+" + self.keys + "@" + \ + self.redirect("sip:" + self.dialog.user + "+" + self.keys + "@" + self.dialog.domain) - - def onEmptyQueue(self): if self.state == collect: self.setTimer(HINT_TIMER, HINT_TIMEOUT) @@ -141,7 +140,7 @@ class IvrDialog(IvrDialogBase): self.dropSession() elif reply.code >= 300: debug("transfer failed. notifying user") - self.state = connect_failed + self.state = connect_failed self.fail_msg = IvrAudioFile() self.fail_msg.open(config['fail_msg'],AUDIO_READ) self.enqueue(self.fail_msg,None) diff --git a/apps/pin_collect/test/authserver.py b/apps/pin_collect/test/authserver.py index 66b9c4b5..323fc736 100644 --- a/apps/pin_collect/test/authserver.py +++ b/apps/pin_collect/test/authserver.py @@ -1,5 +1,6 @@ import SimpleXMLRPCServer + #The server object class AuthServer: def __init__(self): @@ -15,6 +16,7 @@ class AuthServer: self.keys[room] = pin return 'OK' + authsrv = AuthServer() server = SimpleXMLRPCServer.SimpleXMLRPCServer(("127.0.0.1", 9090)) server.register_instance(authsrv) diff --git a/apps/py_sems/py/py_sems_log.py b/apps/py_sems/py/py_sems_log.py index c0b18146..de90bda0 100644 --- a/apps/py_sems/py/py_sems_log.py +++ b/apps/py_sems/py/py_sems_log.py @@ -7,33 +7,39 @@ L_WARN = 1 L_INFO = 2 L_DBG = 3 + def log(level, msg, args): - if args != None: + if args is not None: tmp_msg = msg % args else: tmp_msg = msg - + py_sems.log(level,"PySems: " + tmp_msg + "\n") def error(msg, args=None): log(L_ERR, msg, args) + def warn(msg, args=None): log(L_WARN, msg, args) + def info(msg, args=None): log(L_INFO, msg, args) - + + def debug(msg, args=None): log(L_DBG, msg, args) def stacktrace(tb): - if tb: last_file = stacktrace(tb.tb_next) - else: return + if tb: + last_file = stacktrace(tb.tb_next) + else: + return f = tb.tb_frame.f_code.co_filename line = tb.tb_frame.f_lineno @@ -53,7 +59,6 @@ def log_excepthook(exception, value, tb): error('********** end of PySems exception report *********') - # init code sys.excepthook = log_excepthook debug("PySems logging started") diff --git a/apps/sbc/call_control/prepaid_xmlrpc/server/xmlrpcserver.py b/apps/sbc/call_control/prepaid_xmlrpc/server/xmlrpcserver.py index 365633fe..0617e627 100644 --- a/apps/sbc/call_control/prepaid_xmlrpc/server/xmlrpcserver.py +++ b/apps/sbc/call_control/prepaid_xmlrpc/server/xmlrpcserver.py @@ -6,6 +6,7 @@ import string server = SimpleXMLRPCServer(("localhost", 8000)) server.register_introspection_functions() + class MyFuncs: def getCredit(self, arg): print("Function getCredit") @@ -28,5 +29,6 @@ class MyFuncs: print(" credit: ", credit) return credit + server.register_instance(MyFuncs()) server.serve_forever() diff --git a/apps/twit/twit.py b/apps/twit/twit.py index 057145ba..d2e2ad7b 100644 --- a/apps/twit/twit.py +++ b/apps/twit/twit.py @@ -14,6 +14,7 @@ twit_account_msg = config['twit_account_msg'] twit_ok_msg = config['twit_ok_msg'] twit_posting_msg = config['twit_posting_msg'] + class IvrDialog(IvrDialogBase) : def onSessionStart( self ) : @@ -27,46 +28,46 @@ class IvrDialog(IvrDialogBase) : self.t_pwd = parts[2] if len(parts) == 4: self.t_msg = unquote(parts[3]) - - if not account_found: + + if not account_found: self.t_account = getAppParam("u") self.t_pwd = getAppParam("p") if (len(getAppParam("m"))) and getAppParam("m") != '': self.t_msg = unquote(getAppParam("m")) if (self.t_account != '' and self.t_account != '') and \ self.t_pwd != '' and self.t_pwd != '': - account_found = True - + account_found = True + if not account_found: self.state = 'bye' self.welcome_msg = IvrAudioFile() self.welcome_msg.open(twit_account_msg, AUDIO_READ) self.enqueue(self.welcome_msg, None) return - + self.state = 'recording' self.welcome_msg = IvrAudioFile() self.welcome_msg.open(welcome_msg, AUDIO_READ) self.enqueue(self.welcome_msg, None) - + self.audio_msg = IvrAudioFile() self.twit_file = 'twit_' + ''.join(random.sample('abcdefghijklm', 8)) + '.wav' self.audio_msg.open(rec_path + self.twit_file, AUDIO_WRITE) self.enqueue(None,self.audio_msg) self.setTimer(1, 180) - + def onTimer(self, id): onDtmf(self, 0, 0) pass - + def onDtmf(self, key_no, key_length): self.flush() self.state = 'recorded' - + def onBye(self): self.stopSession() - + def onEmptyQueue(self): log(1, 'eq in '+self.state) if self.state == 'bye': @@ -77,7 +78,7 @@ class IvrDialog(IvrDialogBase) : self.posting_msg = IvrAudioFile() self.posting_msg.open(twit_posting_msg, AUDIO_READ) self.enqueue(self.posting_msg, None) - + longurl=base_url + self.twit_file short_url_handle = urlopen('http://is.gd/api.php?longurl=%s' % longurl) msg = twit_ok_msg @@ -85,10 +86,8 @@ class IvrDialog(IvrDialogBase) : t = twitter.Twitter() t.set_auth(self.t_account, self.t_pwd) return_val = t.status_update(self.t_msg+' @'+short_url_handle.read()) - except: + except Exception: msg = twit_err_msg self.err_msg = IvrAudioFile() self.err_msg.open(msg, AUDIO_READ) self.enqueue(self.err_msg, None) - - diff --git a/apps/webconference/pyqtgui/account.py b/apps/webconference/pyqtgui/account.py index 87d823e1..4a05a7fe 100644 --- a/apps/webconference/pyqtgui/account.py +++ b/apps/webconference/pyqtgui/account.py @@ -9,6 +9,7 @@ from PyQt4 import QtCore, QtGui + class Ui_account(object): def setupUi(self, account): account.setObjectName("account") @@ -56,4 +57,3 @@ class Ui_account(object): self.e_domain.setText(QtGui.QApplication.translate("account", "iptel.org", None, QtGui.QApplication.UnicodeUTF8)) self.label_3.setText(QtGui.QApplication.translate("account", "Password", None, QtGui.QApplication.UnicodeUTF8)) self.e_pwd.setText(QtGui.QApplication.translate("account", "password", None, QtGui.QApplication.UnicodeUTF8)) - diff --git a/apps/webconference/pyqtgui/callbox.py b/apps/webconference/pyqtgui/callbox.py index 0a7f558f..777260e1 100644 --- a/apps/webconference/pyqtgui/callbox.py +++ b/apps/webconference/pyqtgui/callbox.py @@ -9,6 +9,7 @@ from PyQt4 import QtCore, QtGui + class Ui_callbox(object): def setupUi(self, callbox): callbox.setObjectName("callbox") @@ -37,4 +38,3 @@ class Ui_callbox(object): callbox.setWindowTitle(QtGui.QApplication.translate("callbox", "call", None, QtGui.QApplication.UnicodeUTF8)) self.label.setText(QtGui.QApplication.translate("callbox", "calll", None, QtGui.QApplication.UnicodeUTF8)) self.num.setText(QtGui.QApplication.translate("callbox", "+49", None, QtGui.QApplication.UnicodeUTF8)) - diff --git a/apps/webconference/pyqtgui/conftable.py b/apps/webconference/pyqtgui/conftable.py index c6f2f247..107a4716 100644 --- a/apps/webconference/pyqtgui/conftable.py +++ b/apps/webconference/pyqtgui/conftable.py @@ -9,6 +9,7 @@ from PyQt4 import QtCore, QtGui + class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") @@ -30,7 +31,7 @@ class Ui_MainWindow(object): self.gridLayout_2 = QtGui.QGridLayout(self.frame_main) self.gridLayout_2.setObjectName("gridLayout_2") self.label = QtGui.QLabel(self.frame_main) - self.label.setStyleSheet("""QLabel { + self.label.setStyleSheet("""QLabel { background-color: rgb(170, 200, 255); } """) @@ -67,4 +68,3 @@ class Ui_MainWindow(object): "webconference", None, QtGui.QApplication.UnicodeUTF8)) self.menuSettings.setTitle(QtGui.QApplication.translate("MainWindow", "Menu", None, QtGui.QApplication.UnicodeUTF8)) self.actionQuit.setText(QtGui.QApplication.translate("MainWindow", "Quit", None, QtGui.QApplication.UnicodeUTF8)) - diff --git a/apps/webconference/pyqtgui/participant.py b/apps/webconference/pyqtgui/participant.py index 5e594371..679fac0a 100644 --- a/apps/webconference/pyqtgui/participant.py +++ b/apps/webconference/pyqtgui/participant.py @@ -9,6 +9,7 @@ from PyQt4 import QtCore, QtGui + class Ui_participant(object): def setupUi(self, participant): participant.setObjectName("participant") @@ -46,4 +47,3 @@ class Ui_participant(object): self.l_status.setText(QtGui.QApplication.translate("participant", "status", None, QtGui.QApplication.UnicodeUTF8)) self.bt_ciao.setText(QtGui.QApplication.translate("participant", "ciao", None, QtGui.QApplication.UnicodeUTF8)) self.cb_muted.setText(QtGui.QApplication.translate("participant", "muted", None, QtGui.QApplication.UnicodeUTF8)) - diff --git a/apps/webconference/pyqtgui/webconference.py b/apps/webconference/pyqtgui/webconference.py index a7aaea9c..939b07f0 100755 --- a/apps/webconference/pyqtgui/webconference.py +++ b/apps/webconference/pyqtgui/webconference.py @@ -9,6 +9,7 @@ # (c) 2009 Stefan Sayer # License: GPLv3 # + import sys import random from PyQt4 import QtCore, QtGui @@ -18,7 +19,7 @@ from PyQt4.QtCore import * from xmlrpclib import * from threading import * -from conftable import * +from conftable import * from participant import * from callbox import * from account import * @@ -36,10 +37,11 @@ HAS_ACCOUNT=False try: from accountconfig import * HAS_ACCOUNT=True -except: +except Exception: print("accountconfig.py not found - will ask for account to make calls") pass + class named_participant(Ui_participant): def __init__(self, parent, title, callid, id): self.callid = callid @@ -48,12 +50,12 @@ class named_participant(Ui_participant): self.parent = parent self.tag = "" parent.setWindowTitle(title) - QtCore.QObject.connect(self.bt_ciao, QtCore.SIGNAL("clicked()"), self.ciao_clicked) + QtCore.QObject.connect(self.bt_ciao, QtCore.SIGNAL("clicked()"), self.ciao_clicked) QtCore.QObject.connect(self.cb_muted, QtCore.SIGNAL("stateChanged(int)"), self.muted_changed) - + def ciao_clicked(self): self.bt_ciao.emit(QtCore.SIGNAL("ciao(int)"), self.id) - + def status2text(self, s): return { 0: "Disconnected", 1: "Connecting", @@ -61,7 +63,7 @@ class named_participant(Ui_participant): 3: "Connected", 4: "Disconnecting", 5: "Finished"}[s] - + def set_status(self, status, hint, muted): self.l_status.setText(self.status2text(status)) self.l_status.setToolTip(hint) @@ -69,26 +71,26 @@ class named_participant(Ui_participant): self.cb_muted.setCheckState(Qt.Checked) else: self.cb_muted.setCheckState(Qt.Unchecked) - + def muted_changed(self, i): print("callid is" , self.callid) self.cb_muted.emit(QtCore.SIGNAL("mute(int,bool)"), self.id, self.cb_muted.isChecked()) - - + + class StartQT4(QtGui.QMainWindow): participants = [] roomname = "" - adminpin = "" + adminpin = "" s = None last_res = None - + def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.show() - if HAS_ACCOUNT: + if HAS_ACCOUNT: self.call_domain = DOMAIN self.call_user = USER self.call_pwd = PASSWORD @@ -99,12 +101,12 @@ class StartQT4(QtGui.QMainWindow): dlg_cb.setupUi(dlg) if dlg.exec_() == QDialog.Rejected: raise "well, I need a SIP account to make calls" - + self.call_domain = str(dlg_cb.e_domain.text()) self.call_pwd = str(dlg_cb.e_pwd.text()) self.call_user = str(dlg_cb.e_user.text()) self.call_auth_user = self.call_user - + QtCore.QObject.connect(self.ui.buttonNew, QtCore.SIGNAL("clicked()"), self.new_call) self.s = ServerProxy(CONTROL_URI) print("server has %d running calls " % self.s.calls()) @@ -119,28 +121,28 @@ class StartQT4(QtGui.QMainWindow): break if self.adminpin == "": raise "oh, could not get a free room :(" - + print("roomname is %s, adminpin is %s "% (self.roomname, self.adminpin)) - self.ui.label.setText("iptel.org\nwebconference\nhttps://webconference.iptel.org\n\nroom: %s adminpin:%s\n\n" + self.ui.label.setText("iptel.org\nwebconference\nhttps://webconference.iptel.org\n\nroom: %s adminpin:%s\n\n" "to dial in call sip:conference@iptel.org \nand type %s*" %(self.roomname, self.adminpin, self.roomname)) self.timer = QtCore.QTimer(self) self.connect(self.timer, QtCore.SIGNAL("timeout()"), self.timer_hit) self.timer.start(REFRESH_INTERVAL) - + def timer_hit(self): res = self.s.di('webconference', 'roomInfo', self.roomname, self.adminpin) if res[0] != 0: print("oh my god, can't see this room!") return - + code, reason, participants, serverstatus = res if participants == self.last_res: return #optimize a bit - + self.last_res = participants - + for part in participants: call_tag, number, status, reason, muted, participant_id = part found = False @@ -152,7 +154,7 @@ class StartQT4(QtGui.QMainWindow): if not found: p = self.createparticipantWidget(number, call_tag) p.set_status(status, reason, muted) - + def createparticipantWidget(self, name, callid): w = QtGui.QDockWidget("someone", self.ui.frame_main) part = named_participant(w, name, callid, len(self.participants)) @@ -163,7 +165,7 @@ class StartQT4(QtGui.QMainWindow): w.show() self.participants = self.participants + [ part ] return part - + def new_call(self): print("a new call.") dlg = QtGui.QDialog(self) @@ -171,31 +173,29 @@ class StartQT4(QtGui.QMainWindow): dlg_cb.setupUi(dlg) if dlg.exec_() == QDialog.Rejected: return - + print("now calling %s " % dlg_cb.num.text()) res = self.s.di('webconference', 'dialout', self.roomname, self.adminpin, str(dlg_cb.num.text()), self.call_user, self.call_domain, self.call_auth_user, self.call_pwd) if res[0] != 0: print("oh, my dear, calling failed with code %d " % res[0]) return - code, result, callid, serverinfo = res + code, result, callid, serverinfo = res print("code %d result %s " % (code, result)) print("serverinfo is %s " % serverinfo) - + self.createparticipantWidget(dlg_cb.num.text(), callid) - + def part_ciao(self, id): print("ciao: ", id) self.s.di('webconference', 'kickout', self.roomname, self.adminpin, self.participants[id].callid) - + def part_muted(self, id, s): print("mute: ", id, " is ", s) if s: self.s.di('webconference', 'mute', self.roomname, self.adminpin, self.participants[id].callid) else: self.s.di('webconference', 'unmute', self.roomname, self.adminpin, self.participants[id].callid) - - if __name__ == "__main__": @@ -203,4 +203,3 @@ if __name__ == "__main__": myapp = StartQT4() myapp.show() sys.exit(app.exec_()) - diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..5c149670 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,7 @@ +[tool.black] +# Match line-length expected by pycodestyle. +line-length = 200 +# Current version in Debian trixie. +target-version = ['py313'] +# Enable preview features, expected by pycodestyle. +preview = true diff --git a/t/sems_tester.py b/t/sems_tester.py index 08d34e50..bf4d5525 100644 --- a/t/sems_tester.py +++ b/t/sems_tester.py @@ -100,12 +100,12 @@ class TestCase(unittest.TestCase): s = sock if not s: s = self.makeXMLRPCSocket() - l = len(req) + req_len = len(req) req = ( b"POST / HTTP/1.1\r\nConnection: close\r\nHost: 127.0.0.1:" + bytes(self._xmlrpc_port) + b"\r\nUser-Agent: Tester\r\nContent-Type: text/xml\r\nContent-Length: " - + bytes(str(l), "latin1") + + bytes(str(req_len), "latin1") + b"\r\n\r\n" + req ) diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..d7e05cc7 --- /dev/null +++ b/tox.ini @@ -0,0 +1,4 @@ +[pycodestyle] +max-line-length = 200 +# Ignore valid reports for now. +ignore = E101,E111,E117,E126,E127,E128,E201,E202,E203,E221,E222,E223,E225,E226,E227,E231,E241,E261,E262,E265,W191,W503,W504