File: get_bindingstate.py

package info (click to toggle)
synce-sync-engine 0.11.1-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 996 kB
  • ctags: 923
  • sloc: python: 8,586; xml: 949; makefile: 51; sh: 7
file content (37 lines) | stat: -rw-r--r-- 959 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env python

import dbus
import sys

sys.path.insert(0, "..")
from SyncEngine.constants import *

stab = { BSTATE_DEVNOTCONNECTED :  "device not connected",
         BSTATE_DEVNOTBOUND     :  "device connected but no valid partnership binding available",
	 BSTATE_DEVBOUND        :  "device connected and bound, ready to sync"
       }

try:
	engine = dbus.Interface(dbus.SessionBus().get_object(DBUS_SYNCENGINE_BUSNAME, DBUS_SYNCENGINE_OBJPATH), DBUS_SYNCENGINE_BUSNAME)
	item_types = engine.GetItemTypes()
except:
	print "\nerror: unable to connect to running sync-engine"
	print "\nPlease ensure sync-engine is running before executing this command\n"
	sys.exit(1)

try:
	pstate = engine.GetDeviceBindingState()

	if pstate in stab.keys():
		print "\nDevice state - %s\n" % stab[pstate]
	else:
		print "\nUnknown device state returned from sync-engine\n"

		
except dbus.DBusException,e:
	
	print "error: %s" % e._dbus_error_name
	sys.exit(0)