diff options
author | Ali Sabil <ali.sabil@gmail.com> | 2007-01-15 13:55:43 +0530 |
---|---|---|
committer | Ali Sabil <ali.sabil@gmail.com> | 2007-01-15 13:55:43 +0530 |
commit | 971ccb20bcf9283c7835461ab02b5bbeb97d72a5 (patch) | |
tree | c103dedbd9243acfbd273c3418c81e9d8aeb968a /test.py | |
parent | 0837f9b01ea78d40b1b04e22c35b81a7dcbb8cd5 (diff) |
- Started client implementation
- Re-added test.py
Diffstat (limited to 'test.py')
-rw-r--r-- | test.py | 76 |
1 files changed, 76 insertions, 0 deletions
@@ -0,0 +1,76 @@ +#!/usr/bin/env python + +import pymsn + +import logging +import gobject + +logging.basicConfig(level=logging.DEBUG) + +finished = False +def get_proxies(): + import urllib + proxies = urllib.getproxies() + result = {} + for type, url in proxies.items(): + if type == 'no': continue + result[type] = pymsn.Proxy(url) + return result + +class Client(pymsn.Client): + def __init__(self, account, quit): + server = ('207.46.109.66', 1863) + self.quit = quit + pymsn.Client.__init__(self, server, account, proxies = get_proxies()) + gobject.idle_add(self.connect) + + def connect(self): + self.login() + return False + + def on_connect_failure(self, proto): + print "Connect failed" + self.quit() + + def on_login_failure(self, proto): + print "Login failed" + self.quit() + + def on_login_success(self, proto): + self.profile.presence = pymsn.Presence.ONLINE + +def main(): + import sys + import getpass + import signal + + if len(sys.argv) < 2: + account = raw_input('Account: ') + else: + account = sys.argv[1] + + if len(sys.argv) < 3: + passwd = getpass.getpass('Password: ') + else: + passwd = sys.argv[2] + + mainloop = gobject.MainLoop(is_running=True) + + def quit(): + mainloop.quit() + + def sigterm_cb(): + gobject.idle_add(quit) + + signal.signal(signal.SIGTERM, sigterm_cb) + + n = Client((account, passwd), quit) + + while mainloop.is_running(): + try: + mainloop.run() + except KeyboardInterrupt: + quit() + +if __name__ == '__main__': + main() |