diff --git a/lib/constants_generator.py b/lib/constants_generator.py index a798da7dba76f6596b1497f48752d65cdb04de16..6fa378bf4d92583a97a89298fd2bf8b520a78682 100755 --- a/lib/constants_generator.py +++ b/lib/constants_generator.py @@ -4,7 +4,7 @@ # enumerations in the XSD). These are dynamically retrieved from the pyxb-generated API module and in most cases can # just be rerun after pyxb to update the constants module after something has changed in the XSD schema definition. -import ltasip +from . import ltasip import inspect import pyxb #from collections import namedtuple @@ -41,14 +41,14 @@ def get_constants_for_resctrictedtypes(): __constants = dict() for type in enumtypes: - for value in type.values(): + for value in list(type.values()): name = str(type.__name__).upper()+"_"+__safeupper(str(value)) __constants[name] = value # These anonymous ones need a proper name: - for value in ltasip.STD_ANON_.values(): + for value in list(ltasip.STD_ANON_.values()): __constants["FREQUENCY_"+__safeupper(str(value))]=value - for value in ltasip.STD_ANON.values(): + for value in list(ltasip.STD_ANON.values()): __constants["COORDINATESYSTEM_"+__safeupper(str(value))]=value # to convert to named tuple for object-like access (dot-notation): @@ -70,12 +70,12 @@ def main(path): for key in sorted(constants.keys()): #type = type(constants.get(key)) value = constants.get(key) - if isinstance(value, basestring): + if isinstance(value, str): value = "\""+value+"\"" else: value = str(value) line = key+"="+value+"\n" - print line, + print(line, end=' ') f.write(line) diff --git a/lib/feedback.py b/lib/feedback.py index 0a896382332681d5e29d17f9d8a51bf2b2ee9fcb..2eb0a86d8937fb78c983038e96a3c9e37fe6e7e7 100644 --- a/lib/feedback.py +++ b/lib/feedback.py @@ -2,8 +2,8 @@ import sys import pprint -import siplib -import constants +from . import siplib +from . import constants from ast import literal_eval import datetime import copy @@ -15,7 +15,7 @@ class Feedback(): def __init__(self, feedback): self.__inputstrings = feedback self.__tree = {} - print "parsing",len(feedback),"lines of feedback" + print("parsing",len(feedback),"lines of feedback") for line in feedback: if line.strip() and not line.startswith("#"): try: @@ -30,7 +30,7 @@ class Feedback(): except: t[key.split('.')[-1]] = value.strip() except: - print "Skipping line:", line + print("Skipping line:", line) # Now self.__tree holds nested dicts according to the dot-encoded key hierarchy #pprint.pprint(self.__tree) @@ -76,10 +76,10 @@ class Feedback(): #print dps.items() dataproducts = [] - dps = [(k, dp) for (k, dp) in dps.items() if k.startswith("Output_")] + dps = [(k, dp) for (k, dp) in list(dps.items()) if k.startswith("Output_")] for k, dp in dps: - print "Parsing",k,"..." + print("Parsing",k,"...") # correct timestamp format startt=dp.get("startTime") @@ -137,7 +137,7 @@ class Feedback(): if elem.get(prefix): elem = elem.get(prefix) else: - print "provided prefix seems to be wrong: '"+prefix+"' not in", elem.keys() + print("provided prefix seems to be wrong: '"+prefix+"' not in", list(elem.keys())) return elem @@ -151,7 +151,7 @@ class Feedback(): # todo: After evaluation, if still applicable, check assumptions made for missing attributes, assign new IDs, etc. def get_dataproduct_sips(self, obs_prefix="ObsSW.Observation", dp_prefix="ObsSW.Observation.DataProducts"): - print "Generating SIPs for all dataproducts" + print("Generating SIPs for all dataproducts") obs = self.__get_tree_elem(obs_prefix) dps = self.__get_tree_elem(dp_prefix) @@ -227,7 +227,7 @@ class Feedback(): # Determine pointings: pointings=[] - for key in (k for k,v in obs.items() if k.startswith("Beam[")): + for key in (k for k,v in list(obs.items()) if k.startswith("Beam[")): beam = obs.get(key) point=siplib.PointingAltAz( #todo: check if always azel pointing or check on "directionType" @@ -273,7 +273,7 @@ class Feedback(): for dataproduct in self.get_dataproducts(prefix=dp_prefix): try: filename = dataproduct.get_pyxb_dataproduct().fileName - print "Creating SIP for", filename + print("Creating SIP for", filename) # create SIP document for dataproduct sip = self.__get_basic_sip(dataproduct) @@ -322,7 +322,7 @@ class Feedback(): except Exception as err: if not filename: filename = "UNDEFINED" - print "Could not create SIP for", filename,"->",err + print("Could not create SIP for", filename,"->",err) if sips: return sips @@ -331,7 +331,7 @@ class Feedback(): def example(fil): - print "Now running example on file", fil + print("Now running example on file", fil) with open(fil) as f: text = f.readlines() @@ -339,8 +339,8 @@ def example(fil): # A) Parse complete SIP: sips = feedback.get_dataproduct_sips(obs_prefix="ObsSW.Observation", dp_prefix="Observation.DataProducts") - for key in sips.keys(): - print "Created SIP for file "+ str(key) + for key in list(sips.keys()): + print("Created SIP for file "+ str(key)) # B) Alternatively: Parse dataproducts from pseudo-feedback (specialty of Leiden group): @@ -378,8 +378,8 @@ def example(fil): def main(argv): - print "! This is a stub, the feedback to SIP conversion is not correctly working at this point." - print "! You may use this as a module to do some feedback parsing, but unfortunately not all information can be determined from feedback to create a valid SIP." + print("! This is a stub, the feedback to SIP conversion is not correctly working at this point.") + print("! You may use this as a module to do some feedback parsing, but unfortunately not all information can be determined from feedback to create a valid SIP.") if argv[1] is not None: example(argv[1]) diff --git a/lib/ltasip.py b/lib/ltasip.py index b9940d590c5d0be1389f3a213cc1a7b380bffc99..5f457d208a3ac34c55bdef6a6caf26fbbb4868db 100644 --- a/lib/ltasip.py +++ b/lib/ltasip.py @@ -4,7 +4,7 @@ # Generated 2017-04-05 12:06:22.893714 by PyXB version 1.2.5 using Python 2.7.6.final.0 # Namespace http://www.astron.nl/SIP-Lofar -from __future__ import unicode_literals + import pyxb import pyxb.binding import pyxb.binding.saxer diff --git a/lib/query.py b/lib/query.py index 2c10f9b9f5402629bfeb0ac6553777af11e7b0ea..88f14a9b3cbe207ae3ebed31f49e17e2ddfd07a6 100644 --- a/lib/query.py +++ b/lib/query.py @@ -1,11 +1,11 @@ # This module allows querying MoM / the catalog for SIPs of related dataproducts that can be added with the full history to a new SIP. # This is preliminary, for use by the pilot user. Should be cleaned up / replaced by some alternative method -import urllib +import urllib.request, urllib.parse, urllib.error import requests from os.path import expanduser, exists import xml.etree.ElementTree as ET -import xmlrpclib +import xmlrpc.client import uuid import copy @@ -23,7 +23,7 @@ if not exists(path): file.write("host=\n") with open(path,'r') as file: - print "Parsing user credentials from",path + print("Parsing user credentials from",path) for line in file: if line.startswith("user"): user = line.split('=')[1].strip() @@ -38,7 +38,7 @@ login_data = { } url = 'https://'+user+':'+passw+'@'+host -client = xmlrpclib.ServerProxy(url) +client = xmlrpc.client.ServerProxy(url) # id_cache = {} diff --git a/lib/siplib.py b/lib/siplib.py index af574e2c926bfa309c7f2a806caccf77d03e7492..c6fdfde830f475c881c2be55e6efb05f8e75bff7 100644 --- a/lib/siplib.py +++ b/lib/siplib.py @@ -25,15 +25,15 @@ # I could think of that keeps the whole thing reasonably maintainable AND usable. -import ltasip +from . import ltasip import pyxb -import constants +from . import constants import os import uuid import xml.dom.minidom from pyxb.namespace import XMLSchema_instance as xsi from pyxb.namespace import XMLNamespaces as xmlns -import query +from . import query VERSION = "SIPlib 0.4" @@ -51,14 +51,14 @@ ltasip.Namespace.setPrefix('sip') def print_user_warning(): - print "!!! You are accessing an object, which is based on code that was auto-generated with the pyxb package." - print "!!! We strongly advise you to only use the datatypes of the siplib wrapper to create your SIP file." - print "!!! If you choose to alter pyxb/ltasip objects or their values directly for some reason, your SIP may " - print "!!! become invalid. - Please make sure to validate your SIP before submission! " - print "!!! Note that the pyxb portion of the code is subject to change whitout being backwards compatible." - print "!!! This means that, should you choose to access pyxb objects e.g. to parse an existing SIP file, things" - print "!!! might break for you without further warning." - print "!!! (You may suppress this warning by setting the flag in the pyxb-related getter/setter functions.)" + print("!!! You are accessing an object, which is based on code that was auto-generated with the pyxb package.") + print("!!! We strongly advise you to only use the datatypes of the siplib wrapper to create your SIP file.") + print("!!! If you choose to alter pyxb/ltasip objects or their values directly for some reason, your SIP may ") + print("!!! become invalid. - Please make sure to validate your SIP before submission! ") + print("!!! Note that the pyxb portion of the code is subject to change whitout being backwards compatible.") + print("!!! This means that, should you choose to access pyxb objects e.g. to parse an existing SIP file, things") + print("!!! might break for you without further warning.") + print("!!! (You may suppress this warning by setting the flag in the pyxb-related getter/setter functions.)") # =============================== # Identifier definition (used for LTA entities, i-e- processes and dataproducts): @@ -672,7 +672,7 @@ class SpectralCoordinate(): elif isinstance(axis, TabularAxis): args.update(dict(spectralTabularAxis=axis._get_pyxb_axis(suppress_warning=True))) else: - print "wrong axis type:",type(axis) + print("wrong axis type:",type(axis)) self.__pyxb_coordinate=ltasip.SpectralCoordinate(**args) @@ -695,7 +695,7 @@ class TimeCoordinate(): elif isinstance(axis, TabularAxis): args.update(dict(timeTabularAxis=axis._get_pyxb_axis(suppress_warning=True))) else: - print "wrong axis type:",type(axis) + print("wrong axis type:",type(axis)) self.__pyxb_coordinate=ltasip.TimeCoordinate(**args) @@ -1310,9 +1310,9 @@ class Sip(object): The main Sip object. Instantiate this with the dataproduct you want to describe/ingest. Then add all related items to it, like observation, pipeline runs, and intermediate dataproducts. """ - print "\n################" - print VERSION - print "################\n" + print("\n################") + print(VERSION) + print("################\n") #----------- # Base document @@ -1420,7 +1420,7 @@ class Sip(object): if not any(x.dataProductIdentifier.identifier == relateddataproduct_sip.__sip.dataProduct.dataProductIdentifier.identifier for x in self.__sip.relatedDataProduct): self.__sip.relatedDataProduct.append(relateddataproduct_sip.__sip.dataProduct) else: - print "WARNING: There already exists a dataproduct with id", relateddataproduct_sip.__sip.dataProduct.dataProductIdentifier.identifier," - Will try to add any new related items anyway." + print("WARNING: There already exists a dataproduct with id", relateddataproduct_sip.__sip.dataProduct.dataProductIdentifier.identifier," - Will try to add any new related items anyway.") if relateddataproduct_sip.__sip.relatedDataProduct: # add related dataproducts (if not there already) for dp in relateddataproduct_sip.__sip.relatedDataProduct: @@ -1477,11 +1477,11 @@ class Sip(object): return dom.toprettyxml() except pyxb.ValidationError as err: #print str(err) - print err.details() + print(err.details()) raise err def prettyprint(self): - print self.get_prettyxml() + print(self.get_prettyxml()) def save_to_file(self, path): diff --git a/lib/validator.py b/lib/validator.py index 6a60919f6a942e1f82be370c0404b276adaac8d3..4d7f30f9dffaed15ba9bb50762495c972abc7f08 100644 --- a/lib/validator.py +++ b/lib/validator.py @@ -1,7 +1,7 @@ from lxml import etree import os -import ltasip +from . import ltasip d = os.path.dirname(os.path.realpath(__file__)) XSDPATH = d+"/LTA-SIP.xsd" @@ -11,7 +11,7 @@ DEFAULT_SIP_XSD_PATH = os.path.join(os.environ.get('LOFARROOT', '/opt/lofar'), ' def validate(xmlpath, xsdpath=DEFAULT_SIP_XSD_PATH): '''validates given xml file against given xsd file''' - print "validating", xmlpath, "against", xsdpath + print("validating", xmlpath, "against", xsdpath) with open(xsdpath) as xsd: xmlschema_doc = etree.parse(xsd) @@ -25,9 +25,9 @@ def validate(xmlpath, xsdpath=DEFAULT_SIP_XSD_PATH): try: xmlschema.assertValid(doc) except Exception as err: - print err + print(err) - print "SIP is valid according to schema definition!" + print("SIP is valid according to schema definition!") return valid @@ -38,7 +38,7 @@ def check_consistency(xmlpath): Are the input dataproducts for these processes present? """ - print "Checking", xmlpath, "for structural consistency" + print("Checking", xmlpath, "for structural consistency") with open(xmlpath) as f: xml = f.read() @@ -94,7 +94,7 @@ def check_consistency(xmlpath): if not id_from in linkstodataproduct: raise Exception("The input dataproduct for pipeline '"+ id +"' seems to be missing! -> ", id_from) - print "General SIP structure seems ok!" + print("General SIP structure seems ok!") return True # already raised Exception if there was a problem... @@ -110,5 +110,5 @@ def main(xml): consistent = check_consistency(xml) return valid and consistent except Exception as err: - print "An error occurred:" - print err + print("An error occurred:") + print(err) diff --git a/lib/visualizer.py b/lib/visualizer.py index a03a9fffd38c43cad77aec18c2374380dd18c5b2..819194239e63e21536111b2258445ee2bec04bef 100755 --- a/lib/visualizer.py +++ b/lib/visualizer.py @@ -2,8 +2,8 @@ from graphviz import Digraph import sys -import siplib -import ltasip +from . import siplib +from . import ltasip ltasip.Namespace.setPrefix('sip') @@ -44,7 +44,7 @@ def visualize_sip(sip, path="sip.visualize", format="svg", view=False): data_out = sip.dataProduct id_out = str(data_out.dataProductIdentifier.identifier) dot.node(id_out, id_out +": "+data_out.fileName,style="filled",fillcolor="cadetblue", shape="note") - print "adding node for final dataproduct ", id_out + print("adding node for final dataproduct ", id_out) id_process = str(data_out.processIdentifier.identifier) # keep reference to originating pipeline run / observation: linkstodataproduct.setdefault(id_out,[]).append(id_process) @@ -53,7 +53,7 @@ def visualize_sip(sip, path="sip.visualize", format="svg", view=False): for data_in in sip.relatedDataProduct: id_in = str(data_in.dataProductIdentifier.identifier) dot.node(id_in, id_in +": "+data_in.fileName, style="filled", shape="note",fillcolor="cadetblue2") - print "adding node for dataproduct ", id_in + print("adding node for dataproduct ", id_in) id_process = str(data_in.processIdentifier.identifier) # keep reference to originating pipeline run / observation: linkstodataproduct.setdefault(id_in,[]).append(id_process) @@ -63,7 +63,7 @@ def visualize_sip(sip, path="sip.visualize", format="svg", view=False): id_obs = str(obs.observationId.identifier) id_process = str(obs.processIdentifier.identifier) dot.node(id_process, id_process + ": "+ id_obs, style="filled", fillcolor="gold",shape="octagon") - print "adding node for observation ", id_process + print("adding node for observation ", id_process) # no incoming data here, but register node as present: linkstoprocess.setdefault(id_process,[]) @@ -71,7 +71,7 @@ def visualize_sip(sip, path="sip.visualize", format="svg", view=False): for pipe in sip.pipelineRun: id_pipe = str(pipe.processIdentifier.identifier) dot.node(id_pipe, id_pipe+" ", style="filled", fillcolor="chartreuse", shape="cds") - print "adding node for pipelinerun ", id_pipe + print("adding node for pipelinerun ", id_pipe) # keep reference to input dataproducts: id_in = [] for id in pipe.sourceData.content(): @@ -82,7 +82,7 @@ def visualize_sip(sip, path="sip.visualize", format="svg", view=False): for unspec in sip.unspecifiedProcess: id_unspec = str(unspec.processIdentifier.identifier) dot.node(id_unspec, id_unspec, style="filled", fillcolor="orange", shape="hexagon") - print "adding node for unspecified process ", id_unspec + print("adding node for unspecified process ", id_unspec) # no incoming data here, but register node as present: linkstoprocess.setdefault(id_unspec,[]) @@ -100,7 +100,7 @@ def visualize_sip(sip, path="sip.visualize", format="svg", view=False): dot.edge(id_from, id) #print id_from,"->", id else: - print "Error: The pipeline or observation that created dataproduct '"+ id + "' seems to be missing! -> ", id_from + print("Error: The pipeline or observation that created dataproduct '"+ id + "' seems to be missing! -> ", id_from) for id in linkstoprocess: for ids_from in linkstoprocess.get(id): @@ -109,7 +109,7 @@ def visualize_sip(sip, path="sip.visualize", format="svg", view=False): dot.edge(id_from, id) #print id_from,"->", id else: - print "Error: The input dataproduct for pipeline '"+ id +"' seems to be missing! -> ", id_from + print("Error: The input dataproduct for pipeline '"+ id +"' seems to be missing! -> ", id_from) # ---- @@ -118,7 +118,7 @@ def visualize_sip(sip, path="sip.visualize", format="svg", view=False): dot_wrapper.subgraph(dot) dot_wrapper = stylize(dot_wrapper) dot_wrapper.format = format - print "writing rendering to", path + print("writing rendering to", path) dot_wrapper.render(path, view=view) @@ -162,7 +162,7 @@ def stylize(graph): def main(xmlpath): - print "Reading xml from file", xmlpath + print("Reading xml from file", xmlpath) with open(xmlpath) as f: xml = f.read() sip = ltasip.CreateFromDocument(xml) diff --git a/test/test_feedback.py b/test/test_feedback.py index 4e7994e9eaea2b63ae7369afe9af0f3f3070040c..9c01aaabad2a903c22e17d597dfe3a40f8c1ae85 100755 --- a/test/test_feedback.py +++ b/test/test_feedback.py @@ -22,8 +22,8 @@ try: import pyxb except ImportError as e: - print str(e) - print 'Please install python package pyxb: sudo apt-get install python-pyxb' + print(str(e)) + print('Please install python package pyxb: sudo apt-get install python-pyxb') exit(3) # special lofar test exit code: skipped test import unittest @@ -64,21 +64,21 @@ class TestSIPfeedback(unittest.TestCase): def test_basic_doc(self): # create example doc with mandatory attributes - print "===\nCreating basic document:\n" + print("===\nCreating basic document:\n") mysip = create_basicdoc() mysip.save_to_file(TMPFILE_PATH) self.assertTrue(validator.validate(TMPFILE_PATH)) def test_dataproducts(self): mysip = create_basicdoc() - print "===\nAdding related generic dataproduct:\n" + print("===\nAdding related generic dataproduct:\n") with open(FEEDBACK_PATH) as f: text = f.readlines() fb = feedback.Feedback(text) pipe_label = siplib.Identifier('test') dataproducts = fb.get_dataproducts(prefix="test.prefix", process_identifier=pipe_label) for dp in dataproducts: - print "...adding:",dp + print("...adding:",dp) mysip.add_related_dataproduct(dp) mysip.save_to_file(TMPFILE_PATH) diff --git a/test/test_siplib.py b/test/test_siplib.py index 4b4ceef82b19b83500a91f16e97f72163766f02b..0b60911ebdccb834bffa824deb40b39e40381e7d 100755 --- a/test/test_siplib.py +++ b/test/test_siplib.py @@ -24,8 +24,8 @@ import unittest try: import pyxb except ImportError as e: - print str(e) - print 'Please install python package pyxb: sudo apt-get install python-pyxb' + print(str(e)) + print('Please install python package pyxb: sudo apt-get install python-pyxb') exit(3) # special lofar test exit code: skipped test from lofar.lta.sip import siplib @@ -112,36 +112,36 @@ class TestSIPlib(unittest.TestCase): def test_basic_doc(self): # create example doc with mandatory attributes - print "===\nCreating basic document:\n" + print("===\nCreating basic document:\n") mysip = create_basicdoc() mysip.save_to_file(TMPFILE_PATH) self.assertTrue(validator.validate(TMPFILE_PATH)) def test_dataproducts(self): mysip = create_basicdoc() - print "===\nAdding related generic dataproduct:\n" + print("===\nAdding related generic dataproduct:\n") # add optional dataproduct item - print mysip.add_related_dataproduct( + print(mysip.add_related_dataproduct( siplib.GenericDataProduct( create_dataproductmap() ) - ) + )) # add optional dataproduct item - print "===\nAdding related pulp summary dataproduct:\n" - print mysip.add_related_dataproduct( + print("===\nAdding related pulp summary dataproduct:\n") + print(mysip.add_related_dataproduct( siplib.PulpSummaryDataProduct( create_dataproductmap(), filecontent=["content_a","content_b"], datatype="CoherentStokes" ) - ) + )) # add optional dataproduct item - print "===\nAdding related pulp dataproduct:\n" - print mysip.add_related_dataproduct( + print("===\nAdding related pulp dataproduct:\n") + print(mysip.add_related_dataproduct( siplib.PulpDataProduct( create_dataproductmap(), filecontent=["content_a","content_b"], @@ -162,11 +162,11 @@ class TestSIPlib(unittest.TestCase): stokes=["I","Q"] )) ) - ) + )) # add optional dataproduct item - print "===\nAdding related beamformed dataproduct:\n" - print mysip.add_related_dataproduct( + print("===\nAdding related beamformed dataproduct:\n") + print(mysip.add_related_dataproduct( siplib.BeamFormedDataProduct( create_dataproductmap(), beams=[siplib.FlysEyeBeam( @@ -187,12 +187,12 @@ class TestSIPlib(unittest.TestCase): station=siplib.Station.preconfigured("CS001",["HBA0","HBA1"]) )] ) - ) + )) # add optional dataproduct item - print "===\nAdding related sky image dataproduct:\n" - print mysip.add_related_dataproduct( + print("===\nAdding related sky image dataproduct:\n") + print(mysip.add_related_dataproduct( siplib.SkyImageDataProduct( create_dataproductmap(), numberofaxes=2, @@ -281,12 +281,12 @@ class TestSIPlib(unittest.TestCase): restoringbeamminor_angleunit="degrees", rmsnoise=1.0 ) - ) + )) # add optional dataproduct item - print "===\nAdded related correlated dataproduct:\n" - print mysip.add_related_dataproduct( + print("===\nAdded related correlated dataproduct:\n") + print(mysip.add_related_dataproduct( siplib.CorrelatedDataProduct( create_dataproductmap(), subarraypointing_identifier=siplib.Identifier("test"), @@ -302,11 +302,11 @@ class TestSIPlib(unittest.TestCase): channelspersubband=122, stationsubband=2, ) - ) + )) # add optional dataproduct item - print "===\nAdding related pixelmap dataproduct:\n" - print mysip.add_related_dataproduct( + print("===\nAdding related pixelmap dataproduct:\n") + print(mysip.add_related_dataproduct( siplib.PixelMapDataProduct( create_dataproductmap(), numberofaxes=5, @@ -322,12 +322,12 @@ class TestSIPlib(unittest.TestCase): referencepixel=7.5, referencevalue=7.4))] ) - ) + )) # add optional dataproduct item - print "===\nAdding related pixelmap dataproduct using predefined constants:\n" - print mysip.add_related_dataproduct( + print("===\nAdding related pixelmap dataproduct using predefined constants:\n") + print(mysip.add_related_dataproduct( siplib.SkyImageDataProduct( create_dataproductmap(), numberofaxes=2, @@ -398,15 +398,15 @@ class TestSIPlib(unittest.TestCase): restoringbeamminor_angleunit=constants.ANGLEUNIT_DEGREES, rmsnoise=1.0 ) - ) + )) mysip.save_to_file(TMPFILE_PATH) self.assertTrue(validator.validate(TMPFILE_PATH)) def test_observation(self): mysip = create_basicdoc() # add optional observation item - print "===\nAdding observation:\n" - print mysip.add_observation(siplib.Observation(observingmode="Interferometer", + print("===\nAdding observation:\n") + print(mysip.add_observation(siplib.Observation(observingmode="Interferometer", instrumentfilter="10-70 MHz", clock_frequency='160', clock_frequencyunit="MHz", @@ -497,7 +497,7 @@ class TestSIPlib(unittest.TestCase): ) )], transientbufferboardevents=["event1","event2"] - )) + ))) mysip.save_to_file(TMPFILE_PATH) self.assertTrue(validator.validate(TMPFILE_PATH)) @@ -506,63 +506,63 @@ class TestSIPlib(unittest.TestCase): def test_parset(self): mysip = create_basicdoc() - print "===\nAdding parset:\n" - print mysip.add_parset( + print("===\nAdding parset:\n") + print(mysip.add_parset( identifier=siplib.Identifier("test"), - contents="blabla") + contents="blabla")) mysip.save_to_file(TMPFILE_PATH) self.assertTrue(validator.validate(TMPFILE_PATH)) def test_unspecifiedprocess(self): mysip = create_basicdoc() - print "===\nAdding unspecified process:\n" - print mysip.add_unspecifiedprocess( + print("===\nAdding unspecified process:\n") + print(mysip.add_unspecifiedprocess( observingmode="Interferometer", description="unspecified", process_map=create_processmap() - ) + )) mysip.save_to_file(TMPFILE_PATH) self.assertTrue(validator.validate(TMPFILE_PATH)) def test_pipelines(self): mysip = create_basicdoc() - print "===\nAdding simple pipelinerun:\n" - print mysip.add_pipelinerun( + print("===\nAdding simple pipelinerun:\n") + print(mysip.add_pipelinerun( siplib.SimplePipeline( create_pipelinemap() ) - ) + )) - print "===\nAdding generic pipelinerun:\n" - print mysip.add_pipelinerun( + print("===\nAdding generic pipelinerun:\n") + print(mysip.add_pipelinerun( siplib.GenericPipeline( create_pipelinemap() ) - ) + )) - print "===\nAdding cosmic ray pipelinerun:\n" - print mysip.add_pipelinerun( + print("===\nAdding cosmic ray pipelinerun:\n") + print(mysip.add_pipelinerun( siplib.CosmicRayPipeline( create_pipelinemap() ) - ) + )) - print "===\nAdding long baseline pipelinerun:\n" - print mysip.add_pipelinerun( + print("===\nAdding long baseline pipelinerun:\n") + print(mysip.add_pipelinerun( siplib.LongBaselinePipeline( create_pipelinemap(), subbandspersubbandgroup=5, subbandgroupspermS=5 ) - ) + )) - print "===\nAdding imaging pipelinerun:\n" - print mysip.add_pipelinerun(siplib.ImagingPipeline( + print("===\nAdding imaging pipelinerun:\n") + print(mysip.add_pipelinerun(siplib.ImagingPipeline( create_pipelinemap(), imagerintegrationtime=10, imagerintegrationtime_unit="ms", @@ -571,10 +571,10 @@ class TestSIPlib(unittest.TestCase): numberofcorrelateddataproducts=1, numberofskyimages=1, ) - ) + )) - print "===\nAdding calibration pipelinerun:\n" - print mysip.add_pipelinerun( + print("===\nAdding calibration pipelinerun:\n") + print(mysip.add_pipelinerun( siplib.CalibrationPipeline( create_pipelinemap(), skymodeldatabase="db", @@ -584,11 +584,11 @@ class TestSIPlib(unittest.TestCase): timeintegrationstep=1, flagautocorrelations=True, demixing=False - )) + ))) - print "===\nAdding averaging pipelinerun:\n" - print mysip.add_pipelinerun( + print("===\nAdding averaging pipelinerun:\n") + print(mysip.add_pipelinerun( siplib.AveragingPipeline( create_pipelinemap(), numberofcorrelateddataproducts=1, @@ -596,10 +596,10 @@ class TestSIPlib(unittest.TestCase): timeintegrationstep=1, flagautocorrelations=True, demixing=False - )) + ))) - print "===\nAdding pulsar pipelinerun:\n" - print mysip.add_pipelinerun( + print("===\nAdding pulsar pipelinerun:\n") + print(mysip.add_pipelinerun( siplib.PulsarPipeline( create_pipelinemap(), pulsarselection="Pulsars in observation specs, file and brightest in SAP and TAB", @@ -616,7 +616,7 @@ class TestSIPlib(unittest.TestCase): skipdynamicspectrum=False, skipprefold=True ) - ) + )) mysip.save_to_file(TMPFILE_PATH) self.assertTrue(validator.validate(TMPFILE_PATH)) diff --git a/test/test_validator.py b/test/test_validator.py index cc678d9fa1507be90afbe1e885475b270d795c92..e748b55f0c943dfea2efe459b01c87ff8ac43722 100644 --- a/test/test_validator.py +++ b/test/test_validator.py @@ -22,8 +22,8 @@ try: import pyxb except ImportError as e: - print str(e) - print 'Please install python package pyxb: sudo apt-get install python-pyxb' + print(str(e)) + print('Please install python package pyxb: sudo apt-get install python-pyxb') exit(3) # special lofar test exit code: skipped test import unittest diff --git a/test/test_visualizer.py b/test/test_visualizer.py index 6ac71ab3487b7d712323cf2919c8f462460e13d0..d960fbf5fe971b6735f478686c58969ee3fae1d7 100755 --- a/test/test_visualizer.py +++ b/test/test_visualizer.py @@ -22,8 +22,8 @@ try: import pyxb except ImportError as e: - print str(e) - print 'Please install python package pyxb: sudo apt-get install python-pyxb' + print(str(e)) + print('Please install python package pyxb: sudo apt-get install python-pyxb') exit(3) # special lofar test exit code: skipped test import unittest