diff options
Diffstat (limited to 'qtip/web/bench')
-rw-r--r-- | qtip/web/bench/__init__.py | 0 | ||||
-rw-r--r-- | qtip/web/bench/admin.py | 22 | ||||
-rw-r--r-- | qtip/web/bench/apps.py | 8 | ||||
-rw-r--r-- | qtip/web/bench/forms.py | 19 | ||||
-rw-r--r-- | qtip/web/bench/management/__init__.py | 0 | ||||
-rw-r--r-- | qtip/web/bench/management/commands/__init__.py | 0 | ||||
-rw-r--r-- | qtip/web/bench/management/commands/_private.py | 0 | ||||
-rw-r--r-- | qtip/web/bench/management/commands/importstatic.py | 10 | ||||
-rw-r--r-- | qtip/web/bench/migrations/0001_initial.py | 36 | ||||
-rw-r--r-- | qtip/web/bench/migrations/0002_auto_20170713_0210.py | 20 | ||||
-rw-r--r-- | qtip/web/bench/migrations/0003_auto_20170713_0225.py | 20 | ||||
-rw-r--r-- | qtip/web/bench/migrations/0004_auto_20170715_0325.py | 20 | ||||
-rw-r--r-- | qtip/web/bench/migrations/0005_auto_20170720_2115.py | 35 | ||||
-rw-r--r-- | qtip/web/bench/migrations/0006_auto_20170722_0135.py | 25 | ||||
-rw-r--r-- | qtip/web/bench/migrations/__init__.py | 0 | ||||
-rw-r--r-- | qtip/web/bench/models.py | 50 | ||||
-rw-r--r-- | qtip/web/bench/tests.py | 6 | ||||
-rw-r--r-- | qtip/web/bench/urls.py | 25 | ||||
-rw-r--r-- | qtip/web/bench/utils.py | 27 | ||||
-rw-r--r-- | qtip/web/bench/views.py | 101 |
20 files changed, 0 insertions, 424 deletions
diff --git a/qtip/web/bench/__init__.py b/qtip/web/bench/__init__.py deleted file mode 100644 index e69de29b..00000000 --- a/qtip/web/bench/__init__.py +++ /dev/null diff --git a/qtip/web/bench/admin.py b/qtip/web/bench/admin.py deleted file mode 100644 index 1e678ad5..00000000 --- a/qtip/web/bench/admin.py +++ /dev/null @@ -1,22 +0,0 @@ -############################################################################## -# Copyright (c) 2017 akhil.batra@research.iiit.ac.in and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals - -from django.contrib import admin - -import models - -# Register your models here. - - -admin.site.register(models.Repo) -admin.site.register(models.Task) diff --git a/qtip/web/bench/apps.py b/qtip/web/bench/apps.py deleted file mode 100644 index db50dfe0..00000000 --- a/qtip/web/bench/apps.py +++ /dev/null @@ -1,8 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.apps import AppConfig - - -class BenchConfig(AppConfig): - name = 'bench' diff --git a/qtip/web/bench/forms.py b/qtip/web/bench/forms.py deleted file mode 100644 index d897aca7..00000000 --- a/qtip/web/bench/forms.py +++ /dev/null @@ -1,19 +0,0 @@ -############################################################################## -# Copyright (c) 2017 akhil.batra@research.iiit.ac.in and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - - -from django import forms - -import models - - -class TaskForm(forms.ModelForm): - class Meta: - model = models.Task - fields = ['repo'] diff --git a/qtip/web/bench/management/__init__.py b/qtip/web/bench/management/__init__.py deleted file mode 100644 index e69de29b..00000000 --- a/qtip/web/bench/management/__init__.py +++ /dev/null diff --git a/qtip/web/bench/management/commands/__init__.py b/qtip/web/bench/management/commands/__init__.py deleted file mode 100644 index e69de29b..00000000 --- a/qtip/web/bench/management/commands/__init__.py +++ /dev/null diff --git a/qtip/web/bench/management/commands/_private.py b/qtip/web/bench/management/commands/_private.py deleted file mode 100644 index e69de29b..00000000 --- a/qtip/web/bench/management/commands/_private.py +++ /dev/null diff --git a/qtip/web/bench/management/commands/importstatic.py b/qtip/web/bench/management/commands/importstatic.py deleted file mode 100644 index 471faf8b..00000000 --- a/qtip/web/bench/management/commands/importstatic.py +++ /dev/null @@ -1,10 +0,0 @@ -import os - -from django.core.management.base import BaseCommand - - -class Command(BaseCommand): - help = 'Import frontend dependencies for serving as static files' - - def handle(self, *args, **options): - os.system("git clone https://github.com/gurayyarar/AdminBSBMaterialDesign.git bench/static/") diff --git a/qtip/web/bench/migrations/0001_initial.py b/qtip/web/bench/migrations/0001_initial.py deleted file mode 100644 index 04736679..00000000 --- a/qtip/web/bench/migrations/0001_initial.py +++ /dev/null @@ -1,36 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.3 on 2017-07-13 01:36 -from __future__ import unicode_literals - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ] - - operations = [ - migrations.CreateModel( - name='Repo', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=200)), - ('github_link', models.URLField()), - ], - ), - migrations.CreateModel( - name='Task', - fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('start_time', models.DateTimeField(auto_now_add=True)), - ('end_time', models.DateTimeField()), - ('run_time', models.DurationField()), - ('log', models.TextField()), - ('repo', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='bench.Repo')), - ], - ), - ] diff --git a/qtip/web/bench/migrations/0002_auto_20170713_0210.py b/qtip/web/bench/migrations/0002_auto_20170713_0210.py deleted file mode 100644 index 30c0cd63..00000000 --- a/qtip/web/bench/migrations/0002_auto_20170713_0210.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.3 on 2017-07-13 02:10 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('bench', '0001_initial'), - ] - - operations = [ - migrations.AlterField( - model_name='repo', - name='github_link', - field=models.URLField(unique=True), - ), - ] diff --git a/qtip/web/bench/migrations/0003_auto_20170713_0225.py b/qtip/web/bench/migrations/0003_auto_20170713_0225.py deleted file mode 100644 index fec4234a..00000000 --- a/qtip/web/bench/migrations/0003_auto_20170713_0225.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.3 on 2017-07-13 02:25 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('bench', '0002_auto_20170713_0210'), - ] - - operations = [ - migrations.AlterField( - model_name='repo', - name='name', - field=models.CharField(max_length=20), - ), - ] diff --git a/qtip/web/bench/migrations/0004_auto_20170715_0325.py b/qtip/web/bench/migrations/0004_auto_20170715_0325.py deleted file mode 100644 index 74296cce..00000000 --- a/qtip/web/bench/migrations/0004_auto_20170715_0325.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.3 on 2017-07-15 03:25 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('bench', '0003_auto_20170713_0225'), - ] - - operations = [ - migrations.AlterField( - model_name='repo', - name='name', - field=models.CharField(max_length=200), - ), - ] diff --git a/qtip/web/bench/migrations/0005_auto_20170720_2115.py b/qtip/web/bench/migrations/0005_auto_20170720_2115.py deleted file mode 100644 index 5bd81a2c..00000000 --- a/qtip/web/bench/migrations/0005_auto_20170720_2115.py +++ /dev/null @@ -1,35 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.3 on 2017-07-20 21:15 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('bench', '0004_auto_20170715_0325'), - ] - - operations = [ - migrations.RenameField( - model_name='repo', - old_name='github_link', - new_name='git_link', - ), - migrations.AlterField( - model_name='task', - name='end_time', - field=models.DateTimeField(null=True), - ), - migrations.AlterField( - model_name='task', - name='log', - field=models.FilePathField(), - ), - migrations.AlterField( - model_name='task', - name='run_time', - field=models.DurationField(null=True), - ), - ] diff --git a/qtip/web/bench/migrations/0006_auto_20170722_0135.py b/qtip/web/bench/migrations/0006_auto_20170722_0135.py deleted file mode 100644 index 5d066702..00000000 --- a/qtip/web/bench/migrations/0006_auto_20170722_0135.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.3 on 2017-07-22 01:35 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('bench', '0005_auto_20170720_2115'), - ] - - operations = [ - migrations.AddField( - model_name='task', - name='status', - field=models.CharField(choices=[('P', 'Pending'), ('IP', 'In progress'), ('F', 'Finished')], default='P', max_length=20), - ), - migrations.AlterField( - model_name='task', - name='log', - field=models.FileField(upload_to='logs'), - ), - ] diff --git a/qtip/web/bench/migrations/__init__.py b/qtip/web/bench/migrations/__init__.py deleted file mode 100644 index e69de29b..00000000 --- a/qtip/web/bench/migrations/__init__.py +++ /dev/null diff --git a/qtip/web/bench/models.py b/qtip/web/bench/models.py deleted file mode 100644 index 3f0439d9..00000000 --- a/qtip/web/bench/models.py +++ /dev/null @@ -1,50 +0,0 @@ -############################################################################## -# Copyright (c) 2017 akhil.batra@research.iiit.ac.in and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.db import models -from django.urls import reverse - -# Create your models here. - - -class Repo(models.Model): - name = models.CharField(max_length=200, blank=False) - git_link = models.URLField(unique=True) - - def get_absolute_url(self): - return reverse('repo_update', args=[self.pk]) - - def __str__(self): - return "%s, %s" % (self.name, self.git_link) - - -class Task(models.Model): - TASK_STATUS_CHOICES = ( - ('P', 'Pending'), - ('IP', 'In progress'), - ('F', 'Finished') - ) - - start_time = models.DateTimeField(auto_now_add=True) - status = models.CharField(choices=TASK_STATUS_CHOICES, default='P', max_length=20) - end_time = models.DateTimeField(null=True) - run_time = models.DurationField(null=True) - repo = models.ForeignKey('Repo', on_delete=models.DO_NOTHING) - log = models.FileField(upload_to='logs') - - def save(self, **kwargs): - if self.end_time: - self.run_time = self.end_time - self.start_time - super(Task, self).save(kwargs) - - def get_absolute_url(self): - return reverse('task_view', args=[self.pk]) diff --git a/qtip/web/bench/tests.py b/qtip/web/bench/tests.py deleted file mode 100644 index c2de5b3a..00000000 --- a/qtip/web/bench/tests.py +++ /dev/null @@ -1,6 +0,0 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -# from django.test import TestCase - -# Create your tests here. diff --git a/qtip/web/bench/urls.py b/qtip/web/bench/urls.py deleted file mode 100644 index a6decbc5..00000000 --- a/qtip/web/bench/urls.py +++ /dev/null @@ -1,25 +0,0 @@ -############################################################################## -# Copyright (c) 2017 akhil.batra@research.iiit.ac.in and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -from django.conf.urls import include, url - -import views - -urlpatterns = [ - url('^', include('django.contrib.auth.urls')), - url('^dashboard/$', views.Dashboard.as_view(), name="index"), - url('^repos/$', views.ReposView.as_view(), name='repos'), - url('^repos/(?P<pk>\d+)$', views.RepoUpdate.as_view(), name='repo_update'), - url('^run/$', views.Run.as_view(), name='run'), - url('^tasks/$', views.Logs.as_view(), name='tasks'), - url('^tasks/(?P<pk>\d+)$', views.TaskView.as_view(), name='task_view'), -] diff --git a/qtip/web/bench/utils.py b/qtip/web/bench/utils.py deleted file mode 100644 index aac388e0..00000000 --- a/qtip/web/bench/utils.py +++ /dev/null @@ -1,27 +0,0 @@ -############################################################################## -# Copyright (c) 2017 akhil.batra@research.iiit.ac.in and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - -import os -from subprocess import Popen, PIPE, STDOUT -import shutil - - -def run(repo): - if os.path.exists(repo.name): - shutil.rmtree(repo.name) - os.mkdir(repo.name) - os.chdir(repo.name) - output = Popen(("git clone %s ." % repo.git_link).split(), stdout=PIPE, stderr=STDOUT) - for line in output.stdout: - yield line - output.wait() - output = Popen("ansible-playbook run.yml".split(), stdout=PIPE, stderr=STDOUT) - for line in output.stdout: - yield line - os.chdir("../") diff --git a/qtip/web/bench/views.py b/qtip/web/bench/views.py deleted file mode 100644 index 56f100cb..00000000 --- a/qtip/web/bench/views.py +++ /dev/null @@ -1,101 +0,0 @@ -############################################################################## -# Copyright (c) 2017 akhil.batra@research.iiit.ac.in and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - -# -*- coding: utf-8 -*- -from __future__ import unicode_literals -from multiprocessing import Process - -from django.contrib.auth.mixins import LoginRequiredMixin -from django.views.generic.edit import CreateView, UpdateView -from django.views.generic.list import ListView -from django.views.generic.detail import DetailView -from django.views.generic import TemplateView -from django.views import View -from django.shortcuts import render, redirect -from django.core.files.base import ContentFile -from django.utils import timezone - -import forms -import models -import utils - - -class Dashboard(TemplateView): - template_name = "bench/index.html" - - -class ReposView(LoginRequiredMixin, CreateView): - model = models.Repo - fields = '__all__' - - def get_context_data(self, **kwargs): - context = super(ReposView, self).get_context_data(**kwargs) - context["repos"] = self.model.objects.all() - context["template_role"] = "add" - return context - - -class RepoUpdate(LoginRequiredMixin, UpdateView): - model = models.Repo - fields = '__all__' - - def get_context_data(self, **kwargs): - context = super(RepoUpdate, self).get_context_data(**kwargs) - context["repos"] = self.model.objects.all() - context["template_role"] = "edit" - return context - - -class Run(LoginRequiredMixin, View): - template_name = 'bench/run.html' - form_class = forms.TaskForm - - def get(self, request): - task_form = self.form_class() - return render(request, self.template_name, {'form': task_form}) - - def post(self, request): - task_form = self.form_class(request.POST) - if task_form.is_valid(): - new_task = task_form.save() - new_task.log.save("run_%s.log" % new_task.pk, ContentFile('')) - p = Process(target=self.start_task, args=(new_task,)) - p.start() - return redirect('tasks') - p.join() - - def start_task(self, task): - task = models.Task.objects.get(pk=task.pk) - task.status = 'IP' - task.save() - with open(task.log.path, "a") as logfile: - for line in utils.run(task.repo): - logfile.write(line) - now = timezone.now() - task = models.Task.objects.get(pk=task.pk) - task.end_time = now - task.status = 'F' - task.save() - - -class Logs(LoginRequiredMixin, ListView): - model = models.Task - - -class TaskView(LoginRequiredMixin, DetailView): - model = models.Task - - def get_context_data(self, **kwargs): - context = super(TaskView, self).get_context_data(**kwargs) - try: - with open(context['object'].log.path, "r") as log_file: - context['log'] = log_file.read() - except ValueError: - context['log'] = "No log to show" - return context |