All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] test: Add new script for SS GCF test cases
@ 2012-05-23  8:42 Guillaume Zajac
  2012-05-30  4:54 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: Guillaume Zajac @ 2012-05-23  8:42 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2082 bytes --]

This script uses dynamic SS codes in input and
displays answers to the different requests.
It handles all SS: call barring, call forwarding,
call waiting, CLIP, CLIR, ...
---
 test/test-ss |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 55 insertions(+), 0 deletions(-)
 create mode 100755 test/test-ss

diff --git a/test/test-ss b/test/test-ss
new file mode 100755
index 0000000..adeff33
--- /dev/null
+++ b/test/test-ss
@@ -0,0 +1,55 @@
+#!/usr/bin/python
+
+import sys
+import gobject
+
+import dbus
+import dbus.mainloop.glib
+
+if __name__ == "__main__":
+	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+	bus = dbus.SystemBus()
+
+	manager = dbus.Interface(bus.get_object('org.ofono', '/'),
+							'org.ofono.Manager')
+
+	modems = manager.GetModems()
+	modem = modems[0][0]
+
+	if (len(sys.argv) == 2):
+		ss_code = sys.argv[1]
+	else:
+		modem = sys.argv[1]
+		ss_code = sys.argv[2]
+
+	ss = dbus.Interface(bus.get_object('org.ofono', modem),
+					'org.ofono.SupplementaryServices')
+
+	try:
+		ss_type, properties = ss.Initiate(ss_code, timeout=100)
+	except dbus.DBusException, e:
+		print "Unable to perform operation: ", e
+		sys.exit(1);
+
+	if (ss_type == "CallBarring"):
+		print "%s : Operation [ %s ] Service Type [ %s ]" % (ss_type, properties[0], properties[1])
+		for key in properties[2]:
+			print "%s : %s" % (key, properties[2][key])
+		sys.exit(1);
+	elif (ss_type == "CallForwarding"):
+		print "%s : Operation [ %s ] Service Type [ %s ]" % (ss_type, properties[0], properties[1])
+		for key in properties[2]:
+			print "%s : %s" % (key, properties[2][key])
+		sys.exit(1);
+	elif (ss_type == "CallWaiting"):
+		print "%s : Operation [ %s ]" % (ss_type, properties[0])
+		for key in properties[1]:
+			print "%s : %s" % (key, properties[1][key])
+		sys.exit(1);
+	else:
+		print "%s : Operation [ %s ] Status [ %s ]" % (ss_type, properties[0], properties[1])
+		sys.exit(1);
+
+	mainloop = gobject.MainLoop()
+	mainloop.run()
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] test: Add new script for SS GCF test cases
  2012-05-23  8:42 [PATCH] test: Add new script for SS GCF test cases Guillaume Zajac
@ 2012-05-30  4:54 ` Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2012-05-30  4:54 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2570 bytes --]

Hi Guillaume,

On 05/23/2012 03:42 AM, Guillaume Zajac wrote:
> This script uses dynamic SS codes in input and
> displays answers to the different requests.
> It handles all SS: call barring, call forwarding,
> call waiting, CLIP, CLIR, ...
> ---
>   test/test-ss |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>   1 files changed, 55 insertions(+), 0 deletions(-)
>   create mode 100755 test/test-ss
>
> diff --git a/test/test-ss b/test/test-ss
> new file mode 100755
> index 0000000..adeff33
> --- /dev/null
> +++ b/test/test-ss
> @@ -0,0 +1,55 @@
> +#!/usr/bin/python
> +
> +import sys
> +import gobject

What is gobject for?
> +
> +import dbus
> +import dbus.mainloop.glib

Why do you need the mainloop?

> +
> +if __name__ == "__main__":
> +	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
> +
> +	bus = dbus.SystemBus()
> +
> +	manager = dbus.Interface(bus.get_object('org.ofono', '/'),
> +							'org.ofono.Manager')
> +
> +	modems = manager.GetModems()
> +	modem = modems[0][0]
> +
> +	if (len(sys.argv) == 2):
> +		ss_code = sys.argv[1]
> +	else:
> +		modem = sys.argv[1]
> +		ss_code = sys.argv[2]
> +
> +	ss = dbus.Interface(bus.get_object('org.ofono', modem),
> +					'org.ofono.SupplementaryServices')
> +
> +	try:
> +		ss_type, properties = ss.Initiate(ss_code, timeout=100)
> +	except dbus.DBusException, e:
> +		print "Unable to perform operation: ", e
> +		sys.exit(1);
> +
> +	if (ss_type == "CallBarring"):
> +		print "%s : Operation [ %s ] Service Type [ %s ]" % (ss_type, properties[0], properties[1])
> +		for key in properties[2]:
> +			print "%s : %s" % (key, properties[2][key])
> +		sys.exit(1);

This sys.exit seems unnecessary, and since the operation succeeded you 
should be returning 0 anyway.

> +	elif (ss_type == "CallForwarding"):
> +		print "%s : Operation [ %s ] Service Type [ %s ]" % (ss_type, properties[0], properties[1])
> +		for key in properties[2]:
> +			print "%s : %s" % (key, properties[2][key])
> +		sys.exit(1);

ditto

> +	elif (ss_type == "CallWaiting"):
> +		print "%s : Operation [ %s ]" % (ss_type, properties[0])
> +		for key in properties[1]:
> +			print "%s : %s" % (key, properties[1][key])
> +		sys.exit(1);

ditto

> +	else:
> +		print "%s : Operation [ %s ] Status [ %s ]" % (ss_type, properties[0], properties[1])
> +		sys.exit(1);

ditto
> +
> +	mainloop = gobject.MainLoop()
> +	mainloop.run()

This seems unnecessary as well since you're not actually using a main loop.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-05-30  4:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-23  8:42 [PATCH] test: Add new script for SS GCF test cases Guillaume Zajac
2012-05-30  4:54 ` Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.