diff options
Diffstat (limited to 'import-layers/yocto-poky/bitbake/lib/toaster/toastermain')
7 files changed, 63 insertions, 79 deletions
diff --git a/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/management/commands/builddelete.py b/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/management/commands/builddelete.py index ff93e549d..0bef8d410 100644 --- a/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/management/commands/builddelete.py +++ b/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/management/commands/builddelete.py @@ -15,7 +15,7 @@ class Command(BaseCommand): try: b = Build.objects.get(pk = bid) except ObjectDoesNotExist: - print 'build %s does not exist, skipping...' %(bid) + print('build %s does not exist, skipping...' %(bid)) continue # theoretically, just b.delete() would suffice # however SQLite runs into problems when you try to diff --git a/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/management/commands/buildslist.py b/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/management/commands/buildslist.py index cad987fd9..8dfef0aa0 100644 --- a/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/management/commands/buildslist.py +++ b/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/management/commands/buildslist.py @@ -10,4 +10,4 @@ class Command(NoArgsCommand): def handle_noargs(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()])) + print("%d: %s %s %s" % (b.pk, b.machine, b.distro, ",".join([x.target for x in b.target_set.all()]))) diff --git a/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/management/commands/get-dburl.py b/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/management/commands/get-dburl.py deleted file mode 100644 index 22b3eb79e..000000000 --- a/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/management/commands/get-dburl.py +++ /dev/null @@ -1,9 +0,0 @@ -from toastermain.settings import getDATABASE_URL -from django.core.management.base import NoArgsCommand - -class Command(NoArgsCommand): - args = "" - help = "get database url" - - def handle_noargs(self,**options): - print getDATABASE_URL() diff --git a/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/management/commands/perf.py b/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/management/commands/perf.py index 71a48e95d..6b450bbdf 100644 --- a/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/management/commands/perf.py +++ b/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/management/commands/perf.py @@ -25,7 +25,7 @@ class Command(BaseCommand): info = self.url_info(full_url) status_code = info[0] load_time = info[1] - print 'Trying \'' + full_url + '\', ' + str(status_code) + ', ' + str(load_time) + print('Trying \'' + full_url + '\', ' + str(status_code) + ', ' + str(load_time)) def get_full_url(self, url_patt, url_root_res): full_url = str(url_patt).split('^')[1].replace('$>', '').replace('(?P<file_path>(?:/[', '/bin/busybox').replace('.*', '') @@ -54,5 +54,5 @@ class Command(BaseCommand): def error(self, *args): for arg in args: - print >>sys.stderr, arg, - print >>sys.stderr + print(arg, end=' ', file=sys.stderr) + print(file=sys.stderr) diff --git a/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/settings.py b/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/settings.py index 74ab60462..3dfa2b223 100644 --- a/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/settings.py +++ b/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/settings.py @@ -21,7 +21,7 @@ # Django settings for Toaster project. -import os, re +import os DEBUG = True TEMPLATE_DEBUG = DEBUG @@ -38,14 +38,19 @@ ADMINS = ( MANAGERS = ADMINS +TOASTER_SQLITE_DEFAULT_DIR = os.path.join(os.environ.get('TOASTER_DIR', ''), + 'build') + DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. - 'NAME': 'toaster.sqlite', # Or path to database file if using sqlite3. + # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. + 'ENGINE': 'django.db.backends.sqlite3', + # DB name or full path to database file if using sqlite3. + 'NAME': "%s/toaster.sqlite" % TOASTER_SQLITE_DEFAULT_DIR, 'USER': '', 'PASSWORD': '', - 'HOST': '127.0.0.1', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP. - 'PORT': '3306', # Set to empty string for default. + #'HOST': '127.0.0.1', # e.g. mysql server + #'PORT': '3306', # e.g. mysql port } } @@ -55,58 +60,6 @@ DATABASES = { if 'sqlite' in DATABASES['default']['ENGINE']: DATABASES['default']['OPTIONS'] = { 'timeout': 20 } -# Reinterpret database settings if we have DATABASE_URL environment variable defined - -if 'DATABASE_URL' in os.environ: - dburl = os.environ['DATABASE_URL'] - - if dburl.startswith('sqlite3://'): - result = re.match('sqlite3://(.*)', dburl) - if result is None: - raise Exception("ERROR: Could not read sqlite database url: %s" % dburl) - DATABASES['default'] = { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': result.group(1), - 'USER': '', - 'PASSWORD': '', - 'HOST': '', - 'PORT': '', - } - elif dburl.startswith('mysql://'): - # URL must be in this form: mysql://user:pass@host:port/name - result = re.match(r"mysql://([^:]*):([^@]*)@([^:]*):(\d*)/([^/]*)", dburl) - if result is None: - raise Exception("ERROR: Could not read mysql database url: %s" % dburl) - DATABASES['default'] = { - 'ENGINE': 'django.db.backends.mysql', - 'NAME': result.group(5), - 'USER': result.group(1), - 'PASSWORD': result.group(2), - 'HOST': result.group(3), - 'PORT': result.group(4), - } - else: - raise Exception("FIXME: Please implement missing database url schema for url: %s" % dburl) - - -# Allows current database settings to be exported as a DATABASE_URL environment variable value - -def getDATABASE_URL(): - d = DATABASES['default'] - if d['ENGINE'] == 'django.db.backends.sqlite3': - if d['NAME'] == ':memory:': - return 'sqlite3://:memory:' - elif d['NAME'].startswith("/"): - return 'sqlite3://' + d['NAME'] - return "sqlite3://" + os.path.join(os.getcwd(), d['NAME']) - - elif d['ENGINE'] == 'django.db.backends.mysql': - return "mysql://" + d['USER'] + ":" + d['PASSWORD'] + "@" + d['HOST'] + ":" + d['PORT'] + "/" + d['NAME'] - - raise Exception("FIXME: Please implement missing database url schema for engine: %s" % d['ENGINE']) - - - # Hosts/domain names that are valid for this site; required if DEBUG is False # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts ALLOWED_HOSTS = [] @@ -134,17 +87,16 @@ else: try: import pytz from pytz.exceptions import UnknownTimeZoneError - pass try: if pytz.timezone(zonename) is not None: - zonefilelist[hashlib.md5(open(filepath).read()).hexdigest()] = zonename - except UnknownTimeZoneError, ValueError: + zonefilelist[hashlib.md5(open(filepath, 'rb').read()).hexdigest()] = zonename + except UnknownTimeZoneError as ValueError: # we expect timezone failures here, just move over pass except ImportError: - zonefilelist[hashlib.md5(open(filepath).read()).hexdigest()] = zonename + zonefilelist[hashlib.md5(open(filepath, 'rb').read()).hexdigest()] = zonename - TIME_ZONE = zonefilelist[hashlib.md5(open('/etc/localtime').read()).hexdigest()] + TIME_ZONE = zonefilelist[hashlib.md5(open('/etc/localtime', 'rb').read()).hexdigest()] # Language code for this installation. All choices can be found here: # http://www.i18nguy.com/unicode/language-identifiers.html @@ -321,7 +273,7 @@ currentdir = os.path.dirname(__file__) for t in os.walk(os.path.dirname(currentdir)): modulename = os.path.basename(t[0]) #if we have a virtualenv skip it to avoid incorrect imports - if os.environ.has_key('VIRTUAL_ENV') and os.environ['VIRTUAL_ENV'] in t[0]: + if 'VIRTUAL_ENV' in os.environ and os.environ['VIRTUAL_ENV'] in t[0]: continue if ("views.py" in t[2] or "models.py" in t[2]) and not modulename in INSTALLED_APPS: diff --git a/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/settings_test.py b/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/settings_test.py new file mode 100644 index 000000000..a32271157 --- /dev/null +++ b/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/settings_test.py @@ -0,0 +1,41 @@ +# +# ex:ts=4:sw=4:sts=4:et +# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- +# +# BitBake Toaster Implementation +# +# Copyright (C) 2016 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 +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# Django settings for Toaster project. + +# Settings overlay to use for running tests +# DJANGO_SETTINGS_MODULE=toastermain.settings-test + +from toastermain.settings import * + +DEBUG = True +TEMPLATE_DEBUG = DEBUG + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': '/tmp/toaster-test-db.sqlite', + 'TEST': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': '/tmp/toaster-test-db.sqlite', + } + } +} diff --git a/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/urls.py b/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/urls.py index 534679dc5..1f8599edc 100644 --- a/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/urls.py +++ b/import-layers/yocto-poky/bitbake/lib/toaster/toastermain/urls.py @@ -71,7 +71,7 @@ import os currentdir = os.path.dirname(__file__) for t in os.walk(os.path.dirname(currentdir)): #if we have a virtualenv skip it to avoid incorrect imports - if os.environ.has_key('VIRTUAL_ENV') and os.environ['VIRTUAL_ENV'] in t[0]: + if 'VIRTUAL_ENV' in os.environ and os.environ['VIRTUAL_ENV'] in t[0]: continue if "urls.py" in t[2] and t[0] != currentdir: @@ -84,7 +84,7 @@ for t in os.walk(os.path.dirname(currentdir)): if not conflict: urlpatterns.insert(0, url(r'^' + modulename + '/', include ( modulename + '.urls'))) else: - logger.warn("Module \'%s\' has a regexp conflict, was not added to the urlpatterns" % modulename) + logger.warning("Module \'%s\' has a regexp conflict, was not added to the urlpatterns" % modulename) from pprint import pformat #logger.debug("urlpatterns list %s", pformat(urlpatterns)) |