Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for non-english systems [patch] #4

Open
ljanvier opened this issue Jul 11, 2012 · 7 comments
Open

support for non-english systems [patch] #4

ljanvier opened this issue Jul 11, 2012 · 7 comments

Comments

@ljanvier
Copy link

I'm using puppet on french systems (locale defaults to FR_fr)

# LANG=C puppetd -t
info: Retrieving plugin
info: Loading facts in printers
info: Loading facts in printers
Could not retrieve printers: undefined method `captures' for nil:NilClass
Could not retrieve printers: undefined method `captures' for nil:NilClass
Could not retrieve printers: undefined method `captures' for nil:NilClass
...

Indeed, lpstat -p gives :

# lpstat -p
l’imprimante Cups-PDF est inactive, mais activée depuis jeu. 05 juil. 2012 14:58:22 CEST
l’imprimante imp-b14 est inactive, mais activée depuis mer. 11 juil. 2012 15:38:31 CEST
l’imprimante imp-inf6 est inactive, mais activée depuis ven. 06 juil. 2012 18:27:12 CEST
l’imprimante imp-inf7 est inactive, mais activée depuis mer. 11 juil. 2012 14:11:57 CEST
    fichier de données envoyé correctement

with this patch to /lib/facter/printers.rb

6c6
<     stdin, stdout, stderr = Open3.popen3('/usr/bin/lpstat -p')

---
>     stdin, stdout, stderr = Open3.popen3('LANG=C /usr/bin/lpstat -p')

everything's great!

@mosen
Copy link
Owner

mosen commented Jul 12, 2012

je suis desolée and thanks for the patch.

@mosen
Copy link
Owner

mosen commented Sep 12, 2012

I had to remove the variable LANG=C because it was breaking on some systems. I have made a note to test against the FR locale and fix this issue in a different way.

@SteveMaddison
Copy link

We fixed this on our Puppet 3 system by passing the environment variable to Open3 as follows:

stdin, stdout, stderr = Open3.popen3({'LANG' => 'C'}, '/usr/bin/lpstat -p')

@mosen
Copy link
Owner

mosen commented Nov 17, 2013

I'm getting conflicting information about the best method to use for executing shell commands, but it looks like ill have to ditch the provider commands helper. Thanks for the info.

@mosen
Copy link
Owner

mosen commented Nov 17, 2013

Next version released will use Puppet::Util::Execution.execute aka execute which sets LANG=C for every command.

@leoarnold
Copy link
Contributor

@mosen I could not find execute in the source (yet)? Did you abandon the idea (for a reason) or is it on the todo list?

@mosen One step further: Despite i18n, the config files are always in the same language. My uneducated guess would be that is easier to parse config file while changes should still be mage via shell commands. Do you parse shell command output for a reason or just sake of simplicity?

@mosen
Copy link
Owner

mosen commented Sep 18, 2014

@leoarnold I had a branch which used execute, which I planned to merge into master at some stage (given the problems i had with commands helper method).

@leoarnold Shell command parsing is just idiomatic for puppet. Parsing config files would be ok, but I'd have to do it without introducing any dependencies, which means the provider would have some parsing code added in. I would rather set the locale at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants