Use a overwritten runserver command as the solution instead
This commit is contained in:
1 parent
7d820d85d9
commit
19cfa5391d
5 files changed
+54
-39
No files matched your search
+1
-37
@@ -19,42 +19,6 @@
|
||||
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
|
||||
|
||||
import django.apps
|
||||
import threading, time
|
||||
|
||||
class ArtifactWatcher(threading.Thread):
|
||||
|
||||
def run(self):
|
||||
|
||||
# Delay imports due to the app not having been loaded yet
|
||||
import OpenBench.utils
|
||||
|
||||
while True:
|
||||
|
||||
time.sleep(30)
|
||||
|
||||
for test in OpenBench.utils.get_awaiting_tests():
|
||||
|
||||
dev_has_all = test.dev.source.endswith('artifacts')
|
||||
base_has_all = test.base.source.endswith('artifacts')
|
||||
headers = OpenBench.utils.read_git_credentials(test.engine)
|
||||
|
||||
if headers and not dev_has_all:
|
||||
test.dev.source, dev_has_all = OpenBench.utils.fetch_artifact_url(
|
||||
test.dev.source, test.engine, headers, test.dev.sha)
|
||||
test.dev.save()
|
||||
|
||||
if headers and not base_has_all:
|
||||
test.base.source, base_has_all = OpenBench.utils.fetch_artifact_url(
|
||||
test.base.source, test.engine, headers, test.base.sha)
|
||||
test.base.save()
|
||||
|
||||
if dev_has_all and base_has_all:
|
||||
test.awaiting = False
|
||||
test.save()
|
||||
|
||||
class OpenbenchConfig(django.apps.AppConfig):
|
||||
|
||||
class OpenBench(django.apps.AppConfig):
|
||||
name = 'OpenBench'
|
||||
|
||||
def ready(self):
|
||||
self.watcher = ArtifactWatcher().start()
|
||||
Whitespace-only changes.
Whitespace-only changes.
@@ -0,0 +1,51 @@
|
||||
import django.apps
|
||||
import threading, time
|
||||
import OpenBench.utils
|
||||
|
||||
from django.core.management.commands.runserver import BaseRunserverCommand
|
||||
|
||||
class ArtifactWatcher(threading.Thread):
|
||||
|
||||
def update_test(self, test):
|
||||
|
||||
dev_has_all = test.dev.source.endswith('artifacts')
|
||||
base_has_all = test.base.source.endswith('artifacts')
|
||||
headers = OpenBench.utils.read_git_credentials(test.engine)
|
||||
|
||||
if headers and not dev_has_all:
|
||||
test.dev.source, dev_has_all = OpenBench.utils.fetch_artifact_url(
|
||||
test.dev.source, test.engine, headers, test.dev.sha)
|
||||
test.dev.save()
|
||||
|
||||
if headers and not base_has_all:
|
||||
test.base.source, base_has_all = OpenBench.utils.fetch_artifact_url(
|
||||
test.base.source, test.engine, headers, test.base.sha)
|
||||
test.base.save()
|
||||
|
||||
if dev_has_all and base_has_all:
|
||||
test.awaiting = False
|
||||
test.save()
|
||||
|
||||
def run(self):
|
||||
|
||||
while True:
|
||||
|
||||
for test in OpenBench.utils.get_awaiting_tests():
|
||||
self.update_test(test)
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
class Command(BaseRunserverCommand):
|
||||
|
||||
help = "Test"
|
||||
|
||||
def inner_run(self, *args, **options):
|
||||
self.pre_start()
|
||||
super().inner_run(*args, **options)
|
||||
self.pre_quit()
|
||||
|
||||
def pre_start(self):
|
||||
self.watcher = ArtifactWatcher().start()
|
||||
|
||||
def pre_quit(self):
|
||||
self.watcher.kill()
|
||||
@@ -36,14 +36,14 @@ MEDIA_URL = '/Media/'
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'Media')
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'OpenBench',
|
||||
'OpenBench.templatetags',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'OpenBench.templatetags',
|
||||
'OpenBench.apps.OpenbenchConfig',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
|
||||
Reference in new issue
Block a user