From 36a4a96ad4ff483583c319b72d844917b77d354f Mon Sep 17 00:00:00 2001 From: Mattia Mancini <mancini@astron.nl> Date: Fri, 29 Jun 2018 09:44:00 +0000 Subject: [PATCH] SW-300: final trunk integration --- lib/query.py | 9 ++++++++- lib/validator.py | 6 ++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/query.py b/lib/query.py index c00b253..2c10f9b 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 095063e..6a60919 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 -- GitLab