diff --git a/lib/query.py b/lib/query.py index c00b253c1d03d4e2fdfbdff9081e419cc4ae3952..2c10f9b9f5402629bfeb0ac6553777af11e7b0ea 100644 --- a/lib/query.py +++ b/lib/query.py @@ -3,7 +3,7 @@ import urllib import requests -from os.path import expanduser +from os.path import expanduser, exists import xml.etree.ElementTree as ET import xmlrpclib import uuid @@ -15,6 +15,13 @@ passw = None #host = "lta-ingest-test.lofar.eu:19443" host = "lofar-ingest.target.rug.nl:9443" +if not exists(path): + # write default file + with open(path, 'w') as file: + file.write("user=\n") + file.write("password=\n") + file.write("host=\n") + with open(path,'r') as file: print "Parsing user credentials from",path for line in file: diff --git a/lib/validator.py b/lib/validator.py index 095063e8ddc6708284649739f8b3e63c3e2fed24..6a60919f6a942e1f82be370c0404b276adaac8d3 100644 --- a/lib/validator.py +++ b/lib/validator.py @@ -6,7 +6,9 @@ import ltasip d = os.path.dirname(os.path.realpath(__file__)) XSDPATH = d+"/LTA-SIP.xsd" -def validate(xmlpath, xsdpath=XSDPATH): +DEFAULT_SIP_XSD_PATH = os.path.join(os.environ.get('LOFARROOT', '/opt/lofar'), 'etc', 'lta', 'LTA-SIP.xsd') + +def validate(xmlpath, xsdpath=DEFAULT_SIP_XSD_PATH): '''validates given xml file against given xsd file''' print "validating", xmlpath, "against", xsdpath @@ -103,7 +105,7 @@ def main(xml): try: xml = xml - xsd = XSDPATH + xsd = DEFAULT_SIP_XSD_PATH valid = validate(xml, xsd) consistent = check_consistency(xml) return valid and consistent