MSN Bot Class
## # MsnClient Class -- A basic class that enables one to create an MSN client this way: # x = MsnClient(to_msnid, bot_msnid, bot_msnid_password, messege); x.tell() # (C) Timothy Makobu, 2007 ## import select import socket import thread import msnlib import msncb import time import sys class MsnClient: def __init__(self, to_id='', bot_id='', bot_pass='', message='Hi :D'): """ MsnClient(to_msnid, bot_msnid, bot_msnid_password, messege) """ self.to_id = to_id self.message = message self.msn_obj = msnlib.msnd() self.msn_obj.cb = msncb.cb() self.msn_obj.email = bot_id self.msn_obj.pwd = bot_pass self.msn_obj.login() self.msn_obj.sync() self.msn_obj.change_status('online') def _send_message(self): time.sleep(15) print 'Here 2' print 'here 3', self.msn_obj.sendmsg(self.to_id, self.message) time.sleep(30) self._quit() def _quit(self): try: self.msn_obj.disconnect() except: pass sys.exit(0) def tell(self): thread.start_new_thread(self._send_message, ()) while 1: self.nd = self.msn_obj.pollable() self.in_fd = self.nd[0] self.out_fd = self.nd[1] try: self.poller = select.select(self.in_fd, self.out_fd, [], 0) except: self._quit() for self.i in self.poller[0] + self.poller[1]: try: self.msn_obj.read(self.i) except('SocketError', socket.error), err: if self.i != self.msn_obj: self.msn_obj.close(self.i) else: self._quit() time.sleep(0.1) -- http://mail.python.org/mailman/listinfo/python-list
PyS60, GPS and SMS
# Send an SMS with your current GPS co-ordinates using a # Nokia SmartPhone and PyS60 # # Timothy Makobu, 01-01-2009 import positioning import messaging import appuifw import sys # Get your GPS co-ordinates # def getCoordinates(): positioning.select_module(positioning.default_module()) positioning.set_requestors([{'type':'service', 'format':'application','data':'position'}]) try: sys.stdout.write('Retrieving GPS co-ordinates ...\n') data = positioning.position(course=1, satellites=1) except: sys.stdout.write('Could not retrieve GPS co-ordinates\n\n\n') sys.exit(-1) else: sys.stdout.write('GPS co-ordinates retrieved\n') return (data['position']['latitude'], data['position'] ['longitude']) # Send your GPS co-ordinates as an SMS # def sendCoordinates(coords, number): message = u'I\'m at location:\nLatitute --> %f\nLongitute --> %f \n' % coords try: sys.stdout.write('Sending SMS ...\n') messaging.sms_send(number, message) except: sys.stdout.write('Could not send SMS :(\n\n\n') sys.exit(-1) else: sys.stdout.write('SMS sent :)\n') if __name__ == '__main__': presetPhoneNumber = None # Enter phoneNumber here eg '+25472200' phoneNumber = presetPhoneNumber or appuifw.query(u'Enter number: ','text') if not phoneNumber: sys.stdout.write('No number entered; exiting ...\n\n\n') sys.exit(-1) sendCoordinates(getCoordinates(), phoneNumber) -- http://mail.python.org/mailman/listinfo/python-list
parallelpython 1.5.7 crash
Hi all, Hi all, with the above version of parallelpython, what causes this? Traceback (most recent call last): File "C:\Users\tim\code_base\svn\octopus\parallel_python\pp.py", line 762, in __run sresult = worker.t.receive() File "C:\Users\tim\code_base\svn\octopus\parallel_python \pptransport.py", line 133, in receive msg = self.r.read(msg_len) OverflowError: long int too large to convert to int Unhandled exception in thread started by > Traceback (most recent call last): File "C:\Users\tim\code_base\svn\octopus\parallel_python\pp.py", line 771, in __run job.finalize(sresult) UnboundLocalError: local variable 'sresult' referenced before assignment -- http://mail.python.org/mailman/listinfo/python-list
multiprocessing module
I have a function that makes two subprocess.Popen() calls on a file. I have 8 cores. I need 8 instances of that function running in parallel at any given time till all the files are worked on. Can the multiprocessing module do this? If so, whats the best method? A technical overview of how the multiprocessing module actually works would also be really helpful. regards, mak. -- http://mail.python.org/mailman/listinfo/python-list
Re: parallelpython 1.5.7 crash
Thanks Zeph. -- http://mail.python.org/mailman/listinfo/python-list