fixes to comply with PEP8

This commit is contained in:
Patrick McDonagh
2016-11-30 11:04:31 -06:00
parent c7bedf9653
commit 759f478f21
5 changed files with 47 additions and 34 deletions

View File

@@ -5,11 +5,13 @@ import math
from app.datalogger.models import Device
from app import db
def getMainPLC():
dev = Device.query.first()
dev_obj = dev.serialize
return dev_obj
def readTag(addr, tag):
c = ClxDriver()
if c.open(addr):
@@ -22,6 +24,7 @@ def readTag(addr, tag):
traceback.print_exc()
c.close()
def getTotals():
today_tags = [
{'name': "Average SPM", 'tag': "TODAY_Average_SPM", 'min': 0, 'max': 20, 'units': 'SPM'},

View File

@@ -22,6 +22,7 @@ class Config(db.Model):
"updated_on": self.updated_on,
}
class Device_type(db.Model):
__tablename__ = "device_types"
_id = db.Column(db.Integer, primary_key=True)
@@ -79,8 +80,6 @@ class Doc(db.Model):
}
class Tag(db.Model):
__tablename__ = "tags"
_id = db.Column(db.Integer, primary_key=True)
@@ -100,7 +99,6 @@ class Tag(db.Model):
created_on = db.Column(db.DateTime(), default=datetime.utcnow)
updated_on = db.Column(db.DateTime(), default=datetime.utcnow, onupdate=datetime.utcnow)
@property
def serialize(self):
return {
@@ -143,6 +141,7 @@ class Tag_val(db.Model):
"updated_on": self.updated_on
}
class Card(db.Model):
__tablename__ = "cards"
_id = db.Column(db.Integer, primary_key=True)
@@ -158,7 +157,6 @@ class Card(db.Model):
# def __repr__(self):
# return self.serialize
@property
def serialize(self):
json_surf_pos = json.loads(self.surf_pos)
@@ -178,7 +176,6 @@ class Card(db.Model):
}
class GaugeOffVal(db.Model):
__tablename__ = "gauge_off"
_id = db.Column(db.Integer, primary_key=True)
@@ -231,6 +228,7 @@ class GaugeOffVal(db.Model):
"updated_on": self.updated_on,
}
class WellTest(db.Model):
__tablename__ = "well_tests"
_id = db.Column(db.Integer, primary_key=True)
@@ -263,6 +261,7 @@ class WellTest(db.Model):
"updated_on": self.updated_on,
}
class Note(db.Model):
__tablename__ = "notes"
_id = db.Column(db.Integer, primary_key=True)
@@ -282,7 +281,6 @@ class Note(db.Model):
}
class EventConfig(db.Model):
__tablename__ = "event_configs"
_id = db.Column(db.Integer, primary_key=True)
@@ -332,6 +330,7 @@ class Event(db.Model):
"updated_on": self.updated_on,
}
class RunStatus(db.Model):
__tablename__ = "run_status_log"
_id = db.Column(db.Integer, primary_key=True)

View File

@@ -13,10 +13,12 @@ from app.datalogger.getDailyTotals import getTotals
ALLOWED_EXTENSIONS = set(['txt', 'pdf', 'png', 'jpg', 'jpeg', 'gif', 'doc', 'docx', 'xls', 'xlsx', 'zip'])
def allowed_file(filename):
return '.' in filename and \
filename.rsplit('.', 1)[1] in ALLOWED_EXTENSIONS
def latest_to_obj(tup):
ob = {}
ob['id'] = tup[0]
@@ -31,6 +33,7 @@ def latest_to_obj(tup):
ob['max_expected'] = tup[9]
return ob
def tagsattime_to_obj(tup):
ob = {}
ob['_id'] = tup[0]
@@ -70,6 +73,7 @@ def get_multiple_tags(ids):
res = Tag.query.filter(Tag._id.in_(ids)).all()
return jsonify([i.serialize for i in res])
@app.route('/doc/upload', methods=['POST'])
def upload_file():
# check if the post request has the file part
@@ -92,11 +96,13 @@ def upload_file():
filename=filename))
return redirect("/#/docs")
@app.route('/docs/<filename>')
def uploaded_file(filename):
return send_from_directory(app.config['UPLOAD_FOLDER'],
filename)
@app.route('/csv/all')
def get_csv_all():
csv_string = "datetime,"
@@ -117,6 +123,7 @@ def get_csv_all():
headers={"Content-disposition":
"attachment; filename=datadump.csv"})
@app.route('/csv/<string:ids>')
def get_csv_selected(ids):
csv_string = "datetime,"
@@ -137,6 +144,7 @@ def get_csv_selected(ids):
headers={"Content-disposition":
"attachment; filename=datadump{}.csv".format(ids.replace(",", "-"))})
@app.route('/api/card_dates')
def get_card_dates():
# res = session.query(func.DATE(Card.created_on)).distinct()
@@ -145,6 +153,7 @@ def get_card_dates():
return jsonify([str(i[0]) for i in res])
# return jsonify([i.serialize for i in res])
@app.route('/api/cardsbydate/<string:datepar>', defaults={'page': 1})
@app.route('/api/cardsbydate/<string:datepar>/<int:page>')
def get_cardsbydate(datepar, page):
@@ -163,6 +172,7 @@ def get_tags_at_time(datetime):
tag_data_list = list(map(tagsattime_to_obj, tag_data))
return jsonify(tag_data_list)
@app.route('/api/today_totals')
def today_totals():
return jsonify(getTotals())

View File

@@ -7,6 +7,7 @@ REQ_TARGET = "localhost"
REQ_PORT = 5000
REQ_URL_BASE = "{}://{}:{}/api".format(REQ_METHOD, REQ_TARGET, REQ_PORT)
def insert_data(db_table, test_data):
global REQ_URL_BASE
REQ_URL = "{}/{}".format(REQ_URL_BASE, db_table)
@@ -15,6 +16,7 @@ def insert_data(db_table, test_data):
input_id = post_res["_id"]
return input_id
def get_data(db_table, obj_id):
global REQ_URL_BASE
REQ_URL = "{}/{}/{}".format(REQ_URL_BASE, db_table, obj_id)
@@ -221,6 +223,5 @@ class TestStroke(unittest.TestCase):
# self.assertTrue(test_note[x] == data_in_db[x])
if __name__ == '__main__':
unittest.main()