[opensuse-buildservice] Checking md5sums in osc relies on English locales
Hello. I have a little problem when using local build with osc. In file /usr/lib64/python2.5/site-packages/osc/fetch.py osc checks the output of md5sum command. But I have to always change the locale, because the md5sum command output is not in English. Can, probably you Peter Poeml, change the locales internally before calling md5sum in osc, please? Thank you. I'm not python coder, so I'm sorry to not attaching a patch. Regards Ladislav. --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-buildservice+help@opensuse.org
Ladislav Michnovič wrote:
I have a little problem when using local build with osc. In file /usr/lib64/python2.5/site-packages/osc/fetch.py
Peter: Problem is in call on line 144 and in the checks after it on lines 150 and 156: 144: (i, o) = os.popen4(['/bin/rpm', '-K'] + pac_list) 150: if not 'OK' in line: 156: if 'NOT OK' in line: English, German, French, Czech print "OK" or "NOT OK", but Slovak with "V PORIADKU" or "NIE JE V PORIADKU" (as these strings are marked for translation). Similar problem will arise with another languages that have these strings translated. I see 2 possible solutions: 1) check packages one at a time and look for return value from RPM (do not parse stdout) 2) set environment (LC_ALL) before rpm call According to documentation os.popen4() do not pass first parameter to shell if it is list (os.spawn() is used), it is only passed if it is string (os.system() is used). I'm attaching a patch which does it, but I'm not commiting to SVN, because there might be a better solution :) -- Best Regards / S pozdravom, Pavol RUSNAK SUSE LINUX, s.r.o Package Maintainer Lihovarska 1060/12 PGP 0xA6917144 19000 Praha 9, CR prusnak[at]suse.cz http://www.suse.cz
Hi, thank you both for the report and the patch. Additional comments below. On Tue, Dec 04, 2007 at 05:06:19 +0100, Pavol Rusnak wrote:
Ladislav Michnovič wrote:
I have a little problem when using local build with osc. In file /usr/lib64/python2.5/site-packages/osc/fetch.py
Peter: Problem is in call on line 144 and in the checks after it on lines 150 and 156:
144: (i, o) = os.popen4(['/bin/rpm', '-K'] + pac_list) 150: if not 'OK' in line: 156: if 'NOT OK' in line:
English, German, French, Czech print "OK" or "NOT OK", but Slovak with "V PORIADKU" or "NIE JE V PORIADKU" (as these strings are marked for translation). Similar problem will arise with another languages that have these strings translated. I see 2 possible solutions:
1) check packages one at a time and look for return value from RPM (do not parse stdout)
That's what I wanted to avoid, because it would run 3 times slower. Hence the ugly output parsing.
2) set environment (LC_ALL) before rpm call
That should work, indeed. But since the popen is acting on "foreign" input (after retrieving the buildinfo dependency list from the server), it might be harmful to run it through execution of a shell, and I'm a bit hesitant of applying your patch as is. The only other way which cames to mind would be to save a possible LC_ALL environmental value, change it, and re-set it after running the external command. I think I'll rather commit the following patch if you don't mind: --- osc-stable/osc/fetch.py (revision 2686) +++ osc-stable/osc/fetch.py (working copy) @@ -141,8 +141,17 @@ # we can use os.popen4 because we don't care about the return value. # we check the output anyway, and rpm always writes to stdout. + + # save locale first (we rely on English rpm output here) + saved_LC_ALL = os.environ.get('LC_ALL') + os.environ['LC_ALL'] = 'en_EN' + (i, o) = os.popen4(['/bin/rpm', '-K'] + pac_list) + # restore locale + if saved_LC_ALL: os.environ['LC_ALL'] = saved_LC_ALL; + else: os.environ.pop('LC_ALL') + i.close() for line in o.readlines(): Peter -- "WARNING: This bug is visible to non-employees. Please be respectful!" SUSE LINUX Products GmbH Research & Development
2007/12/10, Dr. Peter Poeml <poeml@suse.de>:
Hi,
thank you both for the report and the patch.
Additional comments below.
On Tue, Dec 04, 2007 at 05:06:19 +0100, Pavol Rusnak wrote:
Ladislav Michnovič wrote:
I have a little problem when using local build with osc. In file /usr/lib64/python2.5/site-packages/osc/fetch.py
Peter: Problem is in call on line 144 and in the checks after it on lines 150 and 156:
144: (i, o) = os.popen4(['/bin/rpm', '-K'] + pac_list) 150: if not 'OK' in line: 156: if 'NOT OK' in line:
English, German, French, Czech print "OK" or "NOT OK", but Slovak with "V PORIADKU" or "NIE JE V PORIADKU" (as these strings are marked for translation). Similar problem will arise with another languages that have these strings translated. I see 2 possible solutions:
1) check packages one at a time and look for return value from RPM (do not parse stdout)
That's what I wanted to avoid, because it would run 3 times slower. Hence the ugly output parsing.
2) set environment (LC_ALL) before rpm call
That should work, indeed.
But since the popen is acting on "foreign" input (after retrieving the buildinfo dependency list from the server), it might be harmful to run it through execution of a shell, and I'm a bit hesitant of applying your patch as is.
The only other way which cames to mind would be to save a possible LC_ALL environmental value, change it, and re-set it after running the external command.
This would work fine, so I'm happy. Thank you. Regards Ladislav.
On Mon, Dec 10, 2007 at 02:27:33PM +0100, Ladislav Michnovič wrote:
The only other way which cames to mind would be to save a possible LC_ALL environmental value, change it, and re-set it after running the external command.
This would work fine, so I'm happy. Thank you.
I committed my patch. Thanks again for the report, and the preliminary work! Peter -- "WARNING: This bug is visible to non-employees. Please be respectful!" SUSE LINUX Products GmbH Research & Development
Dr. Peter Poeml wrote:
I think I'll rather commit the following patch if you don't mind:
No problem, your solution seems better even to me :) -- Best Regards / S pozdravom, Pavol RUSNAK SUSE LINUX, s.r.o Package Maintainer Lihovarska 1060/12 PGP 0xA6917144 19000 Praha 9, CR prusnak[at]suse.cz http://www.suse.cz --------------------------------------------------------------------- To unsubscribe, e-mail: opensuse-buildservice+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-buildservice+help@opensuse.org
participants (3)
-
Dr. Peter Poeml
-
Ladislav Michnovič
-
Pavol Rusnak