Re: [PATCH 2/2] test: Arg parsing for p2p-on-supplication

2014-05-14 Thread Tomasz Bursztyka

Hi Eduardo,

Minor issue:


@@ -100,37 +105,33 @@ class Wpa_s:
  bus.add_signal_receiver(self.__InterfaceRemoved, path=WPA_PATH,
  signal_name='InterfaceRemoved')
  self.__reset()
+
+self.debug = False


unnecessary since it's done below already.


+
+self.bus = bus
+
  self.debug = False
  



Rest is fine.

Thanks,

Tomasz

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH 2/2] test: Arg parsing for p2p-on-supplication

2014-05-14 Thread Eduardo Abinader
Hi Tomasz,
On Wed, May 14, 2014 at 2:54 AM, Tomasz Bursztyka
tomasz.burszt...@linux.intel.com wrote:
 Hi Eduardo,

 Minor issue:

 @@ -100,37 +105,33 @@ class Wpa_s:
   bus.add_signal_receiver(self.__InterfaceRemoved, path=WPA_PATH,
   signal_name='InterfaceRemoved')
   self.__reset()
 +
 +self.debug = False


 unnecessary since it's done below already.

Should I resend the patch or send a new one fixing this issue?


 +
 +self.bus = bus
 +
   self.debug = False




 Rest is fine.

 Thanks,

Thanks.


 Tomasz

 ___
 connman mailing list
 connman@connman.net
 https://lists.connman.net/mailman/listinfo/connman
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH 2/2] test: Arg parsing for p2p-on-supplication

2014-05-14 Thread Eduardo Abinader
Argument parsing functionality for commands and options:
- dbus is now wpa_s property
- help is being shown from the command_list built in arg
parse time
- Added enum like class (ArgFields) for future options in arg
parsing
---
 test/p2p-on-supplicant | 174 +++--
 1 file changed, 126 insertions(+), 48 deletions(-)

diff --git a/test/p2p-on-supplicant b/test/p2p-on-supplicant
index 734396e..025bf6e 100755
--- a/test/p2p-on-supplicant
+++ b/test/p2p-on-supplicant
@@ -1,12 +1,13 @@
 #!/usr/bin/python
 
 from os import O_NONBLOCK
-from sys import stdin, stdout, exit, version_info
+from sys import stdin, stdout, exit, version_info, argv
 from fcntl import fcntl, F_GETFL, F_SETFL
 import glib
 import dbus
 import dbus.mainloop.glib
 import gobject
+import argparse
 
 WPA_NAME='fi.w1.wpa_supplicant1'
 WPA_INTF='fi.w1.wpa_supplicant1'
@@ -19,6 +20,10 @@ DBUS_PROPERTIES_INTF = 'org.freedesktop.DBus.Properties'
 
 P2P_GROUP_CAPAB_GROUP_OWNER = 1  0
 
+class ArgFields:
+for i in ('help','metavar'):
+exec('{}={}'.format(i,i))
+
 class InputLine:
 def __init__(self, handler):
 self.line = ''
@@ -91,7 +96,7 @@ def print_tuple(t):
 print 'Element: %s' % e
 
 class Wpa_s:
-def __init__(self, iface_name = None):
+def __init__(self, bus, iface_name, command):
 self.wpa = dbus.Interface(bus.get_object(WPA_NAME, WPA_PATH), WPA_INTF)
 bus.add_signal_receiver(self.__wpa_property_changed, path=WPA_PATH,
 member_keyword='signal')
@@ -100,37 +105,31 @@ class Wpa_s:
 bus.add_signal_receiver(self.__InterfaceRemoved, path=WPA_PATH,
 signal_name='InterfaceRemoved')
 self.__reset()
+
+self.bus = bus
+
 self.debug = False
 
 self.line_in = InputLine(self.__command)
 
-if self.iface_name != None:
-self.create_if(self.iface_name)
+if iface_name:
+try:
+self.create_if([iface_name])
+except:
+print Error creating interface: %s % iface_name
+
+if len(command.strip(' ')):
+self.__command(command)
 
 def help(self, args):
