Mercurial > ~darius > hgwebdir.cgi > pyinst
diff sitesurvey.py @ 56:91b476ebc0f2
Run through 2to3
author | Daniel O'Connor <doconnor@gsoft.com.au> |
---|---|
date | Tue, 08 Dec 2020 14:00:45 +1030 |
parents | 7ba7207df078 |
children |
line wrap: on
line diff
--- a/sitesurvey.py Tue Dec 08 13:59:05 2020 +1030 +++ b/sitesurvey.py Tue Dec 08 14:00:45 2020 +1030 @@ -26,7 +26,7 @@ # import calendar -import ConfigParser +import configparser import datetime import exceptions import numpy @@ -57,10 +57,10 @@ try: self.opts[k] = int(v) - except exceptions.ValueError, e: + except exceptions.ValueError as e: try: self.opts[k] = float(v) - except exceptions.ValueError, e: + except exceptions.ValueError as e: self.opts[k] = v if self.recurrence == None: @@ -127,7 +127,7 @@ return soonestexp, soonestdly def getsweep(inst, conf): - print " Sending configuration" + print(" Sending configuration") for k in conf: #time.sleep(0.3) @@ -138,16 +138,16 @@ rconf = inst.dumpconf() fstart = rconf['fstart'] fstop = rconf['fstop'] - print " Configuration is " + str(rconf) + print(" Configuration is " + str(rconf)) - print " Fetching trace" + print(" Fetching trace") yaxis = inst.gettrace() xaxis = numpy.arange(fstart, fstop, (fstop - fstart) / yaxis.shape[0]) return xaxis, yaxis, rconf def savesweep(fname, exp, x, y): - print " Saving to " + fname + print(" Saving to " + fname) f = open(fname, 'wb') for k in exp: f.write("%s %s\n" % (k.upper(), str(exp[k]))) @@ -162,30 +162,30 @@ if __name__ == '__main__': # Read in config file(s) - conf = ConfigParser.SafeConfigParser(defaults) - r = conf.read(map(lambda a: os.path.join(a, confname), confpaths)) + conf = configparser.SafeConfigParser(defaults) + r = conf.read([os.path.join(a, confname) for a in confpaths]) if len(r) == 0: - print "Unable to find any configuration file(s)" + print("Unable to find any configuration file(s)") sys.exit(1) if not conf.has_section('general'): - print "Configuration file doesn't have a 'general' section" + print("Configuration file doesn't have a 'general' section") sys.exit(1) if not conf.has_option('general', 'url'): - print "Configuration file doesn't have a 'url' option in the 'general' section" + print("Configuration file doesn't have a 'url' option in the 'general' section") sys.exit(1) if not conf.has_option('general', 'type'): - print "Configuration file doesn't have a 'type' option in the 'general' section" + print("Configuration file doesn't have a 'type' option in the 'general' section") sys.exit(1) if not conf.has_option('general', 'sequence'): - print "Configuration file doesn't have a 'sequence' option in the 'general' section" + print("Configuration file doesn't have a 'sequence' option in the 'general' section") sys.exit(1) if not conf.has_option('general', 'fname'): - print "Configuration file doesn't have a 'fname' option in the 'general' section" + print("Configuration file doesn't have a 'fname' option in the 'general' section") sys.exit(1) if conf.has_option('general', 'ampcal'): @@ -209,11 +209,11 @@ fnamefmt = conf.get('general', 'fname') # Connect to the instrument - print "Connecting to " + url + print("Connecting to " + url) con = scpi.instURL(url) con.write("*IDN?") idn = con.read() - print "Instrument is a " + idn + print("Instrument is a " + idn) # Get class for this instrument & instantiate it inst = specan.getInst(insttype)(con) @@ -225,11 +225,11 @@ # Sleep if necessary dly = total_seconds(dly) if dly > 1: - print "Sleeping for %.1f seconds" % (dly) + print("Sleeping for %.1f seconds" % (dly)) time.sleep(dly) # Run it - print "--> Running experiment " + str(exp) + print("--> Running experiment " + str(exp)) freqs, power, opts = getsweep(inst, exp.opts) # Adjust power based on amplifier and antenna calibration @@ -250,14 +250,14 @@ extras = { 'timestamp' : exp.last_run, 'tag' : exp.name, } - opts = dict(opts.items() + extras.items()) + opts = dict(list(opts.items()) + list(extras.items())) fmtextras = { 'timestamp_hex' : '%08x' % (tsepoch), 'timestamp_dec' : '%d' % (tsepoch), 'fstart_mhz' : '%.1f' % (float(opts['fstart']) / 1e6), 'fstop_mhz' : '%.1f' % (float(opts['fstop']) / 1e6), } - fmtopts = dict(opts.items() + fmtextras.items()) + fmtopts = dict(list(opts.items()) + list(fmtextras.items())) fname = fnamefmt % fmtopts # Save data