-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from croth1/bug_fixes
small bug fixes/improvements
- Loading branch information
Showing
20 changed files
with
270 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from bammmotif.utils.cleanup import full_cleanup | ||
from django.conf import settings | ||
from django.core.management.base import BaseCommand | ||
|
||
|
||
class Command(BaseCommand): | ||
def handle(self, *args, **options): | ||
full_cleanup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
$(document).ready(function(){ | ||
|
||
// https://stackoverflow.com/a/18537624/2272172 | ||
$("#checkAll").change(function(){ | ||
$('input:checkbox').not(this).prop('checked', this.checked); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
home/notification.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import shutil | ||
import os | ||
from logging import getLogger | ||
|
||
from django.conf import settings | ||
from django.utils import timezone | ||
|
||
from ..models.models import JobInfo | ||
from .path_helpers import ( | ||
get_job_input_folder, | ||
get_job_folder, | ||
) | ||
|
||
|
||
logger = getLogger(__name__) | ||
|
||
|
||
def cleanup_input_files(): | ||
min_time = timezone.now() - timezone.timedelta(days=settings.MAX_INPUT_STORAGE_DAYS) | ||
timed_out_jobs = JobInfo.objects.filter(created_at__lt=min_time, has_input=True, | ||
is_example=False) | ||
|
||
for job in timed_out_jobs: | ||
logger.debug('Job %s selected for input cleanup.', job.job_id) | ||
input_folder = get_job_input_folder(job.job_id) | ||
job.has_input = False | ||
job.save() | ||
try: | ||
shutil.rmtree(input_folder) | ||
except FileNotFoundError: | ||
logger.warn('Could not find input folder %s', input_folder) | ||
|
||
logger.info('removed input files of %s jobs', len(timed_out_jobs)) | ||
|
||
|
||
def cleanup_expired_jobs(): | ||
min_time = timezone.now() - timezone.timedelta(days=settings.MAX_JOB_STORAGE_DAYS) | ||
timed_out_jobs = JobInfo.objects.filter(created_at__lt=min_time, is_example=False) | ||
|
||
for job in timed_out_jobs: | ||
logger.debug('job %s selected for removal.', job.job_id) | ||
job_folder = get_job_folder(job.job_id) | ||
job.delete() | ||
try: | ||
shutil.rmtree(job_folder) | ||
logger.debug('removing expired job folder: %s' % job_folder) | ||
except FileNotFoundError: | ||
logger.warn('could not find job folder %s', job_folder) | ||
except OSError as exc: | ||
logger.error(exc) | ||
|
||
logger.info('removed %s expired jobs', len(timed_out_jobs)) | ||
|
||
|
||
def remove_orphan_jobdirs(): | ||
job_ids = {str(job.job_id) for job in JobInfo.objects.all()} | ||
n_orphans = 0 | ||
for job_dir in os.listdir(settings.JOB_DIR): | ||
if job_dir not in job_ids: | ||
try: | ||
full_job_dir_path = get_job_folder(job_dir) | ||
if not os.path.isdir(full_job_dir_path): | ||
continue | ||
shutil.rmtree(full_job_dir_path) | ||
logger.debug('removing orphaned job folder: %s', full_job_dir_path) | ||
n_orphans += 1 | ||
except OSError as exc: | ||
logger.error(exc) | ||
logger.info('removed %s orphaned job folders', n_orphans) | ||
|
||
|
||
def full_cleanup(): | ||
cleanup_expired_jobs() | ||
cleanup_input_files() | ||
remove_orphan_jobdirs() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.