Skip to content

Commit

Permalink
wrap all programs in bin
Browse files Browse the repository at this point in the history
  • Loading branch information
michelp committed Aug 29, 2021
1 parent 22c0877 commit 003ed11
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions postgresql/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
import sys
from subprocess import check_output
from pathlib import Path
import postgresql

pg_bin = Path(postgresql.__file__).parent / "bin"
pg_bin = Path(__file__).parent / "bin"


def initdb(cmdline):
cmdline = str(pg_bin / "initdb") + " " + cmdline
return check_output(cmdline, shell=True)
def prog(name):
def f(cmdline):
cmdline = str(pg_bin / name) + " " + cmdline
return check_output(cmdline, shell=True)

return f

def pg_ctl(cmdline):
cmdline = str(pg_bin / "pg_ctl") + " " + cmdline
return check_output(cmdline, shell=True)

progs = """
clusterdb ecpg pg_checksums pg_dumpall pg_restore pg_verifybackup reindexdb
createdb initdb pg_config pg_isready pg_rewind pg_waldump vacuumdb
createuser pg_archivecleanup pg_controldata pg_receivewal pg_test_fsync postgres
dropdb pg_basebackup pg_ctl pg_recvlogical pg_test_timing postmaster
dropuser pgbench pg_dump pg_resetwal pg_upgrade psql
""".split()


this = sys.modules[__name__]
for p in progs:
setattr(this, p, prog(p))


from . import _version
Expand Down

0 comments on commit 003ed11

Please sign in to comment.