diff --git a/utils/flees-manager.py b/utils/flees-manager.py index 5234e63..e133c5c 100755 --- a/utils/flees-manager.py +++ b/utils/flees-manager.py @@ -56,6 +56,9 @@ def list_shares(shares,opts): def list_folders(shares,config): + if 'data_folder' not in config: + print("data_folder not defined in config") + sys.exit(1) folders = sorted(os.listdir(config['data_folder'])) table = [] table.append( ('Path','Share','Size','Unit') ) @@ -100,6 +103,8 @@ def remove_share(shares,config,opts): parser = argparse.ArgumentParser(description='Flees share manager') parser.add_argument('-c','--config', action="store", dest="config", default = "data/config.json", help = "Your current config.json file") +parser.add_argument('-s','--shares', action="store", dest="shares_file", default = None, + help = "shares.json you want to use. Defaults to what config.json defines") subparsers = parser.add_subparsers(help='sub-command help', dest='subparser_name') @@ -114,17 +119,21 @@ parser_remove.add_argument(dest="name") opts = parser.parse_args() - +config = {} if os.path.exists(opts.config): config = json.load(open(opts.config,'rt')) else: - print("config file does not exist!") - sys.exit(1) + if opts.shares == None: + print("config file %s does not exist!"%(opts.config,)) + sys.exit(1) + +if opts.shares_file: + config['shares_file'] = opts.shares_file if os.path.exists(config['shares_file']): shares = json.load(open(config['shares_file'],'rt')) else: - print("shares_file does not exist!") + print("shares_file %s does not exist!"%(config['shares_file'])) sys.exit(1) if opts.subparser_name == 'list':