Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: test/mm-disconnect

Issue 6731056: Update to test scripts to work with both ModemManager and Cromo (Closed) Base URL: ssh://gitrw.chromium.org:9222/flimflam.git@master
Patch Set: Fix review comments Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/mm-disable ('k') | test/mm-enable » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
3 import mm 7 import mm
4 import dbus 8 import dbus
5 import dbus.mainloop.glib 9 import dbus.mainloop.glib
6 import gobject 10 import gobject
7 import sys 11 import sys
8 12
9 waitcnt = 0 13 waitcnt = 0
10 def state_changed(old_state, new_state, reason, path): 14 def state_changed(old_state, new_state, reason, path):
11 global waitcnt 15 global waitcnt
12 if new_state == 60: 16 if new_state == 60:
13 print "Disconnect completed for", path 17 print "Disconnect completed for", path
14 else: 18 else:
15 print "Disconnect failed for", path 19 print "Disconnect failed for", path
16 waitcnt -= 1 20 waitcnt -= 1
17 if waitcnt <= 0: 21 » if waitcnt <= 0:
18 mainloop.quit() 22 mainloop.quit()
19 23
20 waitflag = False 24 waitflag = False
21 if len(sys.argv) > 1 and sys.argv[1] == '-w': 25 if len(sys.argv) > 1 and sys.argv[1] == '-w':
22 waitflag = True 26 waitflag = True
23 del sys.argv[1] 27 del sys.argv[1]
24 28
25 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) 29 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
26 30
27 manager = mm.ModemManager()
28
29 if waitflag: 31 if waitflag:
30 bus = dbus.SystemBus() 32 bus = dbus.SystemBus()
31 bus.add_signal_receiver(state_changed, 33 bus.add_signal_receiver(state_changed,
32 » » » bus_name="org.chromium.ModemManager", 34 » » » bus_name=manager.provider,
33 signal_name="StateChanged", 35 signal_name="StateChanged",
34 path_keyword="path") 36 path_keyword="path")
35 37
36 devices = manager.manager.EnumerateDevices() 38 devices = mm.EnumerateDevices()
37 39
38 for path in devices: 40 for manager, path in devices:
41
39 print "Disconnecting", path 42 print "Disconnecting", path
40 43
41 modem = manager.Modem(path) 44 modem = manager.Modem(path)
42 try: 45 try:
43 modem.Disconnect() 46 modem.Disconnect()
44 except dbus.exceptions.DBusException, e: 47 except dbus.exceptions.DBusException, e:
45 if e._dbus_error_name == "org.chromium.ModemManager.Error.Operat ionInitiated": 48 if e._dbus_error_name == "org.chromium.ModemManager.Error.Operat ionInitiated":
46 waitcnt += 1 49 waitcnt += 1
47 else: 50 else:
48 raise e 51 raise e
49 52
50 if waitflag and waitcnt != 0: 53 if waitflag and waitcnt != 0:
51 mainloop = gobject.MainLoop() 54 mainloop = gobject.MainLoop()
52 mainloop.run() 55 mainloop.run()
OLDNEW
« no previous file with comments | « test/mm-disable ('k') | test/mm-enable » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698