Unverified Commit 8b19a9fb authored by Jelle van der Waa's avatar Jelle van der Waa 🚧 Committed by GitHub
Browse files

Merge pull request #167 from jelly/python3

Switch to Django 2.x with Python 3.7
parents b2e32174 923b674a
language: python
python:
- "2.7"
- "3.6"
cache: pip
install: "pip install -r requirements.txt && pip install coveralls pylint"
......
......@@ -17,8 +17,8 @@ See AUTHORS file.
# Dependencies
- python2
- python2-virtualenv
- python
- python-virtualenv
# Python dependencies
......@@ -26,16 +26,16 @@ More detail in `requirements.txt` and `requirements_prod.txt`; it is best to
use virtualenv and pip to handle these. But if you insist on (Arch Linux)
packages, you will probably want the following:
- python2-django
- python2-psycopg2
- python2-markdown
- python2-memcached
- python-django
- python-psycopg2
- python-markdown
- python-memcached
# Testing Installation
1. Run `virtualenv2`.
1. Run `virtualenv3`.
cd /path/to/archweb && virtualenv2 ./env/
cd /path/to/archweb && virtualenv3 ./env/
2. Activate the virtualenv.
......@@ -88,9 +88,9 @@ For PostgreSQL use packages/sql/update.postgresql_psycopg2.sql
To be able to create an account on your test environment an SMTP server is
required. A simple debugging SMTP server can be setup using Python.
python2 -m smtpd -n -c DebuggingServer localhost:1025
python -m smtpd -n -c DebuggingServer localhost:1025
In local_settings.py change the EMAIL_HOST to 'localhost' and the EMAIL_PORT to
In local\_settings.py add entries to set EMAIL\_HOST to 'localhost' and EMAIL\_PORT to
1025.
# Running tests and coverage
......
......@@ -4,8 +4,9 @@ import sys
import site
base_path = "/srv/http/archweb"
py_version = sys.version_info
site.addsitedir('/srv/http/archweb-env/lib/python2.7/site-packages')
site.addsitedir('/srv/http/archweb-env/lib/python{}.{}/site-packages'.format(py_version.major, py_version.minor))
sys.path.insert(0, base_path)
os.environ['DJANGO_SETTINGS_MODULE'] = "settings"
......
......@@ -59,7 +59,7 @@ def __init__(self, *args, **kwargs):
'alias', 'public_email')
for key in keys:
self.fields[key] = old[key]
for key, _ in old.items():
for key, _ in list(old.items()):
if key not in keys:
self.fields[key] = old[key]
......
......@@ -141,7 +141,7 @@ def import_keys(keyring):
finder = UserFinder()
# we are dependent on parents coming before children; parse_keydata
# uses an OrderedDict to ensure this is the case.
for data in keydata.values():
for data in list(keydata.values()):
parent_id = None
if data.parent:
parent_data = keydata.get(data.parent, None)
......@@ -161,7 +161,7 @@ def import_keys(keyring):
if created:
created_ct += 1
else:
for k, v in other.items():
for k, v in list(other.items()):
if getattr(dkey, k) != v:
setattr(dkey, k, v)
needs_save = True
......
......@@ -62,7 +62,7 @@ def match_packager(finder):
logger.debug(" found user %s", user.username)
matched_count += 1
for packager_str, user in mapping.items():
for packager_str, user in list(mapping.items()):
package_count += Package.objects.filter(packager__isnull=True,
packager_str=packager_str).update(packager=user)
......@@ -88,7 +88,7 @@ def match_flagrequest(finder):
logger.debug(" found user %s", user.username)
matched_count += 1
for user_email, user in mapping.items():
for user_email, user in list(mapping.items()):
req_count += FlagRequest.objects.filter(user__isnull=True,
user_email=user_email).update(user=user)
......
......@@ -107,12 +107,12 @@ def __init__(self, repo):
self.files = None
def populate(self, values):
for k, v in values.iteritems():
for k, v in values.items():
# ensure we stay under our DB character limit
if k in self.bare:
setattr(self, k, v[0][:254])
elif k in self.number:
setattr(self, k, long(v[0]))
setattr(self, k, int(v[0]))
elif k in ('desc', 'pgpsig'):
# do NOT prune these values at all
setattr(self, k, v[0])
......@@ -145,8 +145,8 @@ def files_list(self):
def full_version(self):
'''Very similar to the main.models.Package method.'''
if self.epoch > 0:
return u'%d:%s-%s' % (self.epoch, self.ver, self.rel)
return u'%s-%s' % (self.ver, self.rel)
return '%d:%s-%s' % (self.epoch, self.ver, self.rel)
return '%s-%s' % (self.ver, self.rel)
DEPEND_RE = re.compile(r"^(.+?)((>=|<=|=|>|<)(.+))?$")
......@@ -573,7 +573,7 @@ def parse_repo(repopath):
repodb.close()
logger.info("Finished repo parsing, %d total packages", len(pkgs))
return (reponame, pkgs.values())
return (reponame, list(pkgs.values()))
def locate_arch(arch):
"Check if arch is valid."
......
......@@ -187,7 +187,7 @@ def my_init(self, **kwargs):
# we really want a single path to arch mapping, so massage the data
arch_paths = kwargs['arch_paths']
for arch, paths in arch_paths.items():
for arch, paths in list(arch_paths.items()):
self.arch_lookup.update((path.rstrip('/'), arch) for path in paths)
def process_default(self, event):
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import pytz
from django.db import models, migrations
import django_countries.fields
import django.db.models.deletion
from django.conf import settings
import devel.fields
class Migration(migrations.Migration):
dependencies = [
('main', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='DeveloperKey',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('key', devel.fields.PGPKeyField(unique=True, max_length=40, verbose_name=b'PGP key fingerprint')),
('created', models.DateTimeField()),
('expires', models.DateTimeField(null=True, blank=True)),
('revoked', models.DateTimeField(null=True, blank=True)),
('owner', models.ForeignKey(related_name=b'all_keys', to=settings.AUTH_USER_MODEL, help_text=b'The developer this key belongs to', null=True)),
('parent', models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, to='devel.DeveloperKey', null=True)),
],
options={
},
bases=(models.Model,),
),
migrations.CreateModel(
name='MasterKey',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('pgp_key', devel.fields.PGPKeyField(help_text=b'consists of 40 hex digits; use `gpg --fingerprint`', max_length=40, verbose_name=b'PGP key fingerprint')),
('created', models.DateField()),
('revoked', models.DateField(null=True, blank=True)),
('owner', models.ForeignKey(related_name=b'masterkey_owner', to=settings.AUTH_USER_MODEL, help_text=b'The developer holding this master key')),
('revoker', models.ForeignKey(related_name=b'masterkey_revoker', to=settings.AUTH_USER_MODEL, help_text=b'The developer holding the revocation certificate')),
],
options={
'ordering': ('created',),
'get_latest_by': 'created',
},
bases=(models.Model,),
),
migrations.CreateModel(
name='PGPSignature',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('signer', devel.fields.PGPKeyField(max_length=40, verbose_name=b'Signer key fingerprint', db_index=True)),
('signee', devel.fields.PGPKeyField(max_length=40, verbose_name=b'Signee key fingerprint', db_index=True)),
('created', models.DateField()),
('expires', models.DateField(null=True, blank=True)),
('revoked', models.DateField(null=True, blank=True)),
],
options={
'ordering': ('signer', 'signee'),
'get_latest_by': 'created',
'verbose_name': 'PGP signature',
},
bases=(models.Model,),
),
migrations.CreateModel(
name='UserProfile',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('notify', models.BooleanField(default=True, help_text=b"When enabled, send user 'flag out-of-date' notifications", verbose_name=b'Send notifications')),
('time_zone', models.CharField(default=b'UTC', help_text=b'Used for developer clock page', max_length=100, choices=[(z, z) for z in pytz.common_timezones])),
('alias', models.CharField(help_text=b'Required field', max_length=50)),
('public_email', models.CharField(help_text=b'Required field', max_length=50)),
('other_contact', models.CharField(max_length=100, null=True, blank=True)),
('pgp_key', devel.fields.PGPKeyField(help_text=b'consists of 40 hex digits; use `gpg --fingerprint`', max_length=40, null=True, verbose_name=b'PGP key fingerprint', blank=True)),
('website', models.CharField(max_length=200, null=True, blank=True)),
('yob', models.IntegerField(null=True, verbose_name=b'Year of birth', blank=True)),
('country', django_countries.fields.CountryField(blank=True, max_length=2)),
('location', models.CharField(max_length=50, null=True, blank=True)),
('languages', models.CharField(max_length=50, null=True, blank=True)),
('interests', models.CharField(max_length=255, null=True, blank=True)),
('occupation', models.CharField(max_length=50, null=True, blank=True)),
('roles', models.CharField(max_length=255, null=True, blank=True)),
('favorite_distros', models.CharField(max_length=255, null=True, blank=True)),
('picture', models.FileField(default=b'devs/silhouette.png', help_text=b'Ideally 125px by 125px', upload_to=b'devs')),
('latin_name', models.CharField(help_text=b'Latin-form name; used only for non-Latin full names', max_length=255, null=True, blank=True)),
('last_modified', models.DateTimeField(editable=False)),
('allowed_repos', models.ManyToManyField(to='main.Repo', blank=True)),
('user', models.OneToOneField(related_name=b'userprofile', to=settings.AUTH_USER_MODEL)),
],
options={
'get_latest_by': 'last_modified',
'verbose_name': 'additional profile data',
'verbose_name_plural': 'additional profile data',
'db_table': 'user_profiles',
},
bases=(models.Model,),
),
]
# Generated by Django 2.1.4 on 2018-12-16 16:05
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('devel', '0001_squashed_0002_staffgroup'),
]
operations = [
migrations.AlterField(
model_name='userprofile',
name='time_zone',
field=models.CharField(choices=[('Africa/Abidjan', 'Africa/Abidjan'), ('Africa/Accra', 'Africa/Accra'), ('Africa/Addis_Ababa', 'Africa/Addis_Ababa'), ('Africa/Algiers', 'Africa/Algiers'), ('Africa/Asmara', 'Africa/Asmara'), ('Africa/Bamako', 'Africa/Bamako'), ('Africa/Bangui', 'Africa/Bangui'), ('Africa/Banjul', 'Africa/Banjul'), ('Africa/Bissau', 'Africa/Bissau'), ('Africa/Blantyre', 'Africa/Blantyre'), ('Africa/Brazzaville', 'Africa/Brazzaville'), ('Africa/Bujumbura', 'Africa/Bujumbura'), ('Africa/Cairo', 'Africa/Cairo'), ('Africa/Casablanca', 'Africa/Casablanca'), ('Africa/Ceuta', 'Africa/Ceuta'), ('Africa/Conakry', 'Africa/Conakry'), ('Africa/Dakar', 'Africa/Dakar'), ('Africa/Dar_es_Salaam', 'Africa/Dar_es_Salaam'), ('Africa/Djibouti', 'Africa/Djibouti'), ('Africa/Douala', 'Africa/Douala'), ('Africa/El_Aaiun', 'Africa/El_Aaiun'), ('Africa/Freetown', 'Africa/Freetown'), ('Africa/Gaborone', 'Africa/Gaborone'), ('Africa/Harare', 'Africa/Harare'), ('Africa/Johannesburg', 'Africa/Johannesburg'), ('Africa/Juba', 'Africa/Juba'), ('Africa/Kampala', 'Africa/Kampala'), ('Africa/Khartoum', 'Africa/Khartoum'), ('Africa/Kigali', 'Africa/Kigali'), ('Africa/Kinshasa', 'Africa/Kinshasa'), ('Africa/Lagos', 'Africa/Lagos'), ('Africa/Libreville', 'Africa/Libreville'), ('Africa/Lome', 'Africa/Lome'), ('Africa/Luanda', 'Africa/Luanda'), ('Africa/Lubumbashi', 'Africa/Lubumbashi'), ('Africa/Lusaka', 'Africa/Lusaka'), ('Africa/Malabo', 'Africa/Malabo'), ('Africa/Maputo', 'Africa/Maputo'), ('Africa/Maseru', 'Africa/Maseru'), ('Africa/Mbabane', 'Africa/Mbabane'), ('Africa/Mogadishu', 'Africa/Mogadishu'), ('Africa/Monrovia', 'Africa/Monrovia'), ('Africa/Nairobi', 'Africa/Nairobi'), ('Africa/Ndjamena', 'Africa/Ndjamena'), ('Africa/Niamey', 'Africa/Niamey'), ('Africa/Nouakchott', 'Africa/Nouakchott'), ('Africa/Ouagadougou', 'Africa/Ouagadougou'), ('Africa/Porto-Novo', 'Africa/Porto-Novo'), ('Africa/Sao_Tome', 'Africa/Sao_Tome'), ('Africa/Tripoli', 'Africa/Tripoli'), ('Africa/Tunis', 'Africa/Tunis'), ('Africa/Windhoek', 'Africa/Windhoek'), ('America/Adak', 'America/Adak'), ('America/Anchorage', 'America/Anchorage'), ('America/Anguilla', 'America/Anguilla'), ('America/Antigua', 'America/Antigua'), ('America/Araguaina', 'America/Araguaina'), ('America/Argentina/Buenos_Aires', 'America/Argentina/Buenos_Aires'), ('America/Argentina/Catamarca', 'America/Argentina/Catamarca'), ('America/Argentina/Cordoba', 'America/Argentina/Cordoba'), ('America/Argentina/Jujuy', 'America/Argentina/Jujuy'), ('America/Argentina/La_Rioja', 'America/Argentina/La_Rioja'), ('America/Argentina/Mendoza', 'America/Argentina/Mendoza'), ('America/Argentina/Rio_Gallegos', 'America/Argentina/Rio_Gallegos'), ('America/Argentina/Salta', 'America/Argentina/Salta'), ('America/Argentina/San_Juan', 'America/Argentina/San_Juan'), ('America/Argentina/San_Luis', 'America/Argentina/San_Luis'), ('America/Argentina/Tucuman', 'America/Argentina/Tucuman'), ('America/Argentina/Ushuaia', 'America/Argentina/Ushuaia'), ('America/Aruba', 'America/Aruba'), ('America/Asuncion', 'America/Asuncion'), ('America/Atikokan', 'America/Atikokan'), ('America/Bahia', 'America/Bahia'), ('America/Bahia_Banderas', 'America/Bahia_Banderas'), ('America/Barbados', 'America/Barbados'), ('America/Belem', 'America/Belem'), ('America/Belize', 'America/Belize'), ('America/Blanc-Sablon', 'America/Blanc-Sablon'), ('America/Boa_Vista', 'America/Boa_Vista'), ('America/Bogota', 'America/Bogota'), ('America/Boise', 'America/Boise'), ('America/Cambridge_Bay', 'America/Cambridge_Bay'), ('America/Campo_Grande', 'America/Campo_Grande'), ('America/Cancun', 'America/Cancun'), ('America/Caracas', 'America/Caracas'), ('America/Cayenne', 'America/Cayenne'), ('America/Cayman', 'America/Cayman'), ('America/Chicago', 'America/Chicago'), ('America/Chihuahua', 'America/Chihuahua'), ('America/Costa_Rica', 'America/Costa_Rica'), ('America/Creston', 'America/Creston'), ('America/Cuiaba', 'America/Cuiaba'), ('America/Curacao', 'America/Curacao'), ('America/Danmarkshavn', 'America/Danmarkshavn'), ('America/Dawson', 'America/Dawson'), ('America/Dawson_Creek', 'America/Dawson_Creek'), ('America/Denver', 'America/Denver'), ('America/Detroit', 'America/Detroit'), ('America/Dominica', 'America/Dominica'), ('America/Edmonton', 'America/Edmonton'), ('America/Eirunepe', 'America/Eirunepe'), ('America/El_Salvador', 'America/El_Salvador'), ('America/Fort_Nelson', 'America/Fort_Nelson'), ('America/Fortaleza', 'America/Fortaleza'), ('America/Glace_Bay', 'America/Glace_Bay'), ('America/Godthab', 'America/Godthab'), ('America/Goose_Bay', 'America/Goose_Bay'), ('America/Grand_Turk', 'America/Grand_Turk'), ('America/Grenada', 'America/Grenada'), ('America/Guadeloupe', 'America/Guadeloupe'), ('America/Guatemala', 'America/Guatemala'), ('America/Guayaquil', 'America/Guayaquil'), ('America/Guyana', 'America/Guyana'), ('America/Halifax', 'America/Halifax'), ('America/Havana', 'America/Havana'), ('America/Hermosillo', 'America/Hermosillo'), ('America/Indiana/Indianapolis', 'America/Indiana/Indianapolis'), ('America/Indiana/Knox', 'America/Indiana/Knox'), ('America/Indiana/Marengo', 'America/Indiana/Marengo'), ('America/Indiana/Petersburg', 'America/Indiana/Petersburg'), ('America/Indiana/Tell_City', 'America/Indiana/Tell_City'), ('America/Indiana/Vevay', 'America/Indiana/Vevay'), ('America/Indiana/Vincennes', 'America/Indiana/Vincennes'), ('America/Indiana/Winamac', 'America/Indiana/Winamac'), ('America/Inuvik', 'America/Inuvik'), ('America/Iqaluit', 'America/Iqaluit'), ('America/Jamaica', 'America/Jamaica'), ('America/Juneau', 'America/Juneau'), ('America/Kentucky/Louisville', 'America/Kentucky/Louisville'), ('America/Kentucky/Monticello', 'America/Kentucky/Monticello'), ('America/Kralendijk', 'America/Kralendijk'), ('America/La_Paz', 'America/La_Paz'), ('America/Lima', 'America/Lima'), ('America/Los_Angeles', 'America/Los_Angeles'), ('America/Lower_Princes', 'America/Lower_Princes'), ('America/Maceio', 'America/Maceio'), ('America/Managua', 'America/Managua'), ('America/Manaus', 'America/Manaus'), ('America/Marigot', 'America/Marigot'), ('America/Martinique', 'America/Martinique'), ('America/Matamoros', 'America/Matamoros'), ('America/Mazatlan', 'America/Mazatlan'), ('America/Menominee', 'America/Menominee'), ('America/Merida', 'America/Merida'), ('America/Metlakatla', 'America/Metlakatla'), ('America/Mexico_City', 'America/Mexico_City'), ('America/Miquelon', 'America/Miquelon'), ('America/Moncton', 'America/Moncton'), ('America/Monterrey', 'America/Monterrey'), ('America/Montevideo', 'America/Montevideo'), ('America/Montserrat', 'America/Montserrat'), ('America/Nassau', 'America/Nassau'), ('America/New_York', 'America/New_York'), ('America/Nipigon', 'America/Nipigon'), ('America/Nome', 'America/Nome'), ('America/Noronha', 'America/Noronha'), ('America/North_Dakota/Beulah', 'America/North_Dakota/Beulah'), ('America/North_Dakota/Center', 'America/North_Dakota/Center'), ('America/North_Dakota/New_Salem', 'America/North_Dakota/New_Salem'), ('America/Ojinaga', 'America/Ojinaga'), ('America/Panama', 'America/Panama'), ('America/Pangnirtung', 'America/Pangnirtung'), ('America/Paramaribo', 'America/Paramaribo'), ('America/Phoenix', 'America/Phoenix'), ('America/Port-au-Prince', 'America/Port-au-Prince'), ('America/Port_of_Spain', 'America/Port_of_Spain'), ('America/Porto_Velho', 'America/Porto_Velho'), ('America/Puerto_Rico', 'America/Puerto_Rico'), ('America/Punta_Arenas', 'America/Punta_Arenas'), ('America/Rainy_River', 'America/Rainy_River'), ('America/Rankin_Inlet', 'America/Rankin_Inlet'), ('America/Recife', 'America/Recife'), ('America/Regina', 'America/Regina'), ('America/Resolute', 'America/Resolute'), ('America/Rio_Branco', 'America/Rio_Branco'), ('America/Santarem', 'America/Santarem'), ('America/Santiago', 'America/Santiago'), ('America/Santo_Domingo', 'America/Santo_Domingo'), ('America/Sao_Paulo', 'America/Sao_Paulo'), ('America/Scoresbysund', 'America/Scoresbysund'), ('America/Sitka', 'America/Sitka'), ('America/St_Barthelemy', 'America/St_Barthelemy'), ('America/St_Johns', 'America/St_Johns'), ('America/St_Kitts', 'America/St_Kitts'), ('America/St_Lucia', 'America/St_Lucia'), ('America/St_Thomas', 'America/St_Thomas'), ('America/St_Vincent', 'America/St_Vincent'), ('America/Swift_Current', 'America/Swift_Current'), ('America/Tegucigalpa', 'America/Tegucigalpa'), ('America/Thule', 'America/Thule'), ('America/Thunder_Bay', 'America/Thunder_Bay'), ('America/Tijuana', 'America/Tijuana'), ('America/Toronto', 'America/Toronto'), ('America/Tortola', 'America/Tortola'), ('America/Vancouver', 'America/Vancouver'), ('America/Whitehorse', 'America/Whitehorse'), ('America/Winnipeg', 'America/Winnipeg'), ('America/Yakutat', 'America/Yakutat'), ('America/Yellowknife', 'America/Yellowknife'), ('Antarctica/Casey', 'Antarctica/Casey'), ('Antarctica/Davis', 'Antarctica/Davis'), ('Antarctica/DumontDUrville', 'Antarctica/DumontDUrville'), ('Antarctica/Macquarie', 'Antarctica/Macquarie'), ('Antarctica/Mawson', 'Antarctica/Mawson'), ('Antarctica/McMurdo', 'Antarctica/McMurdo'), ('Antarctica/Palmer', 'Antarctica/Palmer'), ('Antarctica/Rothera', 'Antarctica/Rothera'), ('Antarctica/Syowa', 'Antarctica/Syowa'), ('Antarctica/Troll', 'Antarctica/Troll'), ('Antarctica/Vostok', 'Antarctica/Vostok'), ('Arctic/Longyearbyen', 'Arctic/Longyearbyen'), ('Asia/Aden', 'Asia/Aden'), ('Asia/Almaty', 'Asia/Almaty'), ('Asia/Amman', 'Asia/Amman'), ('Asia/Anadyr', 'Asia/Anadyr'), ('Asia/Aqtau', 'Asia/Aqtau'), ('Asia/Aqtobe', 'Asia/Aqtobe'), ('Asia/Ashgabat', 'Asia/Ashgabat'), ('Asia/Atyrau', 'Asia/Atyrau'), ('Asia/Baghdad', 'Asia/Baghdad'), ('Asia/Bahrain', 'Asia/Bahrain'), ('Asia/Baku', 'Asia/Baku'), ('Asia/Bangkok', 'Asia/Bangkok'), ('Asia/Barnaul', 'Asia/Barnaul'), ('Asia/Beirut', 'Asia/Beirut'), ('Asia/Bishkek', 'Asia/Bishkek'), ('Asia/Brunei', 'Asia/Brunei'), ('Asia/Chita', 'Asia/Chita'), ('Asia/Choibalsan', 'Asia/Choibalsan'), ('Asia/Colombo', 'Asia/Colombo'), ('Asia/Damascus', 'Asia/Damascus'), ('Asia/Dhaka', 'Asia/Dhaka'), ('Asia/Dili', 'Asia/Dili'), ('Asia/Dubai', 'Asia/Dubai'), ('Asia/Dushanbe', 'Asia/Dushanbe'), ('Asia/Famagusta', 'Asia/Famagusta'), ('Asia/Gaza', 'Asia/Gaza'), ('Asia/Hebron', 'Asia/Hebron'), ('Asia/Ho_Chi_Minh', 'Asia/Ho_Chi_Minh'), ('Asia/Hong_Kong', 'Asia/Hong_Kong'), ('Asia/Hovd', 'Asia/Hovd'), ('Asia/Irkutsk', 'Asia/Irkutsk'), ('Asia/Jakarta', 'Asia/Jakarta'), ('Asia/Jayapura', 'Asia/Jayapura'), ('Asia/Jerusalem', 'Asia/Jerusalem'), ('Asia/Kabul', 'Asia/Kabul'), ('Asia/Kamchatka', 'Asia/Kamchatka'), ('Asia/Karachi', 'Asia/Karachi'), ('Asia/Kathmandu', 'Asia/Kathmandu'), ('Asia/Khandyga', 'Asia/Khandyga'), ('Asia/Kolkata', 'Asia/Kolkata'), ('Asia/Krasnoyarsk', 'Asia/Krasnoyarsk'), ('Asia/Kuala_Lumpur', 'Asia/Kuala_Lumpur'), ('Asia/Kuching', 'Asia/Kuching'), ('Asia/Kuwait', 'Asia/Kuwait'), ('Asia/Macau', 'Asia/Macau'), ('Asia/Magadan', 'Asia/Magadan'), ('Asia/Makassar', 'Asia/Makassar'), ('Asia/Manila', 'Asia/Manila'), ('Asia/Muscat', 'Asia/Muscat'), ('Asia/Nicosia', 'Asia/Nicosia'), ('Asia/Novokuznetsk', 'Asia/Novokuznetsk'), ('Asia/Novosibirsk', 'Asia/Novosibirsk'), ('Asia/Omsk', 'Asia/Omsk'), ('Asia/Oral', 'Asia/Oral'), ('Asia/Phnom_Penh', 'Asia/Phnom_Penh'), ('Asia/Pontianak', 'Asia/Pontianak'), ('Asia/Pyongyang', 'Asia/Pyongyang'), ('Asia/Qatar', 'Asia/Qatar'), ('Asia/Qyzylorda', 'Asia/Qyzylorda'), ('Asia/Riyadh', 'Asia/Riyadh'), ('Asia/Sakhalin', 'Asia/Sakhalin'), ('Asia/Samarkand', 'Asia/Samarkand'), ('Asia/Seoul', 'Asia/Seoul'), ('Asia/Shanghai', 'Asia/Shanghai'), ('Asia/Singapore', 'Asia/Singapore'), ('Asia/Srednekolymsk', 'Asia/Srednekolymsk'), ('Asia/Taipei', 'Asia/Taipei'), ('Asia/Tashkent', 'Asia/Tashkent'), ('Asia/Tbilisi', 'Asia/Tbilisi'), ('Asia/Tehran', 'Asia/Tehran'), ('Asia/Thimphu', 'Asia/Thimphu'), ('Asia/Tokyo', 'Asia/Tokyo'), ('Asia/Tomsk', 'Asia/Tomsk'), ('Asia/Ulaanbaatar', 'Asia/Ulaanbaatar'), ('Asia/Urumqi', 'Asia/Urumqi'), ('Asia/Ust-Nera', 'Asia/Ust-Nera'), ('Asia/Vientiane', 'Asia/Vientiane'), ('Asia/Vladivostok', 'Asia/Vladivostok'), ('Asia/Yakutsk', 'Asia/Yakutsk'), ('Asia/Yangon', 'Asia/Yangon'), ('Asia/Yekaterinburg', 'Asia/Yekaterinburg'), ('Asia/Yerevan', 'Asia/Yerevan'), ('Atlantic/Azores', 'Atlantic/Azores'), ('Atlantic/Bermuda', 'Atlantic/Bermuda'), ('Atlantic/Canary', 'Atlantic/Canary'), ('Atlantic/Cape_Verde', 'Atlantic/Cape_Verde'), ('Atlantic/Faroe', 'Atlantic/Faroe'), ('Atlantic/Madeira', 'Atlantic/Madeira'), ('Atlantic/Reykjavik', 'Atlantic/Reykjavik'), ('Atlantic/South_Georgia', 'Atlantic/South_Georgia'), ('Atlantic/St_Helena', 'Atlantic/St_Helena'), ('Atlantic/Stanley', 'Atlantic/Stanley'), ('Australia/Adelaide', 'Australia/Adelaide'), ('Australia/Brisbane', 'Australia/Brisbane'), ('Australia/Broken_Hill', 'Australia/Broken_Hill'), ('Australia/Currie', 'Australia/Currie'), ('Australia/Darwin', 'Australia/Darwin'), ('Australia/Eucla', 'Australia/Eucla'), ('Australia/Hobart', 'Australia/Hobart'), ('Australia/Lindeman', 'Australia/Lindeman'), ('Australia/Lord_Howe', 'Australia/Lord_Howe'), ('Australia/Melbourne', 'Australia/Melbourne'), ('Australia/Perth', 'Australia/Perth'), ('Australia/Sydney', 'Australia/Sydney'), ('Canada/Atlantic', 'Canada/Atlantic'), ('Canada/Central', 'Canada/Central'), ('Canada/Eastern', 'Canada/Eastern'), ('Canada/Mountain', 'Canada/Mountain'), ('Canada/Newfoundland', 'Canada/Newfoundland'), ('Canada/Pacific', 'Canada/Pacific'), ('Europe/Amsterdam', 'Europe/Amsterdam'), ('Europe/Andorra', 'Europe/Andorra'), ('Europe/Astrakhan', 'Europe/Astrakhan'), ('Europe/Athens', 'Europe/Athens'), ('Europe/Belgrade', 'Europe/Belgrade'), ('Europe/Berlin', 'Europe/Berlin'), ('Europe/Bratislava', 'Europe/Bratislava'), ('Europe/Brussels', 'Europe/Brussels'), ('Europe/Bucharest', 'Europe/Bucharest'), ('Europe/Budapest', 'Europe/Budapest'), ('Europe/Busingen', 'Europe/Busingen'), ('Europe/Chisinau', 'Europe/Chisinau'), ('Europe/Copenhagen', 'Europe/Copenhagen'), ('Europe/Dublin', 'Europe/Dublin'), ('Europe/Gibraltar', 'Europe/Gibraltar'), ('Europe/Guernsey', 'Europe/Guernsey'), ('Europe/Helsinki', 'Europe/Helsinki'), ('Europe/Isle_of_Man', 'Europe/Isle_of_Man'), ('Europe/Istanbul', 'Europe/Istanbul'), ('Europe/Jersey', 'Europe/Jersey'), ('Europe/Kaliningrad', 'Europe/Kaliningrad'), ('Europe/Kiev', 'Europe/Kiev'), ('Europe/Kirov', 'Europe/Kirov'), ('Europe/Lisbon', 'Europe/Lisbon'), ('Europe/Ljubljana', 'Europe/Ljubljana'), ('Europe/London', 'Europe/London'), ('Europe/Luxembourg', 'Europe/Luxembourg'), ('Europe/Madrid', 'Europe/Madrid'), ('Europe/Malta', 'Europe/Malta'), ('Europe/Mariehamn', 'Europe/Mariehamn'), ('Europe/Minsk', 'Europe/Minsk'), ('Europe/Monaco', 'Europe/Monaco'), ('Europe/Moscow', 'Europe/Moscow'), ('Europe/Oslo', 'Europe/Oslo'), ('Europe/Paris', 'Europe/Paris'), ('Europe/Podgorica', 'Europe/Podgorica'), ('Europe/Prague', 'Europe/Prague'), ('Europe/Riga', 'Europe/Riga'), ('Europe/Rome', 'Europe/Rome'), ('Europe/Samara', 'Europe/Samara'), ('Europe/San_Marino', 'Europe/San_Marino'), ('Europe/Sarajevo', 'Europe/Sarajevo'), ('Europe/Saratov', 'Europe/Saratov'), ('Europe/Simferopol', 'Europe/Simferopol'), ('Europe/Skopje', 'Europe/Skopje'), ('Europe/Sofia', 'Europe/Sofia'), ('Europe/Stockholm', 'Europe/Stockholm'), ('Europe/Tallinn', 'Europe/Tallinn'), ('Europe/Tirane', 'Europe/Tirane'), ('Europe/Ulyanovsk', 'Europe/Ulyanovsk'), ('Europe/Uzhgorod', 'Europe/Uzhgorod'), ('Europe/Vaduz', 'Europe/Vaduz'), ('Europe/Vatican', 'Europe/Vatican'), ('Europe/Vienna', 'Europe/Vienna'), ('Europe/Vilnius', 'Europe/Vilnius'), ('Europe/Volgograd', 'Europe/Volgograd'), ('Europe/Warsaw', 'Europe/Warsaw'), ('Europe/Zagreb', 'Europe/Zagreb'), ('Europe/Zaporozhye', 'Europe/Zaporozhye'), ('Europe/Zurich', 'Europe/Zurich'), ('GMT', 'GMT'), ('Indian/Antananarivo', 'Indian/Antananarivo'), ('Indian/Chagos', 'Indian/Chagos'), ('Indian/Christmas', 'Indian/Christmas'), ('Indian/Cocos', 'Indian/Cocos'), ('Indian/Comoro', 'Indian/Comoro'), ('Indian/Kerguelen', 'Indian/Kerguelen'), ('Indian/Mahe', 'Indian/Mahe'), ('Indian/Maldives', 'Indian/Maldives'), ('Indian/Mauritius', 'Indian/Mauritius'), ('Indian/Mayotte', 'Indian/Mayotte'), ('Indian/Reunion', 'Indian/Reunion'), ('Pacific/Apia', 'Pacific/Apia'), ('Pacific/Auckland', 'Pacific/Auckland'), ('Pacific/Bougainville', 'Pacific/Bougainville'), ('Pacific/Chatham', 'Pacific/Chatham'), ('Pacific/Chuuk', 'Pacific/Chuuk'), ('Pacific/Easter', 'Pacific/Easter'), ('Pacific/Efate', 'Pacific/Efate'), ('Pacific/Enderbury', 'Pacific/Enderbury'), ('Pacific/Fakaofo', 'Pacific/Fakaofo'), ('Pacific/Fiji', 'Pacific/Fiji'), ('Pacific/Funafuti', 'Pacific/Funafuti'), ('Pacific/Galapagos', 'Pacific/Galapagos'), ('Pacific/Gambier', 'Pacific/Gambier'), ('Pacific/Guadalcanal', 'Pacific/Guadalcanal'), ('Pacific/Guam', 'Pacific/Guam'), ('Pacific/Honolulu', 'Pacific/Honolulu'), ('Pacific/Kiritimati', 'Pacific/Kiritimati'), ('Pacific/Kosrae', 'Pacific/Kosrae'), ('Pacific/Kwajalein', 'Pacific/Kwajalein'), ('Pacific/Majuro', 'Pacific/Majuro'), ('Pacific/Marquesas', 'Pacific/Marquesas'), ('Pacific/Midway', 'Pacific/Midway'), ('Pacific/Nauru', 'Pacific/Nauru'), ('Pacific/Niue', 'Pacific/Niue'), ('Pacific/Norfolk', 'Pacific/Norfolk'), ('Pacific/Noumea', 'Pacific/Noumea'), ('Pacific/Pago_Pago', 'Pacific/Pago_Pago'), ('Pacific/Palau', 'Pacific/Palau'), ('Pacific/Pitcairn', 'Pacific/Pitcairn'), ('Pacific/Pohnpei', 'Pacific/Pohnpei'), ('Pacific/Port_Moresby', 'Pacific/Port_Moresby'), ('Pacific/Rarotonga', 'Pacific/Rarotonga'), ('Pacific/Saipan', 'Pacific/Saipan'), ('Pacific/Tahiti', 'Pacific/Tahiti'), ('Pacific/Tarawa', 'Pacific/Tarawa'), ('Pacific/Tongatapu', 'Pacific/Tongatapu'), ('Pacific/Wake', 'Pacific/Wake'), ('Pacific/Wallis', 'Pacific/Wallis'), ('US/Alaska', 'US/Alaska'), ('US/Arizona', 'US/Arizona'), ('US/Central', 'US/Central'), ('US/Eastern', 'US/Eastern'), ('US/Hawaii', 'US/Hawaii'), ('US/Mountain', 'US/Mountain'), ('US/Pacific', 'US/Pacific'), ('UTC', 'UTC')], default='UTC', help_text='Used for developer clock page', max_length=100),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('auth', '0001_initial'),
('devel', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='StaffGroup',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('slug', models.SlugField(unique=True, max_length=100)),
('sort_order', models.PositiveIntegerField()),
('member_title', models.CharField(max_length=100)),
('description', models.TextField(blank=True)),
('group', models.OneToOneField(to='auth.Group')),
],
options={
'ordering': ('sort_order',),
},
bases=(models.Model,),
),
]
# -*- coding: utf-8 -*-
import pytz
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.db import models
from django.db.models.signals import pre_save
from django.contrib.auth.models import User, Group
......@@ -73,7 +73,7 @@ class StaffGroup(models.Model):
class Meta:
ordering = ('sort_order',)
def __unicode__(self):
def __str__(self):
return self.name
def get_absolute_url(self):
......@@ -94,8 +94,8 @@ class Meta:
ordering = ('created',)
get_latest_by = 'created'
def __unicode__(self):
return u'%s, created %s' % (
def __str__(self):
return '%s, created %s' % (
self.owner.get_full_name(), self.created)
......@@ -109,7 +109,7 @@ class DeveloperKey(models.Model):
revoked = models.DateTimeField(null=True, blank=True)
parent = models.ForeignKey('self', null=True, on_delete=models.SET_NULL)
def __unicode__(self):
def __str__(self):
return self.key
......@@ -127,8 +127,8 @@ class Meta:
get_latest_by = 'created'
verbose_name = 'PGP signature'
def __unicode__(self):
return u'%s → %s' % (self.signer, self.signee)
def __str__(self):
return '%s → %s' % (self.signer, self.signee)
pre_save.connect(set_created_field, sender=UserProfile,
......
......@@ -58,7 +58,7 @@ def test_read_packages(self):
packages = Package.objects.all()
import_packages = ["{}-{}-{}".format(pkg.pkgname, pkg.pkgver, pkg.pkgrel) for pkg in packages]
self.assertItemsEqual(files, import_packages)
self.assertCountEqual(files, import_packages)
def test_flagoutofdate(self):
pkg = self.create_pkg()
......
......@@ -13,7 +13,7 @@
from django.db.models import Count, Max
from django.http import Http404, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from django.utils.encoding import force_unicode
from django.utils.encoding import force_text
from django.utils.http import http_date
from django.utils.timezone import now
from django.views.decorators.cache import never_cache
......@@ -225,7 +225,7 @@ def log_addition(request, obj):
user_id=request.user.pk,
content_type_id=ContentType.objects.get_for_model(obj).pk,
object_id=obj.pk,
object_repr=force_unicode(obj),
object_repr=force_text(obj),
action_flag=ADDITION,
change_message="Added via Create New User form.")
......
......@@ -25,11 +25,11 @@ def write(self, s):
buf = self.buf
buf.append(s)
if len(buf) >= 40:
self.outfile.write(''.join(buf))
self.outfile.write(b''.join(buf))
self.buf = []
def flush(self):
self.outfile.write(''.join(self.buf))
self.outfile.write(b''.join(self.buf))
self.outfile.flush()
......
......@@ -45,7 +45,7 @@ def filter(self, record):
return True
trace = '\n'.join(traceback.format_exception(*record.exc_info))
key = md5(trace).hexdigest()
key = md5(trace.encode('utf-8')).hexdigest()
cache = self.cache_module.cache
# Test if the cache works
......
......@@ -14,6 +14,7 @@
Usage: ./manage.py donor_import path/to/maildir/
"""
import codecs
import logging
import mailbox
import sys
......@@ -43,10 +44,10 @@ def add_arguments(self, parser):
def decode_subject(self, subject):
subject = decode_header(subject)
default_charset = 'ASCII'
default_charset = 'utf-8'
# Convert the list of tuples containing the decoded string and encoding to
# the same encoding.
return u''.join([unicode(s[0], s[1] or default_charset) for s in subject])
# UTF-8
return ''.join([codecs.decode(s[0], s[1] or default_charset) for s in subject])
def parse_subject(self, subject):
......@@ -67,7 +68,7 @@ def sanitize_name(self, name):
return u''
# Strip any numbers, they could be a bank account number
name = filter(lambda x: not x.isdigit(), name)
name = u''.join([l for l in name if not l.isdigit()])
# Normalize all capitalized names. (JOHN DOE)
name = u' '.join(l.capitalize() for l in name.split(u' '))
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import main.fields
......@@ -19,8 +19,8 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(unique=True, max_length=255)),
('agnostic', models.BooleanField(default=False, help_text=b'Is this architecture non-platform specific?')),
('required_signoffs', models.PositiveIntegerField(default=2, help_text=b'Number of signoffs required for packages of this architecture')),
('agnostic', models.BooleanField(default=False, help_text='Is this architecture non-platform specific?')),
('required_signoffs', models.PositiveIntegerField(default=2, help_text='Number of signoffs required for packages of this architecture')),
],
options={
'ordering': ('name',),
......@@ -34,7 +34,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(unique=True, max_length=255)),
('visible', models.BooleanField(default=True, help_text=b'Should we show this donor on the public page?')),
('visible', models.BooleanField(default=True, help_text='Should we show this donor on the public page?')),
('created', models.DateTimeField()),
],
options={
......@@ -53,8 +53,8 @@ class Migration(migrations.Migration):
('pkgver', models.CharField(max_length=255)),
('pkgrel', models.CharField(max_length=255)),
('epoch', models.PositiveIntegerField(default=0)),
('pkgdesc', models.TextField(null=True, verbose_name=b'description')),
('url', models.CharField(max_length=255, null=True, verbose_name=b'URL')),
('pkgdesc', models.TextField(null=True, verbose_name='description')),
('url', models.CharField(max_length=255, null=True, verbose_name='URL')),
('filename', models.CharField(max_length=255)),
('compressed_size', main.fields.PositiveBigIntegerField()),
('installed_size', main.fields.PositiveBigIntegerField()),
......@@ -62,10 +62,10 @@ class Migration(migrations.Migration):
('last_update', models.DateTimeField(db_index=True)),
('files_last_update', models.DateTimeField(null=True, blank=True)),
('created', models.DateTimeField()),
('packager_str', models.CharField(max_length=255, verbose_name=b'packager string')),
('signature_bytes', models.BinaryField(verbose_name=b'PGP signature', null=True)),
('packager_str', models.CharField(max_length=255, verbose_name='packager string')),
('signature_bytes', models.BinaryField(verbose_name='PGP signature', null=True)),
('flag_date', models.DateTimeField(null=True, blank=True)),
('arch', models.ForeignKey(related_name=b'packages', on_delete=django.db.models.deletion.PROTECT, to='main.Arch')),
('arch', models.ForeignKey(related_name='packages', on_delete=django.db.models.deletion.PROTECT, to='main.Arch')),
('packager', models.ForeignKey(on_delete=django.db.models.deletion.SET_NULL, blank=True, to=settings.AUTH_USER_MODEL, null=True)),
],
options={
......@@ -82,7 +82,7 @@ class Migration(migrations.Migration):
('is_directory', models.BooleanField(default=False)),
('directory', models.CharField(max_length=1024)),
('filename', models.CharField(max_length=1024, null=True, blank=True)),
('pkg', models.ForeignKey(to='main.Package')),
('pkg', models.ForeignKey(to='main.Package', on_delete=django.db.models.CASCADE)),
],
options={
'db_table': 'package_files',
......@@ -94,11 +94,11 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(unique=True, max_length=255)),
('testing', models.BooleanField(default=False, help_text=b'Is this repo meant for package testing?')),
('staging', models.BooleanField(default=False, help_text=b'Is this repo meant for package staging?')),
('bugs_project', models.SmallIntegerField(default=1, help_text=b'Flyspray project ID for this repository.')),
('bugs_category', models.SmallIntegerField(default=2, help_text=b'Flyspray category ID for this repository.')),
('svn_root', models.CharField(help_text=b'SVN root (e.g. path) for this repository.', max_length=64)),
('testing', models.BooleanField(default=False, help_text='Is this repo meant for package testing?')),
('staging', models.BooleanField(default=False, help_text='Is this repo meant for package staging?')),
('bugs_project', models.SmallIntegerField(default=1, help_text='Flyspray project ID for this repository.')),
('bugs_category', models.SmallIntegerField(default=2, help_text='Flyspray category ID for this repository.')),
('svn_root', models.CharField(help_text='SVN root (e.g. path) for this repository.', max_length=64)),
],
options={
'ordering': ('name',),
......@@ -109,7 +109,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='package',
name='repo',
field=models.ForeignKey(related_name=b'packages', on_delete=django.db.models.deletion.PROTECT, to='main.Repo'),
field=models.ForeignKey(related_name='packages', on_delete=django.db.models.deletion.PROTECT, to='main.Repo'),
preserve_default=True,
),
migrations.AlterUniqueTogether(
......
......@@ -33,7 +33,7 @@ class Donor(models.Model):
help_text="Should we show this donor on the public page?")
created = models.DateTimeField()
def __unicode__(self):
def __str__(self):
return self.name
class Meta:
......@@ -49,7 +49,7 @@ class Arch(models.Model):
required_signoffs = models.PositiveIntegerField(default=2,
help_text="Number of signoffs required for packages of this architecture")
def __unicode__(self):
def __str__(self):
return self.name