Skip to content

Commit

Permalink
Merge pull request #142 from OnGle/16-update-lapp
Browse files Browse the repository at this point in the history
Updates for LAPP
  • Loading branch information
JedMeister committed Nov 20, 2019
2 parents 6c672bd + a9a1e98 commit 0d97ccd
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions overlays/pgsql/usr/lib/inithooks/bin/pgsqlconf.py
@@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3
# Copyright (c) 2008 Alon Swartz <alon@turnkeylinux.org> - all rights reserved

"""
Expand All @@ -15,9 +15,9 @@
import signal
import subprocess

from subprocess import Popen, PIPE
from os import system
from subprocess import Popen, PIPE, check_output, CalledProcessError
from dialog_wrapper import Dialog
from executil import ExecError, system, getoutput

class Error(Exception):
pass
Expand Down Expand Up @@ -46,13 +46,13 @@ def __init__(self, database='postgres'):

def _is_alive(self):
try:
getoutput('/etc/init.d/postgresql', 'status')
check_output(['/etc/init.d/postgresql', 'status'])

except ExecError, e:
if e.exitcode == 3: #ie. stopped
except CalledProcessError as e:
if e.returncode == 3: #ie. stopped
return False
else:
raise Error("Unknown postgresql status exitcode: %s" % e.exitcode)
raise Error("Unknown postgresql status exitcode: %s" % e.returncode)

return True

Expand All @@ -74,9 +74,9 @@ def execute(self, query):

def usage(s=None):
if s:
print >> sys.stderr, "Error:", s
print >> sys.stderr, "Syntax: %s [options]" % sys.argv[0]
print >> sys.stderr, __doc__
print("Error:", s, file=sys.stderr)
print("Syntax: %s [options]" % sys.argv[0], file=sys.stderr)
print(__doc__, file=sys.stderr)
sys.exit(1)

def main():
Expand All @@ -85,7 +85,7 @@ def main():
try:
opts, args = getopt.gnu_getopt(sys.argv[1:], "hu:p:",
['help', 'user=', 'pass='])
except getopt.GetoptError, e:
except getopt.GetoptError as e:
usage(e)

username="postgres"
Expand All @@ -108,7 +108,9 @@ def main():
p = PostgreSQL()

# set password
p.execute("alter user %s with encrypted password E\'%s\';" % (username, escape_chars(password)))
p.execute(
("alter user %s with encrypted password E\'%s\';" % (username, escape_chars(password)))
.encode('utf8'))

if __name__ == "__main__":
main()
Expand Down

0 comments on commit 0d97ccd

Please sign in to comment.