~clint-fewbar/ubuntu/precise/modemmanager/fix-removed-not-purged

« back to all changes in this revision

Viewing changes to test/ussd.py

  • Committer: Package Import Robot
  • Author(s): Artem Popov
  • Date: 2012-01-02 13:32:18 UTC
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: package-import@ubuntu.com-20120102133218-f2xuil48af71xa7b
Tags: upstream-0.5+git.20111231t174444.1e332ab
ImportĀ upstreamĀ versionĀ 0.5+git.20111231t174444.1e332ab

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) 2010 Guido Guenther <agx@sigxcpu.org>
 
15
#
 
16
# Usage: ./test/ussd.py /org/freedesktop/ModemManager/Modems/0 '*130#'
 
17
 
 
18
import sys, dbus, re
 
19
 
 
20
MM_DBUS_SERVICE='org.freedesktop.ModemManager'
 
21
MM_DBUS_INTERFACE_USSD='org.freedesktop.ModemManager.Modem.Gsm.Ussd'
 
22
 
 
23
if len(sys.argv) != 3:
 
24
    print "Usage: %s dbus_object [<ussd>|cancel]" % sys.argv[0]
 
25
    sys.exit(1)
 
26
else:
 
27
    arg = sys.argv[2]
 
28
 
 
29
bus = dbus.SystemBus()
 
30
objpath = sys.argv[1]
 
31
if objpath[:1] != '/':
 
32
    objpath = "/org/freedesktop/ModemManager/Modems/" + str(objpath)
 
33
proxy = bus.get_object(MM_DBUS_SERVICE, objpath)
 
34
 
 
35
modem = dbus.Interface(proxy, dbus_interface=MM_DBUS_INTERFACE_USSD)
 
36
 
 
37
# For testing purposes treat all "common" USSD sequences as initiate and the
 
38
# rest (except for cancel) as response. See GSM 02.90.
 
39
initiate_re = re.compile('[*#]{1,3}1[0-9][0-9].*#')
 
40
 
 
41
if initiate_re.match(arg):
 
42
    ret = modem.Initiate(arg)
 
43
elif arg == "cancel":
 
44
    ret = modem.Cancel()
 
45
else:
 
46
    ret = modem.Respond(arg)
 
47
print ret
 
48