~ubuntu-branches/ubuntu/wily/modemmanager/wily

« back to all changes in this revision

Viewing changes to test/modem-autoenable.py

  • Committer: Package Import Robot
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2013-12-20 15:35:26 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20131220153526-j3xu9gp51ltzlizc
Tags: 1.0.0-1
* New upstream release. (Closes: #728214, #728215)
* debian/control: add a versioned dependency for libqmi -- we need at least
  version 1.4.
* debian/control: build-depends on libmbim-glib-dev 1.4
* debian/rules: run the local autogen.sh rather than gnome-autogen.sh.
* debian/rules: drop --with-tests. 
* debian/rules: clean up after gtk-doc files left around.
* debian/patches/glib_fixes.patch: link against glib explicitly for the
  huawei modem helper tests.
* debian/libmm-glib0.symbols: updated symbols.
* debian/watch: update watch file for new location of upstream source.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
2
 
# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3
 
#
4
 
# This program is free software; you can redistribute it and/or modify
5
 
# it under the terms of the GNU General Public License as published by
6
 
# the Free Software Foundation; either version 2 of the License, or
7
 
# (at your option) any later version.
8
 
#
9
 
# This program is distributed in the hope that it will be useful,
10
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
# GNU General Public License for more details:
13
 
#
14
 
# Copyright (C) 2011 Red Hat, Inc.
15
 
#
16
 
 
17
 
import gobject, sys, dbus
18
 
from dbus.mainloop.glib import DBusGMainLoop
19
 
 
20
 
DBusGMainLoop(set_as_default=True)
21
 
 
22
 
MM_DBUS_SERVICE='org.freedesktop.ModemManager'
23
 
MM_DBUS_PATH='/org/freedesktop/ModemManager'
24
 
MM_DBUS_INTERFACE='org.freedesktop.ModemManager'
25
 
MM_DBUS_INTERFACE_MODEM='org.freedesktop.ModemManager.Modem'
26
 
 
27
 
def modemAdded(modem_path):
28
 
    proxy = bus.get_object(MM_DBUS_SERVICE, modem_path)
29
 
    modem = dbus.Interface(proxy, dbus_interface=MM_DBUS_INTERFACE_MODEM)
30
 
    modem.Enable (True)
31
 
 
32
 
bus = dbus.SystemBus()
33
 
 
34
 
manager_proxy = bus.get_object(MM_DBUS_SERVICE, MM_DBUS_PATH)
35
 
manager_iface = dbus.Interface(manager_proxy, dbus_interface=MM_DBUS_INTERFACE)
36
 
 
37
 
# Enable modems that are already known
38
 
for m in manager_iface.EnumerateDevices():
39
 
    modemAdded(m)
40
 
 
41
 
# Listen for new modems
42
 
manager_iface.connect_to_signal("DeviceAdded", modemAdded)
43
 
 
44
 
# Start the mainloop and listen 
45
 
loop = gobject.MainLoop()
46
 
try:
47
 
    loop.run()
48
 
except KeyboardInterrupt:
49
 
    pass
50
 
sys.exit(0)