Skip to content

Commit

Permalink
Moving syntax to python3
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfpeterson committed Oct 27, 2015
1 parent 5a63248 commit bcf25f7
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions finddata
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env python
from __future__ import (absolute_import, division, print_function, unicode_literals)

import logging
import os
import sys
Expand Down Expand Up @@ -26,21 +28,21 @@ def __bashOptions(keyword, parser):
INSTR = getInstruments()
options = [instr.lower() for instr in INSTR]
options.extend(INSTR)
print " ".join(options)
print(" ".join(options))
elif keyword == "loglevels":
options = [level.lower() for level in LOGLEVELS]
options.extend(LOGLEVELS)
print " ".join(options)
print(" ".join(options))
elif keyword == "options":
options = [str(item) for item in parser.option_list]

options = " ".join(options)
print options.replace("/", " ")
print(options.replace("/", " "))

def parseInt(number):
try:
return int(number)
except ValueError, e:
except ValueError as e:
logging.info("Invalid run numbers: %s" % str(e))

return 0
Expand Down Expand Up @@ -232,17 +234,17 @@ if __name__ == "__main__":

# if they want the version just give it back and exit
if options.version:
print "finddata version " + __version__
print("finddata version " + __version__)
sys.exit(0)

# if the filename is specified just search and be done
if options.filename:
filename = getFileLoc(options.filename)
if filename is not None:
print filename
print(filename)
sys.exit(0)
else:
print "Failed to find file", options.filename
print("Failed to find file", options.filename)
sys.exit(1)

# hidden options to help out bash completion
Expand All @@ -269,20 +271,20 @@ if __name__ == "__main__":
parser.error("Failed to specify run numbers")
else:
# is actual the proposal number
print getRunsInProp(instr, args[1])
print(getRunsInProp(instr, args[1]))

# do the actual searching
if options.getproposal:
multiRun = (len(runnumbers) > 1)
for run in runnumbers:
result = getProposal(instr, run)
if multiRun:
print run,
print result
print(run,)
print(result)
else:
# get the file
for run in runnumbers:
try:
print findfile(instr, run)
except RuntimeError, e:
print e
print(findfile(instr, run))
except RuntimeError as e:
print(e)

0 comments on commit bcf25f7

Please sign in to comment.