Discussion:
PATCH: udev-synce-serial
Karl Relton
2010-12-16 17:43:58 UTC
Permalink
I tried the new udev based connector on Ubuntu (Maverick) from the
development ppa.

To get it to work I had to apply the following patch:


--- udev-synce-serial 2010-12-16 17:38:20.517195997 +0000
+++ udev-synce-serial.orig 2010-11-15 20:23:51.628813001 +0000
@@ -39,7 +39,7 @@
# there are no python bindings for udev, so this is a little awkward

# get device name
- cmd_list = ["/sbin/udevadm", "info", "--path="+device_path, "--query=name"]
+ cmd_list = ["udevadm", "info", "--path="+devpath, "--query=name"]
try:
proc = subprocess.Popen(cmd_list, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output_text = proc.communicate()[0]
@@ -55,7 +55,7 @@
devname = output_text.strip()

# get parent device path
- match_obj = re.match('^(.+)/'+devname+'/tty/'+devname, device_path)
+ match_obj = re.match('^(.+)/'+name+"/"+subsystem+'/'+name, devpath)
if match_obj == None:
logger.error("failed to get parent device path from udev")
sys.exit(1)
@@ -63,7 +63,7 @@
parent_devpath = match_obj.group(1)

# find all relevant child devices of the parent
- cmd_list = ["/sbin/udevadm", "info", "--export-db"]
+ cmd_list = ["udevadm", "info", "--export-db"]
try:
proc = subprocess.Popen(cmd_list, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output_text = proc.communicate()[0]
@@ -77,7 +77,7 @@
sys.exit(1)

output_list = output_text.split('\n')
- devpath_re = re.compile('^P: ('+parent_devpath+'.+/tty/.+)')
+ devpath_re = re.compile('^P: ('+parent_devpath+'.+/'+subsystem+'/.+)')

devpath_list = []
for line in output_list:
David Eriksson
2010-12-17 16:01:38 UTC
Permalink
Thanks! Maybe those changes should be build options or configuration
options? For example, udevadm might not be in PATH...


Best regards,

David Eriksson
Thanks! Maybe those changes should be build options or configuration
options? For example, udevadm might not be in PATH...
Best regards,
David Eriksson
On Thu, Dec 16, 2010 at 18:43, Karl Relton
Post by Karl Relton
I tried the new udev based connector on Ubuntu (Maverick) from the
development ppa.
--- udev-synce-serial   2010-12-16 17:38:20.517195997 +0000
+++ udev-synce-serial.orig      2010-11-15 20:23:51.628813001 +0000
@@ -39,7 +39,7 @@
        # there are no python bindings for udev, so this is a little awkward
        # get device name
-        cmd_list = ["/sbin/udevadm", "info", "--path="+device_path, "--query=name"]
+        cmd_list = ["udevadm", "info", "--path="+devpath, "--query=name"]
            proc = subprocess.Popen(cmd_list, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
            output_text = proc.communicate()[0]
@@ -55,7 +55,7 @@
        devname = output_text.strip()
        # get parent device path
-        match_obj = re.match('^(.+)/'+devname+'/tty/'+devname, device_path)
+        match_obj = re.match('^(.+)/'+name+"/"+subsystem+'/'+name, devpath)
            logger.error("failed to get parent device path from udev")
            sys.exit(1)
@@ -63,7 +63,7 @@
        parent_devpath = match_obj.group(1)
        # find all relevant child devices of the parent
-        cmd_list = ["/sbin/udevadm", "info", "--export-db"]
+        cmd_list = ["udevadm", "info", "--export-db"]
            proc = subprocess.Popen(cmd_list, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
            output_text = proc.communicate()[0]
@@ -77,7 +77,7 @@
            sys.exit(1)
        output_list = output_text.split('\n')
-        devpath_re = re.compile('^P: ('+parent_devpath+'.+/tty/.+)')
+        devpath_re = re.compile('^P: ('+parent_devpath+'.+/'+subsystem+'/.+)')
        devpath_list = []
------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
SynCE-Devel mailing list
https://lists.sourceforge.net/lists/listinfo/synce-devel
Karl Relton
2010-12-20 13:33:56 UTC
Permalink
On my Ubuntu system, all the scripts in /lib/udev that need to run
things from /sbin either use full path at each invocation, or at the top
prepend /sbin to $PATH.

So to be consistent with them we could make /lib/udev/synce-udev-serial
do the prepend /sbin to $PATH, and
then /usr/share/synce-connector/udev-synce-serial could just call
udevadm.

Karl
Post by David Eriksson
Thanks! Maybe those changes should be build options or configuration
options? For example, udevadm might not be in PATH...
Best regards,
David Eriksson
On Thu, Dec 16, 2010 at 18:43, Karl Relton
Post by Karl Relton
I tried the new udev based connector on Ubuntu (Maverick) from the
development ppa.
--- udev-synce-serial 2010-12-16 17:38:20.517195997 +0000
+++ udev-synce-serial.orig 2010-11-15 20:23:51.628813001 +0000
@@ -39,7 +39,7 @@
# there are no python bindings for udev, so this is a little awkward
# get device name
- cmd_list = ["/sbin/udevadm", "info", "--path="+device_path, "--query=name"]
+ cmd_list = ["udevadm", "info", "--path="+devpath, "--query=name"]
proc = subprocess.Popen(cmd_list, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output_text = proc.communicate()[0]
@@ -55,7 +55,7 @@
devname = output_text.strip()
# get parent device path
- match_obj = re.match('^(.+)/'+devname+'/tty/'+devname, device_path)
+ match_obj = re.match('^(.+)/'+name+"/"+subsystem+'/'+name, devpath)
logger.error("failed to get parent device path from udev")
sys.exit(1)
@@ -63,7 +63,7 @@
parent_devpath = match_obj.group(1)
# find all relevant child devices of the parent
- cmd_list = ["/sbin/udevadm", "info", "--export-db"]
+ cmd_list = ["udevadm", "info", "--export-db"]
proc = subprocess.Popen(cmd_list, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output_text = proc.communicate()[0]
@@ -77,7 +77,7 @@
sys.exit(1)
output_list = output_text.split('\n')
- devpath_re = re.compile('^P: ('+parent_devpath+'.+/tty/.+)')
+ devpath_re = re.compile('^P: ('+parent_devpath+'.+/'+subsystem+'/.+)')
devpath_list = []
------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
SynCE-Devel mailing list
https://lists.sourceforge.net/lists/listinfo/synce-devel
Andrey Yurkevich
2010-12-20 14:11:44 UTC
Permalink
Actually, the path to the scripts dir (/lib/udev in your case) is provided by udev.pc pkg-config file. So if you consider installing any script(s) to /lib/udev, you'd better avoid hardcoding that directory and use pkgconfig:

$ pkg-config --variable udevdir udev
/lib/udev

Unfortunately, there is no path to udevadm provided as a variable in udev.pc which, I suppose, could be filed as an enhancement request to udev bugtracker.

cheers,
Andrey
Post by Karl Relton
On my Ubuntu system, all the scripts in /lib/udev that need to run
things from /sbin either use full path at each invocation, or at the top
prepend /sbin to $PATH.
So to be consistent with them we could make /lib/udev/synce-udev-serial
do the prepend /sbin to $PATH, and
then /usr/share/synce-connector/udev-synce-serial could just call
udevadm.
Karl
Post by David Eriksson
Thanks! Maybe those changes should be build options or configuration
options? For example, udevadm might not be in PATH...
Best regards,
David Eriksson
On Thu, Dec 16, 2010 at 18:43, Karl Relton
Post by Karl Relton
I tried the new udev based connector on Ubuntu (Maverick) from the
development ppa.
--- udev-synce-serial 2010-12-16 17:38:20.517195997 +0000
+++ udev-synce-serial.orig 2010-11-15 20:23:51.628813001 +0000
@@ -39,7 +39,7 @@
# there are no python bindings for udev, so this is a little awkward
# get device name
- cmd_list = ["/sbin/udevadm", "info", "--path="+device_path, "--query=name"]
+ cmd_list = ["udevadm", "info", "--path="+devpath, "--query=name"]
proc = subprocess.Popen(cmd_list, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output_text = proc.communicate()[0]
@@ -55,7 +55,7 @@
devname = output_text.strip()
# get parent device path
- match_obj = re.match('^(.+)/'+devname+'/tty/'+devname, device_path)
+ match_obj = re.match('^(.+)/'+name+"/"+subsystem+'/'+name, devpath)
logger.error("failed to get parent device path from udev")
sys.exit(1)
@@ -63,7 +63,7 @@
parent_devpath = match_obj.group(1)
# find all relevant child devices of the parent
- cmd_list = ["/sbin/udevadm", "info", "--export-db"]
+ cmd_list = ["udevadm", "info", "--export-db"]
proc = subprocess.Popen(cmd_list, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output_text = proc.communicate()[0]
@@ -77,7 +77,7 @@
sys.exit(1)
output_list = output_text.split('\n')
- devpath_re = re.compile('^P: ('+parent_devpath+'.+/tty/.+)')
+ devpath_re = re.compile('^P: ('+parent_devpath+'.+/'+subsystem+'/.+)')
devpath_list = []
------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
SynCE-Devel mailing list
https://lists.sourceforge.net/lists/listinfo/synce-devel
------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
SynCE-Devel mailing list
https://lists.sourceforge.net/lists/listinfo/synce-devel
Karl Relton
2010-12-21 14:14:26 UTC
Permalink
Any objections to using the library python-gudev? In theory that should
give us access to udev without having to invoke udevadm as an
executable. That would make the whole udevadm on path issue go away (and
make for a better solution all round).

If you like, I could try and learn how to use the library and send in a
patch for that.

Karl
Post by Andrey Yurkevich
$ pkg-config --variable udevdir udev
/lib/udev
Unfortunately, there is no path to udevadm provided as a variable in udev.pc which, I suppose, could be filed as an enhancement request to udev bugtracker.
cheers,
Andrey
Post by Karl Relton
On my Ubuntu system, all the scripts in /lib/udev that need to run
things from /sbin either use full path at each invocation, or at the top
prepend /sbin to $PATH.
So to be consistent with them we could make /lib/udev/synce-udev-serial
do the prepend /sbin to $PATH, and
then /usr/share/synce-connector/udev-synce-serial could just call
udevadm.
Karl
Post by David Eriksson
Thanks! Maybe those changes should be build options or configuration
options? For example, udevadm might not be in PATH...
Best regards,
David Eriksson
On Thu, Dec 16, 2010 at 18:43, Karl Relton
Post by Karl Relton
I tried the new udev based connector on Ubuntu (Maverick) from the
development ppa.
--- udev-synce-serial 2010-12-16 17:38:20.517195997 +0000
+++ udev-synce-serial.orig 2010-11-15 20:23:51.628813001 +0000
@@ -39,7 +39,7 @@
# there are no python bindings for udev, so this is a little awkward
# get device name
- cmd_list = ["/sbin/udevadm", "info", "--path="+device_path, "--query=name"]
+ cmd_list = ["udevadm", "info", "--path="+devpath, "--query=name"]
proc = subprocess.Popen(cmd_list, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output_text = proc.communicate()[0]
@@ -55,7 +55,7 @@
devname = output_text.strip()
# get parent device path
- match_obj = re.match('^(.+)/'+devname+'/tty/'+devname, device_path)
+ match_obj = re.match('^(.+)/'+name+"/"+subsystem+'/'+name, devpath)
logger.error("failed to get parent device path from udev")
sys.exit(1)
@@ -63,7 +63,7 @@
parent_devpath = match_obj.group(1)
# find all relevant child devices of the parent
- cmd_list = ["/sbin/udevadm", "info", "--export-db"]
+ cmd_list = ["udevadm", "info", "--export-db"]
proc = subprocess.Popen(cmd_list, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
output_text = proc.communicate()[0]
@@ -77,7 +77,7 @@
sys.exit(1)
output_list = output_text.split('\n')
- devpath_re = re.compile('^P: ('+parent_devpath+'.+/tty/.+)')
+ devpath_re = re.compile('^P: ('+parent_devpath+'.+/'+subsystem+'/.+)')
devpath_list = []
------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
SynCE-Devel mailing list
https://lists.sourceforge.net/lists/listinfo/synce-devel
------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
SynCE-Devel mailing list
https://lists.sourceforge.net/lists/listinfo/synce-devel
Loading...