Skip to content

Commit

Permalink
Make python2/3 compatible
Browse files Browse the repository at this point in the history
Versioneer needs to be updated to 0.17 still.
  • Loading branch information
peterfpeterson committed Dec 9, 2016
1 parent f65198c commit 01a8cf2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion finddata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
__version__ = get_versions()['version']
del get_versions
# everything else
from publish_plot import publish_plot
from .publish_plot import publish_plot
15 changes: 8 additions & 7 deletions finddata/publish_plot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
from __future__ import (absolute_import, division, print_function, unicode_literals)
import json
import logging
import os
Expand All @@ -17,7 +18,7 @@ class Configuration(object):
"""
def __init__(self, config_file):
if os.access(config_file, os.R_OK) == False:
raise RuntimeError, "Configuration file doesn't exist or is not readable: %s" % config_file
raise RuntimeError("Configuration file doesn't exist or is not readable: %s" % config_file)
with open(config_file, 'r') as cfg:
json_encoded = cfg.read()
config = json.loads(json_encoded)
Expand Down Expand Up @@ -64,8 +65,8 @@ def read_configuration(config_file=None):
def _loadDiv(filename):
if not os.path.exists(filename):
raise RuntimeError('\'%s\' does not exist' % filename)
print 'loading \'%s\'' % filename
with file(filename, 'r') as handle:
print('loading \'%s\'' % filename)
with open(filename, 'r') as handle:
div = handle.read()
return div

Expand All @@ -88,7 +89,7 @@ def publish_plot(instrument, run_number, files, config=None):

run_number = str(run_number)
url = _getURL(config.publish_url, instrument, run_number)
print 'posting to \'%s\'' % url
print('posting to \'%s\'' % url)

# these next 2 lines are explicity bad - and doesn't seem
# to do ANYTHING
Expand All @@ -105,8 +106,8 @@ def publish_plot(instrument, run_number, files, config=None):
if __name__ == '__main__':
import sys
div = _loadDiv(sys.argv[1])
#print '**********'
#print div
#print('**********')
#print(div)

# run information is generated from the filename
name = os.path.split(sys.argv[1])[-1]
Expand All @@ -115,4 +116,4 @@ def publish_plot(instrument, run_number, files, config=None):
config = read_configuration('post_processing.conf')
#config = read_configuration('post_processing_full.conf')
request = publish_plot(instr, runnumber, {'file':div}, config)
print 'request returned', request.status_code
print('request returned', request.status_code)

0 comments on commit 01a8cf2

Please sign in to comment.