MCPcopy Create free account
hub / github.com/ElementsProject/lightning / locate_path

Method locate_path

tests/db.py:117–139  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

115 print("Starting PostgresDbProvider")
116
117 def locate_path(self):
118 prefix = '/usr/lib/postgresql/*'
119 matches = glob(prefix)
120
121 candidates = {}
122 for m in matches:
123 g = re.search(r'([0-9]+[\.0-9]*)', m)
124 if not g:
125 continue
126 candidates[float(g.group(1))] = m
127
128 if len(candidates) == 0:
129 raise ValueError("Could not find `postgres` and `initdb` binaries in {}. Is postgresql installed?".format(prefix))
130
131 # Now iterate in reverse order through matches
132 for k, v in sorted(candidates.items())[::-1]:
133 initdb = os.path.join(v, 'bin', 'initdb')
134 postgres = os.path.join(v, 'bin', 'postgres')
135 if os.path.isfile(initdb) and os.path.isfile(postgres):
136 logging.info("Found `postgres` and `initdb` in {}".format(os.path.join(v, 'bin')))
137 return initdb, postgres
138
139 raise ValueError("Could not find `postgres` and `initdb` in any of the possible paths: {}".format(candidates.values()))
140
141 def start(self):
142 passfile = os.path.join(self.directory, "pgpass.txt")

Callers 1

startMethod · 0.95

Calls 1

joinMethod · 0.80

Tested by

no test coverage detected