toaster: adresss Django-1.10 API deprecations
PATCH 1/1 toaster: adresss Django-1.10 API deprecations
From: David Reyna <[email protected]>
There are three main API deprecations in Django-1.10:
(a) String view arguments to url() must be replaced by the explicit class reference
(b) New TEMPLATES stucture in settings.py consolidates TEMPLATE_DIRS, TEMPLATE_CONTEXT_PROCESSORS, TEMPLATE_LOADERS, TEMPLATE_STRING_IF_INVALID, and TEMPLATE_DEBUG
(c) patterns() wrapper in url() is removed, with urlpatterns now a simple list
Also, the Django version checker must be updated to accept two digit sub-version numbers (e.g. "1.8" < "1.10")
[YOCTO #11684]
Signed-off-by David Reyna <[email protected]>
--- bitbake/bin/toaster | 10 +++- bitbake/lib/toaster/bldcollector/urls.py | 10 ++-- .../management/commands/checksettings.py | 6 +- .../bldcontrol/management/commands/runbuilds.py | 6 +- .../toaster/orm/management/commands/lsupdates.py | 8 +-- bitbake/lib/toaster/toastergui/urls.py | 61 +++++++++---------- .../toastermain/management/commands/buildslist.py | 6 +- bitbake/lib/toaster/toastermain/settings.py | 70 +++++++++++++--------- bitbake/lib/toaster/toastermain/urls.py | 8 ++- bitbake/toaster-requirements.txt | 2 +- 10 files changed, 105 insertions(+), 82 deletions(-)
bitbake/bin/toaster +8 -2
@@ -106,8 +106,14 @@ verify_prereq() { # Verify Django version reqfile=$(python3 -c "import os; print(os.path.realpath('$BBBASEDIR/toaster-requirements.txt'))") exp='s/Django\([><=]\+\)\([^,]\+\),\([><=]\+\)\(.\+\)/' - exp=$exp'import sys,django;version=django.get_version().split(".");' - exp=$exp'sys.exit(not (version \1 "\2".split(".") and version \3 "\4".split(".")))/p' + # expand version parts to 2 digits to support 1.10.x > 1.8 + # (note:helper functions hard to insert in-line) + exp=$exp'import sys,django;' + exp=$exp'version=["%02d" % int(n) for n in django.get_version().split(".")];' + exp=$exp'vmin=["%02d" % int(n) for n in "\2".split(".")];' + exp=$exp'vmax=["%02d" % int(n) for n in "\4".split(".")];' + exp=$exp'sys.exit(not (version \1 vmin and version \3 vmax))' + exp=$exp'/p' if ! sed -n "$exp" $reqfile | python3 - ; then req=`grep ^Django $reqfile` echo "This program needs $req"
bitbake/lib/toaster/bldcollector/urls.py +6 -4
@@ -1,7 +1,7 @@ # # BitBake Toaster Implementation # -# Copyright (C) 2014 Intel Corporation +# Copyright (C) 2014-2017 Intel Corporation # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as
@@ -19,7 +19,9 @@ from django.conf.urls import patterns, include, url -urlpatterns = patterns('bldcollector.views', +import bldcollector.views + +urlpatterns = [ # landing point for pushing a bitbake_eventlog.json file to this toaster instace - url(r'^eventfile$', 'eventfile', name='eventfile'), - ) + url(r'^eventfile$', bldcollector.views.eventfile, name='eventfile'), +]
bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py +3 -3
@@ -1,4 +1,4 @@ -from django.core.management.base import NoArgsCommand, CommandError +from django.core.management.base import BaseCommand, CommandError from django.db import transaction from django.core.management import call_command
@@ -18,7 +18,7 @@ def DN(path): return os.path.dirname(path) -class Command(NoArgsCommand): +class Command(BaseCommand): args = "" help = "Verifies that the configured settings are valid and usable, or prompts the user to fix the settings."
@@ -152,7 +152,7 @@ class Command(NoArgsCommand): - def handle_noargs(self, **options): + def handle(self, **options): retval = 0 retval += self._verify_build_environment() retval += self._verify_default_settings()
bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py +3 -3
@@ -1,4 +1,4 @@ -from django.core.management.base import NoArgsCommand +from django.core.management.base import BaseCommand from django.db import transaction from django.db.models import Q
@@ -16,7 +16,7 @@ import os logger = logging.getLogger("toaster") -class Command(NoArgsCommand): +class Command(BaseCommand): args = "" help = "Schedules and executes build requests as possible. "\ "Does not return (interrupt with Ctrl-C)"
@@ -168,7 +168,7 @@ class Command(NoArgsCommand): except Exception as e: logger.warn("runbuilds: schedule exception %s" % str(e)) - def handle_noargs(self, **options): + def handle(self, **options): pidfile_path = os.path.join(os.environ.get("BUILDDIR", "."), ".runbuilds.pid")
bitbake/lib/toaster/orm/management/commands/lsupdates.py +4 -4
@@ -4,7 +4,7 @@ # # BitBake Toaster Implementation # -# Copyright (C) 2016 Intel Corporation +# Copyright (C) 2016-2017 Intel Corporation # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as
@@ -19,7 +19,7 @@ # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -from django.core.management.base import NoArgsCommand +from django.core.management.base import BaseCommand from orm.models import LayerSource, Layer, Release, Layer_Version from orm.models import LayerVersionDependency, Machine, Recipe
@@ -56,7 +56,7 @@ class Spinner(threading.Thread): self.signal = False -class Command(NoArgsCommand): +class Command(BaseCommand): args = "" help = "Updates locally cached information from a layerindex server"
@@ -307,5 +307,5 @@ class Command(NoArgsCommand): os.system('setterm -cursor on') - def handle_noargs(self, **options): + def handle(self, **options): self.update()
bitbake/lib/toaster/toastergui/urls.py +31 -30
158 lines not on this page · raw message
bitbake/lib/toaster/toastermain/management/commands/buildslist.py +3 -3
@@ -1,13 +1,13 @@ -from django.core.management.base import NoArgsCommand, CommandError +from django.core.management.base import BaseCommand, CommandError from orm.models import Build import os -class Command(NoArgsCommand): +class Command(BaseCommand): args = "" help = "Lists current builds" - def handle_noargs(self,**options): + def handle(self,**options): for b in Build.objects.all(): print("%d: %s %s %s" % (b.pk, b.machine, b.distro, ",".join([x.target for x in b.target_set.all()])))
bitbake/lib/toaster/toastermain/settings.py +41 -29
92 lines not on this page · raw message
bitbake/lib/toaster/toastermain/urls.py +5 -3
@@ -23,6 +23,8 @@ from django.conf.urls import patterns, include, url from django.views.generic import RedirectView from django.views.decorators.cache import never_cache +import bldcollector.views + import logging logger = logging.getLogger("toaster")
@@ -31,7 +33,7 @@ logger = logging.getLogger("toaster") from django.contrib import admin admin.autodiscover() -urlpatterns = patterns('', +urlpatterns = [ # Examples: # url(r'^toaster/', include('toaster.foo.urls')),
@@ -42,11 +44,11 @@ urlpatterns = patterns('', # This is here to maintain backward compatibility and will be deprecated # in the future. - url(r'^orm/eventfile$', 'bldcollector.views.eventfile'), + url(r'^orm/eventfile$', bldcollector.views.eventfile), # if no application is selected, we have the magic toastergui app here url(r'^$', never_cache(RedirectView.as_view(url='/toastergui/', permanent=True))), -) +] import toastermain.settings
bitbake/toaster-requirements.txt +1 -1
@@ -1,3 +1,3 @@ -Django>1.8,<1.9 +Django>1.8,<1.9.9 beautifulsoup4>=4.4.0 pytz
Signature · 1 line
1.9.1