Spotter-VM/basic/portal-app-manager.py

30 lines
974 B
Python
Executable File

#!/usr/bin/env python
import argparse
import json
def main(args):
jsonfile = '/srv/portal/js/apps.json'
data = {}
with open(jsonfile, 'r') as f:
data = json.load(f)
if not args.app in data:
data[args.app] = {}
if args.url:
data[args.app]['url'] = args.url
if args.login:
data[args.app]['login'] = args.login
if args.password:
data[args.app]['password'] = args.password
with open(jsonfile, 'w') as f:
json.dump(data, f)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Spotter Cluster portal application manager')
parser.add_argument('app', help='Application ID.')
parser.add_argument('url', nargs='?', help='URL to the application. Use "{host}" as a host placeholder.')
parser.add_argument('login', nargs='?', help='Administrative login.')
parser.add_argument('password', nargs='?', help='Administrative password.')
main(parser.parse_args())