-print 'Commands:'
-print 'quit'
-print 'enable_debug'
-print 'disable_debug'
-print 'create_if iface_name'
-print 'get_if iface_name'
-print 'del_if'
-print 'scan'
-print 'p2p_find'
-print 'p2p_stop_find'
-print 'p2p_flush'
-print 'p2p_group_add'
-print 'p2p_group_remove'
-print 'p2p_group'
-print 'p2p_peers'
-print 'p2p_peer p2p device name'
-print 'p2p_connect p2p device name'
-print 'p2p_disconnect p2p device name'
-print 'p2p_serv_disc_req'
-print 'p2p_serv_disc_cancel_req identifier'
-print 'p2p_service_add service type version/query 
service/response'
-print 'p2p_service_del service type version/query [service]'
-print 'p2p_service_flush'
+list = self.command_list.keys()
+list.sort()
+for key in list:
+help = ''
+if (self.command_list[key].has_key(ArgFields.help)):
+help = self.command_list[key][ArgFields.help]
+
+print %s\t%s % (key.rjust(25), help.ljust(50))
 
 def __command(self, cmd_line):
 cmd = cmd_line.split(' ')
@@ -172,7 +171,7 @@ class Wpa_s:
 def __DeviceFound(self, object_path):
 self.peers[object_path] = None
 
-peer = bus.get_object(WPA_INTF, object_path)
+peer = self.bus.get_object(WPA_INTF, object_path)
 peer_if = dbus.Interface(peer, DBUS_PROPERTIES_INTF)
 
 self.peers[object_path] = peer_if.GetAll(WPA_PEER_INTF)
@@ -201,35 +200,36 @@ class Wpa_s:
 
 def __GroupStarted(self, properties):
 self.group_obj = properties['group_object']
