($INBOX_DIR/description missing)
 help / color / mirror / Atom feed
From: "Reyna, David" <david.reyna@windriver.com>
To: <toaster@lists.yoctoproject.org>
Subject: [PATCH] toaster: Update to support Django-3
Date: Mon, 20 Jul 2020 19:45:02 -0700	[thread overview]
Message-ID: <20200721024502.32579-1-david.reyna@windriver.com> (raw)

Update the Toaster code to support both Django-2 and Django-3.
- The module 'six' was for Python 2/3 compatibility. That package is both
  no longer needed and is deprecated on recent hosts, so explicitly replace
  'reraise' with the Python-3 version.
- The 'autocommits_when_autocommit_is_off' attribute is deprecated in
  Django-3. It was used for 'sqlite3 in Python < 3.6 which doesn't handle
  transactions and savepoints properly when autocommit is off'
- Toaster requirements file updated to include Django 3.0*.

[YOCTO #13888]

Signed-off-by: David Reyna <david.reyna@windriver.com>
---
 bitbake/lib/bb/ui/buildinfohelper.py |  6 ++++--
 bitbake/lib/toaster/orm/models.py    | 15 +++++++++++++--
 bitbake/toaster-requirements.txt     |  2 +-
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py
index 82c62e3324..b20774d895 100644
--- a/bitbake/lib/bb/ui/buildinfohelper.py
+++ b/bitbake/lib/bb/ui/buildinfohelper.py
@@ -894,8 +894,10 @@ class BuildInfoHelper(object):
         self.autocommit_step = 1
         self.server = server
         # we use manual transactions if the database doesn't autocommit on us
-        if not connection.features.autocommits_when_autocommit_is_off:
-            transaction.set_autocommit(False)
+        # deprecated with Django 3
+        if 2 == django.VERSION[0]:
+            if not connection.features.autocommits_when_autocommit_is_off:
+                 transaction.set_autocommit(False)
         self.orm_wrapper = ORMWrapper()
         self.has_build_history = has_build_history
         self.tmp_dir = self.server.runCommand(["getVariable", "TMPDIR"])[0]
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 7f7e922ade..abd657b9e3 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -58,7 +58,18 @@ if 'sqlite' in settings.DATABASES['default']['ENGINE']:
             return _base_insert(self, *args, **kwargs)
     QuerySet._insert = _insert
 
-    from django.utils import six
+    #from django.utils import six (deprecate with Python-3/latest 'six')
+    def six_reraise(tp, value, tb=None):
+        try:
+            if value is None:
+                value = tp()
+            if value.__traceback__ is not tb:
+                raise value.with_traceback(tb)
+            raise value
+        finally:
+            value = None
+            tb = None
+
     def _create_object_from_params(self, lookup, params):
         """
         Tries to create an object using passed params.
@@ -73,7 +84,7 @@ if 'sqlite' in settings.DATABASES['default']['ENGINE']:
                 return self.get(**lookup), False
             except self.model.DoesNotExist:
                 pass
-            six.reraise(*exc_info)
+            six_reraise(*exc_info)
 
     QuerySet._create_object_from_params = _create_object_from_params
 
diff --git a/bitbake/toaster-requirements.txt b/bitbake/toaster-requirements.txt
index 735b614546..56a51fc667 100644
--- a/bitbake/toaster-requirements.txt
+++ b/bitbake/toaster-requirements.txt
@@ -1,3 +1,3 @@
-Django>2.2,<2.3
+Django>2.2,<3.1
 beautifulsoup4>=4.4.0
 pytz
-- 
2.20.1


                 reply	other threads:[~2020-07-21  2:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200721024502.32579-1-david.reyna@windriver.com \
    --to=david.reyna@windriver.com \
    --cc=toaster@lists.yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).