Skip to content

Commit

Permalink
PEP8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Arne de Laat committed Apr 11, 2013
1 parent c3625b3 commit 19068d3
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 7 deletions.
14 changes: 11 additions & 3 deletions writer/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class HisparcClusters(tables.IsDescription):
cluster_id = tables.StringCol(40, pos=2)
password = tables.StringCol(20, pos=3)
description = tables.StringCol(20, pos=4)



class HisparcEvent(tables.IsDescription):
# DISCUSS: use of signed (dflt -1) vs unsigned (labview code)
event_id = tables.UInt32Col(pos=0)
Expand All @@ -24,12 +25,14 @@ class HisparcEvent(tables.IsDescription):
integrals = tables.Int32Col(shape=4, dflt=-1, pos=11)
traces = tables.Int32Col(shape=4, dflt=-1, pos=12)
event_rate = tables.Float32Col(pos=13)



class HisparcError(tables.IsDescription):
event_id = tables.UInt32Col(pos=0)
timestamp = tables.Time32Col(pos=2)
messages = tables.Int32Col(pos=3)


class HisparcComparatorData(tables.IsDescription):
event_id = tables.UInt32Col(pos=0)
timestamp = tables.Time32Col(pos=2)
Expand All @@ -39,6 +42,7 @@ class HisparcComparatorData(tables.IsDescription):
comparator = tables.UInt8Col(pos=6)
count = tables.UInt16Col(pos=7)


class HisparcConfiguration(tables.IsDescription):
event_id = tables.UInt32Col()
timestamp = tables.Time32Col()
Expand Down Expand Up @@ -130,6 +134,7 @@ class HisparcConfiguration(tables.IsDescription):
slv_ch2_comp_gain = tables.Float64Col()
slv_ch2_comp_offset = tables.Float64Col()


class HisparcWeather(tables.IsDescription):
event_id = tables.UInt32Col(pos=0)
timestamp = tables.Time32Col(pos=1)
Expand Down Expand Up @@ -169,6 +174,7 @@ def open_or_create_file(data_dir, date):

return tables.openFile(file, 'a')


def get_or_create_station_group(file, cluster, station_id):
"""Get an existing station group or create a new one
Expand All @@ -188,6 +194,7 @@ def get_or_create_station_group(file, cluster, station_id):

return station


def get_or_create_cluster_group(file, cluster):
"""Get an existing cluster group or create a new one
Expand All @@ -211,6 +218,7 @@ def get_or_create_cluster_group(file, cluster):

return cluster


def get_or_create_node(file, cluster, node):
"""Get an existing node or create a new one
Expand All @@ -224,7 +232,7 @@ def get_or_create_node(file, cluster, node):
except tables.NoSuchNodeError:
if node == 'events':
node = file.createTable(cluster, 'events', HisparcEvent,
'HiSPARC coincidences table')
'HiSPARC coincidences table')
elif node == 'errors':
node = file.createTable(cluster, 'errors', HisparcError,
'HiSPARC error messages')
Expand Down
2 changes: 1 addition & 1 deletion writer/store_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def store_event_list(data_dir, station_id, cluster, event_list):
logger.error("Strange event (no timestamp!), discarding event "
"(station: %s)" % station_id)
except:
logger.error("Unable to process event, discarding event (station: %s)"
logger.error("Cannot process event, discarding event (station: %s)"
% station_id)

if datafile:
Expand Down
1 change: 1 addition & 0 deletions writer/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def writer(configfile):
except:
logger.exception('Exception occured, quitting.')


def process_data(file):
with open(file) as handle:
data = pickle.load(handle)
Expand Down
2 changes: 1 addition & 1 deletion wsgi/md5_sum.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Python >= 2.5 has hashlib

try:
from hashlib import md5
def md5_sum(s):
Expand All @@ -8,4 +9,3 @@ def md5_sum(s):
import md5
def md5_sum(s):
return md5.new(s).hexdigest()

7 changes: 5 additions & 2 deletions wsgi/wsgi_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def application(environ, start_response, configfile):
logger.debug("Station %d: succesfully completed" % station_id)
return [str(RC_OK)]


def do_init(configfile):
"""Load configuration and passwords and set up a logger handler
Expand All @@ -105,7 +106,7 @@ def do_init(configfile):
if not logger.handlers:
file = config.get('General', 'log') + '-wsgi.%d' % os.getpid()
handler = logging.handlers.TimedRotatingFileHandler(file,
when='midnight', backupCount=14)
when='midnight', backupCount=14)
handler.setFormatter(formatter)
logger.addHandler(handler)
level = LEVELS.get(config.get('General', 'loglevel'), logging.NOTSET)
Expand All @@ -125,6 +126,7 @@ def do_init(configfile):
num = int(num)
station_list[num] = (cluster, password)


def store_data(station_id, cluster, event_list):
"""Store verified event data to temporary storage"""

Expand All @@ -145,9 +147,10 @@ def store_data(station_id, cluster, event_list):

shutil.move(file.name, dir)


def is_data_suspicious(event_list):
"""Check data for suspiciousness
Suspiciousness, a previously unknown quantum number that may signify
the actual birth of the universe and the reweaving of past fates into
current events has come to hunt us and our beloved data.
Expand Down

0 comments on commit 19068d3

Please sign in to comment.