mirror of
https://github.com/ha7ilm/openwebrx.git
synced 2026-04-21 06:13:45 +00:00
add "silent" flag to openwebrx-admin
This commit is contained in:
parent
e548d6a5de
commit
d99669b3aa
3 changed files with 30 additions and 10 deletions
|
|
@ -2,6 +2,7 @@ from owrx.version import openwebrx_version
|
|||
from owrxadmin.commands import NewUser, DeleteUser
|
||||
import argparse
|
||||
import sys
|
||||
import traceback
|
||||
|
||||
|
||||
def main():
|
||||
|
|
@ -10,13 +11,25 @@ def main():
|
|||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("command", help="One of the following commands: adduser, removeuser")
|
||||
parser.add_argument("--noninteractive", action="store_true", help="Don't ask for any user input (useful for automation)")
|
||||
parser.add_argument("--silent", action="store_true", help="Ignore errors (useful for automation)")
|
||||
parser.add_argument("-u", "--user")
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.command == "adduser":
|
||||
NewUser().run(args)
|
||||
command = NewUser()
|
||||
elif args.command == "removeuser":
|
||||
DeleteUser().run(args)
|
||||
command = DeleteUser()
|
||||
else:
|
||||
print("Unknown command: {command}".format(command=args.command))
|
||||
sys.exit(1)
|
||||
if not args.silent:
|
||||
print("Unknown command: {command}".format(command=args.command))
|
||||
sys.exit(1)
|
||||
sys.exit(0)
|
||||
|
||||
try:
|
||||
command.run(args)
|
||||
except Exception:
|
||||
if not args.silent:
|
||||
print("Error running command:")
|
||||
traceback.print_exc()
|
||||
sys.exit(1)
|
||||
sys.exit(0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue