Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def it_prefers_shorter_strings(self):
assert bestrelpath('/a/b/c', '/a/b') == 'c'
assert bestrelpath('/a/b', '/a/b/c') == '/a/b'
assert bestrelpath('/a/b', '/a/b/c/d') == '/a/b'
def it_prefers_shorter_strings(self):
assert bestrelpath('/a/b/c', '/a/b') == 'c'
assert bestrelpath('/a/b', '/a/b/c') == '/a/b'
assert bestrelpath('/a/b', '/a/b/c/d') == '/a/b'
def ensure_exists(self):
if self.__exists:
return
if not self.path.check(dir=True):
raise NoSuchService("No such service: '%s'" % bestrelpath(str(self.path)))
self._ensure_supervise_is_scratch('supervise')
self.__exists = True
failapp = self.with_services(failed)
childpid = os.fork()
if childpid:
os.waitpid(childpid, 0)
else:
os.dup2(2, 1) # send log to stderr
failapp.log(interactive=False) # doesn't return
if state == 'start':
# we don't want services that failed to start to be 'up'
failapp.stop()
pgctl_print()
pgctl_print('There might be useful information further up in the log; you can view it by running:')
for service in failapp.services:
pgctl_print(' less +G {}'.format(bestrelpath(service.path.join('logs', 'current').strpath)))
raise PgctlUserMessage('Some services failed to %s: %s' % (state, commafy(failed)))
# TODO(p3): -f: force iteractive behavior
# TODO(p3): -F: force iteractive behavior off
tail = ('tail', '-n', '30', '--verbose') # show file headers
if interactive is None:
interactive = sys.stdout.isatty()
if interactive:
# we're interactive; give a continuous log
# TODO-TEST: pgctl log | pb should be non-interactive
tail += ('--follow=name', '--retry')
logfiles = []
for service in self.services:
service.ensure_logs()
logfile = service.path.join('logs', 'current')
logfile = bestrelpath(str(logfile))
logfiles.append(logfile)
exec_(tail + tuple(logfiles)) # never returns