From 830e3f087695d30661ad9a9aef60425d474efc46 Mon Sep 17 00:00:00 2001 From: Ravi kumar Veeramally Date: Wed, 2 May 2012 19:00:43 +0300 Subject: [PATCH] test: Add a device push script --- Makefile.am | 3 ++- test/push-device | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100755 test/push-device diff --git a/Makefile.am b/Makefile.am index 30fa336..c709cb6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -65,7 +65,8 @@ EXTRA_DIST = src/genbuiltin $(doc_files) test_scripts = test/disable-adapter test/enable-adapter test/list-adapters \ test/dump-device test/dump-tag test/dump-record \ - test/monitor-near test/start-poll test/stop-poll test/write-tag + test/monitor-near test/start-poll test/stop-poll test/write-tag \ + test/push-device if TEST testdir = $(pkglibdir)/test diff --git a/test/push-device b/test/push-device new file mode 100755 index 0000000..a34bc6d --- /dev/null +++ b/test/push-device @@ -0,0 +1,43 @@ +#!/usr/bin/python + +import sys +import dbus + +def help_text(): + print "Usage: %s <...>" % (sys.argv[0]) + print " If type is Text, parameters are " + print " If type is URI, parameters are " + print " If type is SmartPoster, parameters are " + print "e.g. < %s /org/neard/nfc0/device0 Text UTF-8 en-US hello,Type2! >" % (sys.argv[0]) + print "e.g. < %s /org/neard/nfc0/device0 URI http://www.nfc-forum.com >" % (sys.argv[0]) + print "e.g. < %s /org/neard/nfc0/device0 SmartPoster http://www.nfc-forum.com >" % (sys.argv[0]) + sys.exit(1) + +if len(sys.argv) < 2: + help_text() + +bus = dbus.SystemBus() + +device = dbus.Interface(bus.get_object("org.neard", sys.argv[1]), + "org.neard.Device") + +if len(sys.argv) == 6: + if sys.argv[2] in ["Text"]: + device.Push(({ "Type" : "Text", + "Encoding" : sys.argv[3], + "Language" : sys.argv[4], + "Representation" : sys.argv[5] })) + else: + help_text() + +elif len(sys.argv) == 4: + if sys.argv[2] in ["URI"]: + device.Push(({ "Type" : "URI", + "URI" : sys.argv[3] })) + elif sys.argv[2] in ["SmartPoster"]: + device.Push(({ "Type" : "SmartPoster", + "URI" : sys.argv[3] })) + else: + help_text() +else: + help_text() -- 2.7.4