-bus.add_signal_receiver(self.__PeerJoined,
+self.bus.add_signal_receiver(self.__PeerJoined,
 dbus_interface=WPA_GROUP_INTF,
 path=self.group_obj,
 signal_name='PeerJoined')
-bus.add_signal_receiver(self.__PeerDisconnected,
+self.bus.add_signal_receiver(self.__PeerDisconnected,
 dbus_interface=WPA_GROUP_INTF,
 path=self.group_obj,
 signal_name='PeerDisconnected')
 
 self.group_iface_path = properties['interface_object']
-self.group_if = dbus.Interface(bus.get_object(WPA_INTF,
+self.group_if = dbus.Interface(self.bus.get_object(WPA_INTF,
self.group_iface_path),
WPA_P2P_INTF)
-bus.add_signal_receiver(self.__group_if_property_changed,
+

Re: [PATCH 2/2] test: Arg parsing for p2p-on-supplication

2014-05-14 Thread Patrik Flykt
On Wed, 2014-05-14 at 06:25 -0400, Eduardo Abinader wrote:
 Should I resend the patch or send a new one fixing this issue?

Yes, please. Once you do that, please add a version to the patch message
like so: 'git format-patch --cover-letter --subject-prefix=PATCH
v3 ...'. This way it's much easier to find the whole patch set as they
all dangle from the cover letter and the version number makes it clear
which one is the newest.

We can omit further resends this time if the newest version was sent
today 07:39:34 -0400 (2014-05-14 14:39:34)

Cheers,

Patrik

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH 2/2] test: Arg parsing for p2p-on-supplication

2014-05-14 Thread Patrik Flykt
On Wed, 2014-05-14 at 07:39 -0400, Eduardo Abinader wrote:
 Argument parsing functionality for commands and options:
   - dbus is now wpa_s property
   - help is being shown from the command_list built in arg
   parse time
   - Added enum like class (ArgFields) for future options in arg
   parsing

Applied, thanks!

Patrik

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH 2/2] test: Arg parsing for p2p-on-supplication

2014-05-13 Thread Eduardo Abinader
Argument parsing functionality for commands and options.
---
 test/p2p-on-supplicant | 176 +++--
 1 file changed, 128 insertions(+), 48 deletions(-)

diff --git a/test/p2p-on-supplicant b/test/p2p-on-supplicant
index 734396e..bc10ad2 100755
--- a/test/p2p-on-supplicant
+++ b/test/p2p-on-supplicant
@@ -1,12 +1,13 @@
 #!/usr/bin/python
 
 from os import O_NONBLOCK
-from sys import stdin, stdout, exit, version_info
+from sys import stdin, stdout, exit, version_info, argv
 from fcntl import fcntl, F_GETFL, F_SETFL
 import glib
 import dbus
 import dbus.mainloop.glib
 import gobject
+import argparse
 
 WPA_NAME='fi.w1.wpa_supplicant1'
 WPA_INTF='fi.w1.wpa_supplicant1'
@@ -19,6 +20,10 @@ DBUS_PROPERTIES_INTF = 'org.freedesktop.DBus.Properties'
 
 P2P_GROUP_CAPAB_GROUP_OWNER = 1  0
 
+class ArgFields:
+for i in ('help','metavar'):
+exec('{}={}'.format(i,i))
+
 class InputLine:
 def __init__(self, handler):
 self.line = ''
@@ -91,7 +96,7 @@ def print_tuple(t):
 print 'Element: %s' % e
 
 class Wpa_s:
-def __init__(self, iface_name = None):
+def __init__(self, bus, iface_name, command):
 self.wpa = dbus.Interface(bus.get_object(WPA_NAME, WPA_PATH), WPA_INTF)
 bus.add_signal_receiver(self.__wpa_property_changed, path=WPA_PATH,
 member_keyword='signal')
@@ -100,37 +105,33 @@ class Wpa_s:
 bus.add_signal_receiver(self.__InterfaceRemoved, path=WPA_PATH,
 signal_name='InterfaceRemoved')
 self.__reset()
+
+self.debug = False
+
+self.bus = bus
+
 self.debug = False
 
 self.line_in = InputLine(self.__command)
 
-if self.iface_name != None:
-self.create_if(self.iface_name)
+if iface_name:
+try:
+self.create_if([iface_name])
+except:
+print Error creating interface: %s % iface_name
+
+if len(command.strip(' ')):
+self.__command(command)
 
 def help(self, args):
-print 'Commands:'
-print 'quit'
-print 'enable_debug'
-print 'disable_debug'
-print 'create_if iface_name'
-print 'get_if iface_name'
-print 'del_if'
-print 'scan'
-print 'p2p_find'
-print 'p2p_stop_find'
-print 'p2p_flush'
-print 'p2p_group_add'
-print 'p2p_group_remove'
-print 'p2p_group'
-print 'p2p_peers'
-print 'p2p_peer p2p device name'
-print 'p2p_connect p2p device name'
-print 'p2p_disconnect p2p device name'
-print 'p2p_serv_disc_req'
-print 'p2p_serv_disc_cancel_req identifier'
-print 'p2p_service_add service type version/query 
service/response'
-print 'p2p_service_del service type version/query [service]'
-print 'p2p_service_flush'
+list = self.command_list.keys()
+list.sort()
+for key in list:
+help = ''
+if (self.command_list[key].has_key(ArgFields.help)):
+help = self.command_list[key][ArgFields.help]
+
+print %s\t%s % (key.rjust(25), help.ljust(50))
 
 def __command(self, cmd_line):
 cmd = cmd_line.split(' ')
@@ -172,7 +173,7 @@ class Wpa_s:
 def __DeviceFound(self, object_path):
 self.peers[object_path] = None
 
-peer = bus.get_object(WPA_INTF, object_path)
+peer = self.bus.get_object(WPA_INTF, object_path)
 peer_if = dbus.Interface(peer, DBUS_PROPERTIES_INTF)
 
 self.peers[object_path] = peer_if.GetAll(WPA_PEER_INTF)
@@ -201,35 +202,36 @@ class Wpa_s:
 
 def __GroupStarted(self, properties):
 self.group_obj = properties['group_object']
-bus.add_signal_receiver(self.__PeerJoined,
+self.bus.add_signal_receiver(self.__PeerJoined,
 dbus_interface=WPA_GROUP_INTF,
 path=self.group_obj,
 signal_name='PeerJoined')
-bus.add_signal_receiver(self.__PeerDisconnected,
+self.bus.add_signal_receiver(self.__PeerDisconnected,
 dbus_interface=WPA_GROUP_INTF,
 path=self.group_obj,
 signal_name='PeerDisconnected')
 
 self.group_iface_path = properties['interface_object']
-self.group_if = dbus.Interface(bus.get_object(WPA_INTF,
+self.group_if = dbus.Interface(self.bus.get_object(WPA_INTF,
self.group_iface_path),
WPA_P2P_INTF)
-bus.add_signal_receiver(self.__group_if_property_changed,
+self.bus.add_signal_receiver(self.__group_if_property_changed,
 dbus_interface=WPA_IF_INTF,
 path=self.group_iface_path,
  

[PATCH 2/2] test: Arg parsing for p2p-on-supplication

2014-05-13 Thread Eduardo Abinader
Argument parsing functionality for commands and options.
---
 test/p2p-on-supplicant | 176 +++--
 1 file changed, 128 insertions(+), 48 deletions(-)

diff --git a/test/p2p-on-supplicant b/test/p2p-on-supplicant
index 734396e..7930242 100755
--- a/test/p2p-on-supplicant
+++ b/test/p2p-on-supplicant
@@ -1,12 +1,13 @@
 #!/usr/bin/python
 
 from os import O_NONBLOCK
-from sys import stdin, stdout, exit, version_info
+from sys import stdin, stdout, exit, version_info, argv
 from fcntl import fcntl, F_GETFL, F_SETFL
 import glib
 import dbus
 import dbus.mainloop.glib
 import gobject
+import argparse
 
 WPA_NAME='fi.w1.wpa_supplicant1'
 WPA_INTF='fi.w1.wpa_supplicant1'
@@ -19,6 +20,10 @@ DBUS_PROPERTIES_INTF = 'org.freedesktop.DBus.Properties'
 
 P2P_GROUP_CAPAB_GROUP_OWNER = 1  0
 
+class ArgFields:
+for i in ('help','metavar'):
+exec('{}={}'.format(i,i))
+
 class InputLine:
 def __init__(self, handler):
 self.line = ''
@@ -91,7 +96,7 @@ def print_tuple(t):
 print 'Element: %s' % e
 
 class Wpa_s:
-def __init__(self, iface_name = None):
+def __init__(self, bus, iface_name, command):
 self.wpa = dbus.Interface(bus.get_object(WPA_NAME, WPA_PATH), WPA_INTF)
 bus.add_signal_receiver(self.__wpa_property_changed, path=WPA_PATH,
 member_keyword='signal')
@@ -100,37 +105,33 @@ class Wpa_s:
 bus.add_signal_receiver(self.__InterfaceRemoved, path=WPA_PATH,
 signal_name='InterfaceRemoved')
 self.__reset()
+
+self.debug = False
+
+self.bus = bus
+
 self.debug = False
 
 self.line_in = InputLine(self.__command)
 
-if self.iface_name != None:
-self.create_if(self.iface_name)
+if iface_name:
+try:
+self.create_if([iface_name])
+except:
+print Error creating interface: %s % iface_name
+
+if len(command.strip(' ')):
+self.__command(command)
 
 def help(self, args):
-print 'Commands:'
-print 'quit'
-print 'enable_debug'
-print 'disable_debug'
-print 'create_if iface_name'
-print 'get_if iface_name'
-print 'del_if'
-print 'scan'
-print 'p2p_find'
-print 'p2p_stop_find'
-print 'p2p_flush'
-print 'p2p_group_add'
-print 'p2p_group_remove'
-print 'p2p_group'
-print 'p2p_peers'
-print 'p2p_peer p2p device name'
-print 'p2p_connect p2p device name'
-print 'p2p_disconnect p2p device name'
-print 'p2p_serv_disc_req'
-print 'p2p_serv_disc_cancel_req identifier'
-print 'p2p_service_add service type version/query 
service/response'
-print 'p2p_service_del service type version/query [service]'
-print 'p2p_service_flush'
+list = self.command_list.keys()
+list.sort()
+for key in list:
+help = ''
+if (self.command_list[key].has_key(ArgFields.help)):
+help = self.command_list[key][ArgFields.help]
+
+print %s\t%s % (key.rjust(25), help.ljust(50))
 
 def __command(self, cmd_line):
 cmd = cmd_line.split(' ')
@@ -172,7 +173,7 @@ class Wpa_s:
 def __DeviceFound(self, object_path):
 self.peers[object_path] = None
 
-peer = bus.get_object(WPA_INTF, object_path)
+peer = self.bus.get_object(WPA_INTF, object_path)
 peer_if = dbus.Interface(peer, DBUS_PROPERTIES_INTF)
 
 self.peers[object_path] = peer_if.GetAll(WPA_PEER_INTF)
@@ -201,35 +202,36 @@ class Wpa_s:
 
 def __GroupStarted(self, properties):
 self.group_obj = properties['group_object']
-bus.add_signal_receiver(self.__PeerJoined,
+self.bus.add_signal_receiver(self.__PeerJoined,
 dbus_interface=WPA_GROUP_INTF,
 path=self.group_obj,
 signal_name='PeerJoined')
-bus.add_signal_receiver(self.__PeerDisconnected,
+self.bus.add_signal_receiver(self.__PeerDisconnected,
 dbus_interface=WPA_GROUP_INTF,
 path=self.group_obj,
 signal_name='PeerDisconnected')
 
 self.group_iface_path = properties['interface_object']
-self.group_if = dbus.Interface(bus.get_object(WPA_INTF,
+self.group_if = dbus.Interface(self.bus.get_object(WPA_INTF,
self.group_iface_path),
WPA_P2P_INTF)
-bus.add_signal_receiver(self.__group_if_property_changed,
+self.bus.add_signal_receiver(self.__group_if_property_changed,
 dbus_interface=WPA_IF_INTF,
 path=self.group_iface_path,