Add configuration file for DBus access
[platform/upstream/connman.git] / test / set-clock
1 #!/usr/bin/python
2
3 import sys
4 import dbus
5
6 def print_usage():
7         print "Usage: %s TimeUpdates|TimezoneUpdates manual|auto" % (sys.argv[0])
8         sys.exit(1)
9
10
11 def make_variant(string):
12         return dbus.String(string, variant_level=1)
13
14
15 if (len(sys.argv) != 3):
16         print_usage()
17
18 if (sys.argv[1] != "TimeUpdates" and sys.argv[1] != "TimezoneUpdates"):
19         print_usage()
20
21 if (sys.argv[2] != "manual" and sys.argv[2] != "auto"):
22         print_usage()
23
24 bus = dbus.SystemBus()
25
26 clock = dbus.Interface(bus.get_object('net.connman', '/'),
27                                         'net.connman.Clock')
28
29 print "Setting %s to %s" % (sys.argv[1], sys.argv[2])
30
31 clock.SetProperty(sys.argv[1], make_variant(sys.argv[2]),
32                   signature=dbus.Signature('sv'))