summaryrefslogtreecommitdiffstats
path: root/devel
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-11-26 04:10:25 +0100
committerDan McGee <dan@archlinux.org>2013-11-26 04:10:25 +0100
commit108cfaa8df3b94031a3436fbb71c76fdc0650ba1 (patch)
tree61c30085b49e63c6605dfebac3bef5e123cbaa70 /devel
parent06317908f73420224fce0c400048c3b7dcfc8abb (diff)
parent071bd6bd71f681c45048fc0a0961e58d43d44d48 (diff)
downloadarchweb-108cfaa8df3b94031a3436fbb71c76fdc0650ba1.tar.gz
archweb-108cfaa8df3b94031a3436fbb71c76fdc0650ba1.tar.xz
Merge branch 'django-1.6'
Diffstat (limited to 'devel')
-rw-r--r--devel/management/commands/pgp_import.py4
-rw-r--r--devel/management/commands/rematch_developers.py4
-rw-r--r--devel/management/commands/reporead.py13
-rw-r--r--devel/management/commands/reporead_inotify.py2
-rw-r--r--devel/views.py6
5 files changed, 15 insertions, 14 deletions
diff --git a/devel/management/commands/pgp_import.py b/devel/management/commands/pgp_import.py
index faa9ff5..3f557fe 100644
--- a/devel/management/commands/pgp_import.py
+++ b/devel/management/commands/pgp_import.py
@@ -134,7 +134,7 @@ def import_keys(keyring):
logger.info("creating or finding %d keys", len(keydata))
created_ct = updated_ct = 0
- with transaction.commit_on_success():
+ with transaction.atomic():
finder = UserFinder()
# we are dependent on parents coming before children; parse_keydata
# uses an OrderedDict to ensure this is the case.
@@ -232,7 +232,7 @@ def import_signatures(keyring):
logger.info("creating or finding up to %d signatures", len(pruned_edges))
created_ct = updated_ct = 0
- with transaction.commit_on_success():
+ with transaction.atomic():
for edge in pruned_edges:
sig, created = PGPSignature.objects.get_or_create(
signer=edge.signer, signee=edge.signee,
diff --git a/devel/management/commands/rematch_developers.py b/devel/management/commands/rematch_developers.py
index 2b37958..7a06e08 100644
--- a/devel/management/commands/rematch_developers.py
+++ b/devel/management/commands/rematch_developers.py
@@ -44,7 +44,7 @@ class Command(NoArgsCommand):
match_packager(finder)
match_flagrequest(finder)
-@transaction.commit_on_success
+@transaction.atomic
def match_packager(finder):
logger.info("getting all unmatched packager strings")
package_count = matched_count = 0
@@ -70,7 +70,7 @@ def match_packager(finder):
package_count, matched_count)
-@transaction.commit_on_success
+@transaction.atomic
def match_flagrequest(finder):
logger.info("getting all flag request email addresses from unknown users")
req_count = matched_count = 0
diff --git a/devel/management/commands/reporead.py b/devel/management/commands/reporead.py
index ff7a842..2b565cf 100644
--- a/devel/management/commands/reporead.py
+++ b/devel/management/commands/reporead.py
@@ -13,6 +13,7 @@ Example:
./manage.py reporead i686 /tmp/core.db.tar.gz
"""
+from base64 import b64decode
from collections import defaultdict
from copy import copy
import io
@@ -217,7 +218,7 @@ def populate_pkg(dbpkg, repopkg, force=False, timestamp=None):
dbpkg.packager_str = repopkg.packager
# attempt to find the corresponding django user for this string
dbpkg.packager = finder.find(repopkg.packager)
- dbpkg.pgp_signature = repopkg.pgpsig
+ dbpkg.signature_bytes = b64decode(repopkg.pgpsig.encode('utf-8'))
if timestamp:
dbpkg.last_update = timestamp
@@ -302,7 +303,7 @@ def update_common(archname, reponame, pkgs, sanity_check=True):
# If isolation level is repeatable-read, we need to ensure each package
# update starts a new transaction and re-queries the database as
# necessary to guard against simultaneous updates.
- with transaction.commit_on_success():
+ with transaction.atomic():
# force the transaction dirty, even though we will only do reads
transaction.set_dirty()
@@ -365,7 +366,7 @@ def db_update(archname, reponame, pkgs, force=False):
dbpkg = Package(pkgname=pkg.name, arch=architecture, repo=repository,
created=timestamp)
try:
- with transaction.commit_on_success():
+ with transaction.atomic():
populate_pkg(dbpkg, pkg, timestamp=timestamp)
Update.objects.log_update(None, dbpkg)
except IntegrityError:
@@ -380,7 +381,7 @@ def db_update(archname, reponame, pkgs, force=False):
for pkgname in (dbset - syncset):
logger.info("Removing package %s", pkgname)
dbpkg = dbdict[pkgname]
- with transaction.commit_on_success():
+ with transaction.atomic():
Update.objects.log_update(dbpkg, None)
# no race condition here as long as simultaneous threads both
# issue deletes; second delete will be a no-op
@@ -403,7 +404,7 @@ def db_update(archname, reponame, pkgs, force=False):
# The odd select_for_update song and dance here are to ensure
# simultaneous updates don't happen on a package, causing
# files/depends/all related items to be double-imported.
- with transaction.commit_on_success():
+ with transaction.atomic():
dbpkg = Package.objects.select_for_update().get(id=dbpkg.id)
if not force and pkg_same_version(pkg, dbpkg):
logger.debug("Package %s was already updated", pkg.name)
@@ -431,7 +432,7 @@ def filesonly_update(archname, reponame, pkgs, force=False):
# The odd select_for_update song and dance here are to ensure
# simultaneous updates don't happen on a package, causing
# files to be double-imported.
- with transaction.commit_on_success():
+ with transaction.atomic():
if not dbpkg.files_last_update or not dbpkg.last_update:
pass
elif not force and dbpkg.files_last_update >= dbpkg.last_update:
diff --git a/devel/management/commands/reporead_inotify.py b/devel/management/commands/reporead_inotify.py
index 6aa4e0e..e3c720b 100644
--- a/devel/management/commands/reporead_inotify.py
+++ b/devel/management/commands/reporead_inotify.py
@@ -66,7 +66,7 @@ class Command(BaseCommand):
if hasattr(thread, 'cancel'):
thread.cancel()
- @transaction.commit_on_success
+ @transaction.atomic
def setup_notifier(self):
'''Set up and configure the inotify machinery and logic.
This takes the provided or default path_template and builds a list of
diff --git a/devel/views.py b/devel/views.py
index b6e8582..29954b5 100644
--- a/devel/views.py
+++ b/devel/views.py
@@ -167,7 +167,7 @@ def change_profile(request):
request.user.email = form.cleaned_data['email']
if form.cleaned_data['passwd1']:
request.user.set_password(form.cleaned_data['passwd1'])
- with transaction.commit_on_success():
+ with transaction.atomic():
request.user.save()
profile_form.save()
return HttpResponseRedirect('/devel/')
@@ -275,7 +275,7 @@ def report(request, report_name, username=None):
cutoff = timedelta(hours=24)
filtered = []
packages = packages.select_related(
- 'arch', 'repo', 'packager').filter(pgp_signature__isnull=False)
+ 'arch', 'repo', 'packager').filter(signature_bytes__isnull=False)
known_keys = DeveloperKey.objects.select_related(
'owner').filter(owner__isnull=False)
known_keys = {dk.key: dk for dk in known_keys}
@@ -335,7 +335,7 @@ def new_user_form(request):
if request.POST:
form = NewUserForm(request.POST)
if form.is_valid():
- with transaction.commit_on_success():
+ with transaction.atomic():
form.save()
log_addition(request, form.instance.user)
return HttpResponseRedirect('/admin/auth/user/%d/' % \