X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=plc-config;h=78fc6dbf2d359e86260cb2f4a3f739b06828764d;hb=b34cfeed447ca9f8cb41599dbf6cdf21e6d5404e;hp=840ee468bb69a84c397585707eb02113e17ab5a1;hpb=2b5a03e21b801468b9e509d49626b97e7798922e;p=myplc.git diff --git a/plc-config b/plc-config index 840ee46..78fc6db 100755 --- a/plc-config +++ b/plc-config @@ -54,6 +54,11 @@ Usage: %s [OPTION]... [FILES] sys.exit(1) +def deprecated (message): + print "%s: deprecated usage"%sys.argv[0] + print message + sys.exit(1) + def main(): plc = PLCConfiguration() fileobjs = [] @@ -65,17 +70,18 @@ def main(): save = False # Standard options - shortopts = "hs" + shortopts = "hs:" longopts = ["shell", "bash", "python", "php", "xml", "variables", "packages", + "groups", "comps", "category=", "variable=", "value=", "group=", "package=", "type=", "help", - "save"] + "save="] try: (opts, argv) = getopt.gnu_getopt(sys.argv[1:], shortopts, longopts) @@ -95,9 +101,14 @@ def main(): elif opt == "--variables": output = plc.output_variables elif opt == "--packages": - output = plc.output_packages +# output = plc.output_packages + deprecated("option --packages deprecated -- use .lst files instead") + elif opt == "--groups": +# output = plc.output_groups + deprecated("option --groups deprecated -- use .lst files instead") elif opt == "--comps": - output = plc.output_comps +# output = plc.output_comps + deprecated("option --comps deprecated -- use .lst files instead") elif opt == "--category": category['id'] = optval elif opt == "--variable": @@ -105,13 +116,18 @@ def main(): elif opt == "--value": variable['value'] = optval elif opt == "--group": - group['id'] = optval +# group['id'] = optval + deprecated("option --group deprecated -- use .lst files instead") elif opt == "--package": - package['name'] = optval +# package['name'] = optval + deprecated("option --package deprecated -- use .lst files instead") elif opt == "--type": package['type'] = optval elif opt == '-s' or opt == "--save": - save = True + if not optval: + usage() + print 'parsed save option',optval + save = optval elif opt == '-h' or opt == "--help": usage() @@ -144,7 +160,16 @@ def main(): # --save if save: - plc.save() + # create directory if needed + # so that plc.d/{api,postgres} can create configs/site.xml + dirname = os.path.dirname (save) + if (not os.path.exists (dirname)): + os.makedirs(dirname,0755) + if (not os.path.exists (dirname)): + print "Cannot create dir %s - exiting" % dirname + sys.exit(1) + + plc.save(save) if __name__ == '__main__':