500 fix
diff --git a/config.py b/config.py
index 57888c3..b3b6d69 100644
--- a/config.py
+++ b/config.py
@@ -1,3 +1,5 @@
+import os
+
DOCUMENT_ID = "1Xvd0aHA7mr-_b5C3b-sQ66BQsJiOGIT2UesP7kG26oU"
SHEET_NAME = "aaa"
WORK_SHEET = "Worksheet"
@@ -5,3 +7,4 @@
ROW_COUNT = 10
DEFAULT_FILE_PATH = "test.json"
OUTPUT_FILE = "output.json"
+TEST_PATH = os.environ.get("TEST_PATH", os.path.dirname(__file__) + "/test_results")
diff --git a/storage_api.py b/storage_api.py
index 7841297..5578984 100644
--- a/storage_api.py
+++ b/storage_api.py
@@ -1,46 +1,7 @@
from urlparse import urlparse
-# from gspread import WorksheetNotFound, login
-# from gspread import login
+
import json
import os
-# from gspread import login, WorksheetNotFound
-from config import ROW_COUNT, DOCUMENT_ID, WORK_SHEET
-
-# TEST_PATH = os.environ.get("TEST_PATH", os.path.dirname(__file__) + "/test_results")
-
-
-def get_work_sheet(sheet, name, column_names):
- try:
- work_sheet = sheet.worksheet(name)
- except WorksheetNotFound:
- work_sheet = sheet.add_worksheet(title=name, rows=ROW_COUNT,
- cols=max(40, len(column_names)))
-
- for i in range(1, len(column_names) + 1):
- work_sheet.update_cell(1, i, column_names[i - 1])
-
- return work_sheet
-
-
-def get_row_number(work_sheet):
- num = 2
-
- while num < work_sheet.row_count and work_sheet.cell(num, 1).value != "":
- num += 1
-
- if num == work_sheet.row_count:
- work_sheet.append_row(["" for x in range(work_sheet.col_count)])
-
- return num
-
-
-def append_row(work_sheet, row):
- row_number = get_row_number(work_sheet)
-
- i = 1
- for k in row.keys():
- work_sheet.update_cell(row_number, i, row[k])
- i += 1
class Measurement(object):
@@ -61,8 +22,6 @@
u = urlparse(url)
if u.scheme == 'file':
storage = DiskStorage(u.path)
- else:
- storage = GoogleDocsStorage(DOCUMENT_ID, WORK_SHEET, email, password)
return storage
@@ -76,58 +35,6 @@
pass
-class GoogleDocsStorage(Storage):
-
- def __init__(self, doc_id, work_sheet_name, email=None, password=None):
- self.gc = login(email, password)
- self.sh = self.gc.open_by_key(doc_id)
- self.work_sheet = get_work_sheet(self.sh, work_sheet_name, 40)
-
- def store(self, data):
- append_row(self.work_sheet, data)
-
- def retrieve(self, id):
- row_number = self.find_by_id(id)
-
- if row_number != -1:
- vals = self.work_sheet.row_values(row_number)
- m = Measurement()
- m.build = vals.pop("build_id")
- m.build_type = vals.pop("type")
- m.md5 = vals.pop("iso_md5")
- m.results = {k: vals[k] for k in vals.keys()}
- else:
- return None
-
- def find_by_id(self, row_id):
- for i in range(1, self.work_sheet):
- if self.work_sheet.cell(i, 1) == row_id:
- return i
-
- return -1
-
- def recent_builds(self):
- i = self.work_sheet.row_count - 1
- d = {}
- result = []
-
- while i > 0:
- vals = self.work_sheet.row_values(i)
-
- if vals["type"] not in d:
- d[vals["type"]] = vals
- m = Measurement()
- m.build = vals.pop("build_id")
- m.build_type = vals.pop("type")
- m.md5 = vals.pop("iso_md5")
- m.results = {k: vals[k] for k in vals.keys()}
- result.append(m)
-
- i -= 1
-
- return result
-
-
class DiskStorage(Storage):
def __init__(self, file_name):
self.file_name = file_name
diff --git a/web_app/__init__.py b/web_app/__init__.py
index 7aa6312..3a5aa4f 100644
--- a/web_app/__init__.py
+++ b/web_app/__init__.py
@@ -2,8 +2,9 @@
from flask_bootstrap import Bootstrap
import json
import os.path
+from config import TEST_PATH
from report import build_vertical_bar, build_lines_chart
-from storage_api import create_storage, TEST_PATH
+from storage_api import create_storage
app = Flask(__name__)
Bootstrap(app)
@@ -109,7 +110,7 @@
tests = json.loads(request.data)
if not hasattr(g, "storage"):
- g.storage = create_storage("file://" + os.path.dirname(__file__) + "/test_results/sample.json", "", "")
+ g.storage = create_storage("file://" + TEST_PATH + test_name + ".json", "", "")
for test in tests:
g.storage.store(test)