/usr/share/doc/syncevolution-dbus/examples/dbus-server-sync.py is in syncevolution-dbus 1.2.2-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | #! /usr/bin/python
'''Runs a sync.
Usage: dbus-server-sync <server> <mode> <source modes>
<server> - configuration name
<mode> - "", "two-way", "disabled", ...
<source modes> - "{}" or Python hash (like {"addressbook": "refresh-from-server"})
'''
import dbus
from dbus.mainloop.glib import DBusGMainLoop
import gobject
import sys
DBusGMainLoop(set_as_default=True)
bus = dbus.SessionBus()
object = dbus.Interface(bus.get_object('org.syncevolution',
'/org/syncevolution/Server'),
'org.syncevolution.Server')
loop = gobject.MainLoop()
sessionpath = None
def SessionChanged(object, ready):
print "SessionChanged:", object, ready
if sessionpath == object:
loop.quit()
bus.add_signal_receiver(SessionChanged,
'SessionChanged',
'org.syncevolution.Server',
'org.syncevolution',
None,
byte_arrays=True)
dummysessionpath = object.StartSession("")
sessionpath = object.StartSession(sys.argv[1])
# detach from dummy session so that real session can run
session = dbus.Interface(bus.get_object('org.syncevolution',
dummysessionpath),
'org.syncevolution.Session')
session.Detach()
session = dbus.Interface(bus.get_object('org.syncevolution',
sessionpath),
'org.syncevolution.Session')
print 'session created:', session.GetStatus(), session.GetProgress()
# wait for session ready
loop.run()
print 'session ready:', session.GetStatus(), session.GetProgress()
session.Sync(sys.argv[2], eval(sys.argv[3]))
print 'sync started:', session.GetStatus(), session.GetProgress()
# wait for session done
loop.run()
print 'done:', session.GetStatus(), session.GetProgress()
|