use alternate shares file for manager
This commit is contained in:
@@ -56,6 +56,9 @@ def list_shares(shares,opts):
|
|||||||
|
|
||||||
|
|
||||||
def list_folders(shares,config):
|
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']))
|
folders = sorted(os.listdir(config['data_folder']))
|
||||||
table = []
|
table = []
|
||||||
table.append( ('Path','Share','Size','Unit') )
|
table.append( ('Path','Share','Size','Unit') )
|
||||||
@@ -100,6 +103,8 @@ def remove_share(shares,config,opts):
|
|||||||
parser = argparse.ArgumentParser(description='Flees share manager')
|
parser = argparse.ArgumentParser(description='Flees share manager')
|
||||||
parser.add_argument('-c','--config', action="store", dest="config", default = "data/config.json",
|
parser.add_argument('-c','--config', action="store", dest="config", default = "data/config.json",
|
||||||
help = "Your current config.json file")
|
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')
|
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()
|
opts = parser.parse_args()
|
||||||
|
config = {}
|
||||||
if os.path.exists(opts.config):
|
if os.path.exists(opts.config):
|
||||||
config = json.load(open(opts.config,'rt'))
|
config = json.load(open(opts.config,'rt'))
|
||||||
else:
|
else:
|
||||||
print("config file does not exist!")
|
if opts.shares == None:
|
||||||
sys.exit(1)
|
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']):
|
if os.path.exists(config['shares_file']):
|
||||||
shares = json.load(open(config['shares_file'],'rt'))
|
shares = json.load(open(config['shares_file'],'rt'))
|
||||||
else:
|
else:
|
||||||
print("shares_file does not exist!")
|
print("shares_file %s does not exist!"%(config['shares_file']))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if opts.subparser_name == 'list':
|
if opts.subparser_name == 'list':
|
||||||
|
|||||||
Reference in New Issue
Block a user