X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plc-config;h=e7b74fd6a1ea302130c40014d17ce03d0982a41b;hb=391310e122de0536c08f62bd46acd3b3b7b13964;hp=645b1d0adbb875ef340c269dccc06e3b5825bd30;hpb=5beafd1fab624c36f81972588da3463a416a8a00;p=myplc.git diff --git a/plc-config b/plc-config index 645b1d0..e7b74fd 100755 --- a/plc-config +++ b/plc-config @@ -6,7 +6,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: plc-config,v 1.1.1.1 2006/03/27 17:36:46 mlhuang Exp $ +# $Id: plc-config 1078 2007-11-15 13:38:27Z thierry $ # import sys @@ -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,7 +70,7 @@ def main(): save = False # Standard options - shortopts = "hs" + shortopts = "hs:" longopts = ["shell", "bash", "python", "php", "xml", @@ -76,7 +81,7 @@ def main(): "category=", "variable=", "value=", "group=", "package=", "type=", "help", - "save"] + "save="] try: (opts, argv) = getopt.gnu_getopt(sys.argv[1:], shortopts, longopts) @@ -96,11 +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 +# 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": @@ -108,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() @@ -147,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__':