Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
YuWei-CH committed May 30, 2024
1 parent b187af5 commit b382670
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
6 changes: 3 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from rq import Queue
from werkzeug.utils import redirect

from forms import SubmitJob
from forms import SubmitJob, Testjob
from job import *

app = Flask(__name__)
Expand Down Expand Up @@ -37,7 +37,7 @@ def submit():
else:
# User Submits Job #
# (1) Create unique ID for each submission
timestamp = datetime.datetime.now().strftime('%Y%m%d%H%M%S%f')
timestamp = datetime.now().strftime('%Y%m%d%H%M%S%f')
target_dir = os.path.join(UPLOAD_FOLDER, timestamp)
# (2) Log to Database
if not os.path.isfile('database.db'):
Expand Down Expand Up @@ -116,7 +116,7 @@ def submit_test():
else:
# User Submits Job #
# (1) Create unique ID for each submission
timestamp = datetime.datetime.now().strftime('%Y%m%d%H%M%S%f')
timestamp = datetime.now().strftime('%Y%m%d%H%M%S%f')
target_dir = os.path.join(UPLOAD_FOLDER, timestamp)
# (2) Log to Database
if not os.path.isfile('database.db'):
Expand Down
11 changes: 6 additions & 5 deletions cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

# Define the path for the log file
primary_log_directory = "/var/log/reform"
local_log_dirs = "./cleanuplog" # If not, use the local log directory

if not os.path.exists(primary_log_directory):
local_log_dirs = "./cleanuplog" # If not, use the local log directory
if os.path.exists(primary_log_directory) and os.access(primary_log_directory, os.W_OK):
log_file_path = os.path.join(primary_log_directory, "cleanup.log")
else:
# If the primary log directory does not exist or is not writable, use the local log directory
if not os.path.exists(local_log_dirs):
os.makedirs(local_log_dirs)
log_file_path = os.path.join(local_log_dirs, "cleanup.log")
else:
log_file_path = os.path.join(primary_log_directory, "cleanup.log") # create cleanup.log in /var/log/reform
log_file_path = os.path.join(local_log_dirs, "cleanup.log") # create cleanup.log in /var/log/reform

# Configure logging
logging.basicConfig(
Expand Down
9 changes: 9 additions & 0 deletions corn-cleanup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
touch mycron

'''
0 * * * * /home/reform/venv/bin/python /home/reform/reformWeb/cleanup.py
'''

crontab mycron

crontab -l
1 change: 1 addition & 0 deletions mycorn
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# 0 * * * * /home/reform/venv/bin/python /home/reform/reformWeb/cleanup.py
9 changes: 8 additions & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ download_and_decompress() {
}

# Create the upload directories
echo "mkdir -p ./$target_dir"
mkdir -p "./$target_dir"

# Variables to hold the final paths to be used in the reform.py command
Expand All @@ -55,6 +56,9 @@ ref_gff_path="$ref_gff"
if is_url "$ref_fasta"; then
download_and_decompress "$ref_fasta" "./$target_dir"
ref_fasta_path="./$target_dir/$(basename "$ref_fasta")"
if [[ ${ref_fasta_path: -3} == ".gz" ]]; then
ref_fasta_path="${ref_fasta_path::-3}"
fi
else
echo "Using local file: $ref_fasta"
ref_fasta_path="$ref_fasta"
Expand All @@ -63,7 +67,10 @@ fi
# Check and process the reference gff file
if is_url "$ref_gff"; then
download_and_decompress "$ref_gff" "./$target_dir"
ref_fasta_path="./$target_dir/$(basename "$ref_gff")"
ref_gff_path="./$target_dir/$(basename "$ref_gff")"
if [[ ${ref_gff_path: -3} == ".gz" ]]; then
ref_gff_path="${ref_gff_path::-3}"
fi
else
echo "Using local file: $ref_gff"
ref_gff_path="$ref_gff"
Expand Down

0 comments on commit b382670

Please sign in to comment.