Commit 01c69dbc authored by Jomaro Rodrigues's avatar Jomaro Rodrigues
Browse files

comando pra execução das análises por linha de comando

parent ddba920c
from django.core.management.base import BaseCommand
from uploads.models import Submission
from script.main import analyze
class Command(BaseCommand):
help = 'Makes one specific analysis'
def add_arguments(self, parser):
parser.add_argument('submission_id', type=int)
def handle(self, *args, **options):
id = options['submission_id']
submission = Submission.objects.get(pk=id)
analyze(submission)
......@@ -15,6 +15,8 @@ def analyze(submission):
build_cache(dataframe)
submission.processed = True
submission.process_time = round(time.clock() - start_time)
submission.save()
......@@ -36,5 +38,6 @@ def main():
print("--- Tempo de CPU: {} ---".format(cpu_time))
print("--- Tempo total: {} ---".format(run_time))
if __name__ == "__main__":
main()
......@@ -13,11 +13,6 @@ def make_analysis(modeladmin, request, queryset):
print('analisando: '+str(submission))
analyze(submission)
submission.processed = True
print('salvando')
submission.save()
print('OK')
except:
print('Análise falhou')
......@@ -33,4 +28,4 @@ class SubmissionAdmin(admin.ModelAdmin):
actions = [make_analysis]
admin.site.register(Submission, SubmissionAdmin)
\ No newline at end of file
admin.site.register(Submission, SubmissionAdmin)
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