UbuntuOneFilesNotes11.10
Attachment '2.py'
Download 1 #!/usr/bin/python
2
3 import sys
4
5 _login_success = False
6 def login():
7 from gobject import MainLoop
8 from dbus.mainloop.glib import DBusGMainLoop
9 from ubuntuone.platform.credentials import CredentialsManagementTool
10
11 global _login_success
12 _login_success = False
13
14 DBusGMainLoop(set_as_default=True)
15 loop = MainLoop()
16
17 def quit(result):
18 global _login_success
19 loop.quit()
20 if result:
21 _login_success = True
22
23 cd = CredentialsManagementTool()
24 d = cd.login()
25 d.addCallbacks(quit)
26 loop.run()
27 if not _login_success:
28 sys.exit(1)
29
30 def logout():
31 from gobject import MainLoop
32 from dbus.mainloop.glib import DBusGMainLoop
33 from ubuntuone.platform.credentials import CredentialsManagementTool
34
35 DBusGMainLoop(set_as_default=True)
36 loop = MainLoop()
37
38 def quit(result):
39 loop.quit()
40
41 cd = CredentialsManagementTool()
42 d = cd.clear_credentials()
43 d.addCallbacks(quit)
44 loop.run()
45
46
47 if len(sys.argv) <= 1:
48 print "Need more arguments"
49 sys.exit(1)
50
51 if sys.argv[1] == "login":
52 login()
53 elif sys.argv[1] == "logout":
54 logout()
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.