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

avoid calling locale. #45

Merged
merged 1 commit into from Sep 26, 2013
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -33,7 +33,6 @@
import socket
import subprocess
from optparse import OptionParser, SUPPRESS_HELP
import locale
import traceback

#Constants
@@ -556,15 +555,18 @@ def find_syslog_process():
if results:
#For python version 3 and above, reading binary data, not str,
#so we need to decode the output first:
encoding = locale.getdefaultlocale()[1] or 'UTF-8'
reslines = results.decode(encoding).split('\n')
reslines = results.split(b'\n')
if len(reslines) == 1:
ps_out_fields = reslines[0].split()
pid = int(ps_out_fields[1])
progname = ps_out_fields[7]
if '/' in progname:
progname = progname.split('/')[-1]
return (progname, pid)
if b'/' in progname:
progname = progname.split(b'/')[-1]
try:
return (progname.decode('UTF-8'), pid)
except ValueError:
# if progname won't decode, it's not a progname we know.
pass
return None, 0

def check_syslog_service_status(syslog_type):
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.