Git Lab CI for docker build enabled! You can enable it using .gitlab-ci.yml in your project. Check file template at https://gitlab.bio.di.uminho.pt/snippets/5

Commit c8bf89c5 authored by Davide Lagoa's avatar Davide Lagoa
Browse files

debug log files system created

parent 00cb7fb4
File added
from zipfile import ZipFile
import os
def read_conf_file(path):
res = {}
with open(path) as file:
lines = file.readlines()
for line in lines:
if '=' in line:
prop = line.replace(" ", "").replace("\n", "")
l_str = prop.split('=')
res[l_str[0]] = l_str[1]
return res
def read_workers_conf_file(path):
res = []
with open(path) as file:
lines = file.readlines()
for line in lines:
if "#" not in line[0]:
str = line.replace(" ", "").replace("\n", "")
res.append(str)
return res
def compressFiles(path, savePath):
file_paths = get_all_file_paths(path)
zipLocation = savePath
with ZipFile(zipLocation, 'w') as zip:
# writing each file one by one
for file in file_paths:
new_file = file.split("/")[-1]
zip.write(file, arcname=new_file)
return zipLocation
def get_all_file_paths(directory):
# initializing empty file paths list
file_paths = []
# crawling through directory and subdirectories
for root, directories, files in os.walk(directory):
for filename in files:
# join the two strings in order to form the full filepath.
filepath = os.path.join(root, filename)
file_paths.append(filepath)
# returning all file paths
return file_paths
......@@ -3,7 +3,7 @@ import subprocess
import os
import shutil
import datetime
import logging
import FilesUtilities
app = Flask(__name__)
......@@ -22,6 +22,12 @@ start_time = datetime.datetime.now()
running = False
@app.after_request
def after_request(response):
response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate, public, max-age=0"
response.headers["Expires"] = 0
response.headers["Pragma"] = "no-cache"
return response
@app.route("/start", methods=["POST"])
def start():
......@@ -71,10 +77,29 @@ def display_msg():
return jsonify({"result": "running"}), 202
@app.route('/handshake')
def handshake():
return jsonify({"result": "alive"}), 200
@app.route('/retrieveLogs')
def retrieveLogs():
logsPath = '/workdir/logs'
logsZip = '/logs.zip'
if os.path.exists(logsZip):
os.remove(logsZip)
FilesUtilities.compressFiles(logsPath, logsZip)
if not os.path.exists(logsZip):
return jsonify({"Result": "Request unavailable!"}), 503
return send_file(logsZip, as_attachment=True, attachment_filename='logs.zip')
if __name__ == "__main__":
app.run(host="0.0.0.0", port=80, threaded=False, debug=True)
app.run(host="0.0.0.0", port=80, threaded=False, debug=False)
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
......@@ -31,7 +31,7 @@ coverage=0.8
bitScore=50
# 10 - Select the IDs to generate the reactions. Select 'ModelSEED', 'BiGG', 'MetaCyc', or 'KEGG'.
IDsDatabase=KEGG
IDsDatabase=BiGG
# 11 - Allowed difference between compartments (set a value between 0% and 50%).
difference=30
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment