parent
3547ed0db9
commit
0c37948c37
|
@ -91,6 +91,10 @@ class AutoManGroup(object):
|
||||||
def add_argument(self, *args, **kwargs):
|
def add_argument(self, *args, **kwargs):
|
||||||
self.arguments.append(parse_argument(*args, **kwargs))
|
self.arguments.append(parse_argument(*args, **kwargs))
|
||||||
|
|
||||||
|
def add_argument_group(self, *args, **kwargs):
|
||||||
|
self.arguments.append(AutoManGroup())
|
||||||
|
return self.arguments[-1]
|
||||||
|
|
||||||
|
|
||||||
class SurroundWith():
|
class SurroundWith():
|
||||||
def __init__(self, ret, condition, start='[', end=']'):
|
def __init__(self, ret, condition, start='[', end=']'):
|
||||||
|
|
|
@ -8,8 +8,9 @@ def get_argparser(ArgumentParser=argparse.ArgumentParser):
|
||||||
parser = ArgumentParser(description='Daemon that improves powerline performance.')
|
parser = ArgumentParser(description='Daemon that improves powerline performance.')
|
||||||
parser.add_argument('--quiet', '-q', action='store_true', help='Without other options: do not complain about already running powerline-daemon instance. Will still exit with 1. With `--kill\' and `--replace\': do not show any messages. With `--foreground\': ignored. Does not silence exceptions in any case.')
|
parser.add_argument('--quiet', '-q', action='store_true', help='Without other options: do not complain about already running powerline-daemon instance. Will still exit with 1. With `--kill\' and `--replace\': do not show any messages. With `--foreground\': ignored. Does not silence exceptions in any case.')
|
||||||
parser.add_argument('--socket', '-s', help='Specify socket which will be used for connecting to daemon.')
|
parser.add_argument('--socket', '-s', help='Specify socket which will be used for connecting to daemon.')
|
||||||
arggr = parser.add_mutually_exclusive_group().add_argument
|
exclusive_group = parser.add_mutually_exclusive_group()
|
||||||
arggr('--kill', '-k', action='store_true', help='Kill an already running instance.')
|
exclusive_group.add_argument('--kill', '-k', action='store_true', help='Kill an already running instance.')
|
||||||
arggr('--foreground', '-f', action='store_true', help='Run in the foreground (don’t daemonize).')
|
replace_group = exclusive_group.add_argument_group()
|
||||||
arggr('--replace', '-r', action='store_true', help='Replace an already running instance.')
|
replace_group.add_argument('--foreground', '-f', action='store_true', help='Run in the foreground (don’t daemonize).')
|
||||||
|
replace_group.add_argument('--replace', '-r', action='store_true', help='Replace an already running instance.')
|
||||||
return parser
|
return parser
|
||||||
|
|
|
@ -356,7 +356,8 @@ def lockpidfile():
|
||||||
def main():
|
def main():
|
||||||
global address
|
global address
|
||||||
global pidfile
|
global pidfile
|
||||||
args = get_daemon_argparser().parse_args()
|
parser = get_daemon_argparser()
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.socket:
|
if args.socket:
|
||||||
address = args.socket
|
address = args.socket
|
||||||
|
@ -376,6 +377,8 @@ def main():
|
||||||
pidfile = address + '.pid'
|
pidfile = address + '.pid'
|
||||||
|
|
||||||
if args.kill:
|
if args.kill:
|
||||||
|
if args.foreground or args.replace:
|
||||||
|
parser.error('--kill and --foreground/--replace cannot be used together')
|
||||||
if kill_daemon():
|
if kill_daemon():
|
||||||
if not args.quiet:
|
if not args.quiet:
|
||||||
print ('Kill command sent to daemon, if it does not die in a couple of seconds use kill to kill it')
|
print ('Kill command sent to daemon, if it does not die in a couple of seconds use kill to kill it')
|
||||||
|
|
Loading…
Reference in New Issue