Allow --foreground to be used with --replace

Fixes #1235
This commit is contained in:
ZyX 2015-01-08 16:47:56 +03:00
parent 3547ed0db9
commit 0c37948c37
3 changed files with 13 additions and 5 deletions

View File

@ -91,6 +91,10 @@ class AutoManGroup(object):
def add_argument(self, *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():
def __init__(self, ret, condition, start='[', end=']'):

View File

@ -8,8 +8,9 @@ def get_argparser(ArgumentParser=argparse.ArgumentParser):
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('--socket', '-s', help='Specify socket which will be used for connecting to daemon.')
arggr = parser.add_mutually_exclusive_group().add_argument
arggr('--kill', '-k', action='store_true', help='Kill an already running instance.')
arggr('--foreground', '-f', action='store_true', help='Run in the foreground (dont daemonize).')
arggr('--replace', '-r', action='store_true', help='Replace an already running instance.')
exclusive_group = parser.add_mutually_exclusive_group()
exclusive_group.add_argument('--kill', '-k', action='store_true', help='Kill an already running instance.')
replace_group = exclusive_group.add_argument_group()
replace_group.add_argument('--foreground', '-f', action='store_true', help='Run in the foreground (dont daemonize).')
replace_group.add_argument('--replace', '-r', action='store_true', help='Replace an already running instance.')
return parser

View File

@ -356,7 +356,8 @@ def lockpidfile():
def main():
global address
global pidfile
args = get_daemon_argparser().parse_args()
parser = get_daemon_argparser()
args = parser.parse_args()
if args.socket:
address = args.socket
@ -376,6 +377,8 @@ def main():
pidfile = address + '.pid'
if args.kill:
if args.foreground or args.replace:
parser.error('--kill and --foreground/--replace cannot be used together')
if kill_daemon():
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')