]> git.ipfire.org Git - pbs.git/commitdiff
Run 2to3
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 10 Jun 2021 15:09:47 +0000 (15:09 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 10 Jun 2021 15:09:47 +0000 (15:09 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
19 files changed:
src/buildservice/__init__.py
src/buildservice/bugtracker.py
src/buildservice/builders.py
src/buildservice/builds.py
src/buildservice/database.py
src/buildservice/jobs.py
src/buildservice/ldap.py
src/buildservice/messages.py
src/buildservice/mirrors.py
src/buildservice/misc.py
src/buildservice/repository.py
src/buildservice/sources.py
src/buildservice/uploads.py
src/buildservice/users.py
src/scripts/pakfire-build-service
src/web/base.py
src/web/builds.py
src/web/handlers.py
src/web/ui_modules.py

index c3d5ed08698007467fec56ed3dcbc25d2161a128..d26f92d96b17935a81402283ec2c49e0be60747a 100644 (file)
@@ -1,8 +1,8 @@
 #!/usr/bin/python
 
-from __future__ import absolute_import
 
-import ConfigParser
+
+import configparser
 import logging
 import os
 import pakfire
@@ -89,7 +89,7 @@ class Backend(object):
                return env
 
        def read_config(self, path):
-               c = ConfigParser.SafeConfigParser()
+               c = configparser.SafeConfigParser()
 
                # Import configuration from environment
                for section in self._environment_configuration:
@@ -123,7 +123,7 @@ class Backend(object):
                        hostname = self.config.get("database", "hostname")
                        user     = self.config.get("database", "user")
                        password = self.config.get("database", "password")
-               except ConfigParser.Error as e:
+               except configparser.Error as e:
                        log.error("Error parsing the config: %s" % e.message)
 
                log.debug("Connecting to database %s @ %s" % (name, hostname))
@@ -151,7 +151,7 @@ class Backend(object):
                        try:
                                logging.debug("Removing %s..." % path)
                                os.unlink(path)
-                       except OSError, e:
+                       except OSError as e:
                                logging.error("Could not remove %s: %s" % (path, e))
 
                        while True:                     
@@ -168,7 +168,7 @@ class Backend(object):
                                try:
                                        logging.debug("Removing %s..." % path)
                                        os.rmdir(path)
-                               except OSError, e:
+                               except OSError as e:
                                        logging.error("Could not remove %s: %s" % (path, e))
                                        break
 
index f9bc43b3eef3660f27df2075b94979846bfb0fa4..9eca7ced7212f8e303abf9caa82ed7312a15b549 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import xmlrpclib
+import xmlrpc.client
 
 from . import base
 
@@ -88,7 +88,7 @@ class Bugzilla(base.Object):
                base.Object.__init__(self, pakfire)
 
                # Open the connection to the server.
-               self.server = xmlrpclib.ServerProxy(self.url, use_datetime=True)
+               self.server = xmlrpc.client.ServerProxy(self.url, use_datetime=True)
 
                # Cache the credentials.
                self.__credentials = {
@@ -151,7 +151,7 @@ class Bugzilla(base.Object):
                try:
                        bug = BugzillaBug(self, bug_id)
 
-               except xmlrpclib.Fault:
+               except xmlrpc.client.Fault:
                        return None
 
                return bug
@@ -168,7 +168,7 @@ class Bugzilla(base.Object):
                        return
 
                elif len(users) > 1:
-                       raise Exception, "Got more than one result."
+                       raise Exception("Got more than one result.")
 
                return users[0]
 
@@ -208,7 +208,7 @@ class Bugzilla(base.Object):
                                # Set the changes.
                                bug.set_status(update.status, update.resolution, update.comment)
 
-                       except Exception, e:
+                       except Exception as e:
                                # If there was an error, we save that and go on.
                                self.db.execute("UPDATE builds_bugs_updates SET error = 'Y', error_msg = %s \
                                        WHERE id = %s", "%s" % e, update.id)
index 97de6121db88f74baf49b18183a8b5a91410329e..ce277d605dad728f7a558fc1aea2a43f93facc50 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-from __future__ import absolute_import, division
+
 
 import datetime
 import hashlib
index 83d5f241e625aaa490dffe8d4e3b3ac0b2bb4198..e971c064b6476cf5531b1e70abb7d9e3b9503e96 100644 (file)
@@ -172,7 +172,7 @@ class Builds(base.Object):
 
                # Check if scratch build has an owner.
                if type == "scratch" and not owner:
-                       raise Exception, "Scratch builds require an owner"
+                       raise Exception("Scratch builds require an owner")
 
                # Set the default priority of this build.
                if type == "release":
@@ -652,7 +652,7 @@ class Build(base.DataObject):
                                (self.pkg.name, self.pkg.epoch, self.pkg.version, self.pkg.release))
 
                else:
-                       raise Exception, "Unknown build type: %s" % self.type
+                       raise Exception("Unknown build type: %s" % self.type)
                        
                return os.path.join(*path)
 
@@ -964,7 +964,7 @@ class Build(base.DataObject):
                        return False
 
                # If there is no next repository, we cannot move anything.
-               if not self.repo.next:
+               if not self.repo.__next__:
                        return False
 
                # If the needed amount of score is reached, we can move forward.
index 53e163ab6d3ef7dd0d10ed60235f94001661b9b0..e5e5ab8f6cf1529fb0d4e00fdc0dc9ea914e4b3f 100644 (file)
@@ -8,7 +8,7 @@
        as torndb.
 """
 
-from __future__ import absolute_import, division, with_statement
+
 
 import itertools
 import logging
@@ -77,7 +77,7 @@ class Connection(object):
                try:
                        self._execute(cursor, query, parameters, kwparameters)
                        column_names = [d[0] for d in cursor.description]
-                       return [Row(itertools.izip(column_names, row)) for row in cursor]
+                       return [Row(zip(column_names, row)) for row in cursor]
                finally:
                        cursor.close()
 
index a6b0be0f8f961e1e2d800853f7a8a2180cfa9d0c..08318875eb1ffc6a2fecde71e25fcf5968195841 100644 (file)
@@ -114,7 +114,7 @@ class Job(base.DataObject):
 
                return iter(packages)
 
-       def __nonzero__(self):
+       def __bool__(self):
                return True
 
        def __len__(self):
@@ -641,7 +641,7 @@ class Job(base.DataObject):
                        solver = p.resolvdep(filename)
 
                # Catch dependency errors and log the problem string.
-               except DependencyError, e:
+               except DependencyError as e:
                        self.dependency_check_succeeded = False
                        self.message = e
 
index efa08ee95da004fb9f46b9c81e7d8f689c3ed30c..54b9f258a7c2a63e9661b16aec6fa46fda3982ec 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-from __future__ import absolute_import
+
 
 import ldap
 import logging
index 6a90fb87fd9681881f5f508436e40e2f310d1ece..df01ae128186a5378b5c9e09e84bedb28bc0dc07 100644 (file)
@@ -66,7 +66,7 @@ class Messages(base.Object):
                message.add_header("X-Mailer", "Pakfire Build Service %s" % self.backend.version)
 
                # Add any headers
-               for k, v in headers.items():
+               for k, v in list(headers.items()):
                        message.add_header(k, v)
 
                # Queue the message
@@ -122,7 +122,7 @@ class Messages(base.Object):
                        part = email.message_from_string(part)
 
                        # Extract the headers
-                       for k, v in part.items():
+                       for k, v in list(part.items()):
                                message.add_header(k, v)
 
                        body = part.get_payload()
@@ -173,7 +173,7 @@ class Messages(base.Object):
                p.wait()
 
                if p.returncode:
-                       raise Exception, "Could not send mail: %s" % stderr
+                       raise Exception("Could not send mail: %s" % stderr)
 
                # Mark message as sent
                self.db.execute("UPDATE messages SET sent_at = NOW() WHERE id = %s", message.id)
index e54c8d4432f5dcdcab326db1cfdd328d51196080..374c9eabf875f345815fc282f22a1642603cda21 100644 (file)
@@ -6,7 +6,7 @@ import math
 import socket
 import time
 import tornado.httpclient
-import urlparse
+import urllib.parse
 
 from . import base
 from . import logs
@@ -165,7 +165,7 @@ class Mirror(base.DataObject):
                if path.startswith("/"):
                        path = path[1:]
 
-               return urlparse.urljoin(url, path)
+               return urllib.parse.urljoin(url, path)
 
        def set_supports_https(self, supports_https):
                self._set_attribute("supports_https", supports_https)
index 9610cd73fef932f127825cea04d3b2b495d38790..4a0cf76efa575115bf58499217a4bb29a4ed9f77 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-from __future__ import division
+
 
 import hashlib
 import os
index a191f83be0fe18123540c4894675038121cbcec0..858d750b4a01eb1013507ccd6de88df0c0d4309b 100644 (file)
@@ -108,7 +108,7 @@ class Repository(base.DataObject):
 
                return res.len
 
-       def __nonzero__(self):
+       def __bool__(self):
                return True
 
        @lazy_property
index 51f9989c1e5285144603f6df911a62716d010823..2dacb8abf76ab6f10e068481876bb2d6433453a0 100644 (file)
@@ -219,7 +219,7 @@ class Commit(base.DataObject):
 
                # We will now break the message into paragraphs
                paragraphs = re.split("\n\n+", "\n".join(message))
-               print paragraphs
+               print(paragraphs)
 
                message = []
                for paragraph in paragraphs:
index 24d05ce84e7e8ce3450f8d040ccad5204fcf650a..8ed5e1b1a757cff397542b82bce943921fbf3049 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-from __future__ import division
+
 
 import datetime
 import hashlib
@@ -123,7 +123,7 @@ class Upload(base.DataObject):
                # Check if the filesize was exceeded.
                size = os.path.getsize(self.path) + len(data)
                if size > self.data.size:
-                       raise Exception, "Given filesize was exceeded for upload %s" % self.uuid
+                       raise Exception("Given filesize was exceeded for upload %s" % self.uuid)
 
                logging.debug("Writing %s bytes to %s" % (len(data), self.path))
 
index d8edd01f1e1ce83509d8a99b227b47165358f47f..ad6ab90619e305afbc4a80b0912943392e10e961 100644 (file)
@@ -8,8 +8,8 @@ import pytz
 import random
 import re
 import string
-import urllib
-import ldap
+import urllib.request, urllib.parse, urllib.error
+from . import ldap
 
 import tornado.locale
 
@@ -42,7 +42,7 @@ def generate_password_hash(password, salt=None, algo="sha512"):
        # Compute the hash.
        # <SALT> + <PASSWORD>
        if not algo in hashlib.algorithms:
-               raise Exception, "Unsupported password hash algorithm: %s" % algo
+               raise Exception("Unsupported password hash algorithm: %s" % algo)
 
        # Calculate the digest.
        h = hashlib.new(algo)
@@ -497,7 +497,7 @@ class User(base.DataObject):
 
                # construct the url
                gravatar_url = "http://www.gravatar.com/avatar/%s?" % h.hexdigest()
-               gravatar_url += urllib.urlencode({'d': "mm", 's': str(size)})
+               gravatar_url += urllib.parse.urlencode({'d': "mm", 's': str(size)})
 
                return gravatar_url
 
@@ -583,6 +583,6 @@ if __name__ == "__main__":
        for password in ("1234567890", "abcdefghij"):
                digest = generate_password_hash(password)
 
-               print "%s %s" % (password, digest)
-               print "  Matches? %s" % check_password_hash(password, digest)
+               print("%s %s" % (password, digest))
+               print("  Matches? %s" % check_password_hash(password, digest))
 
index 83aceb674ebdeaee8e585be12302caca26c54609..1ea3e5d60f6b54c2b3d41efb9f3ab294cab7ea02 100644 (file)
@@ -62,7 +62,7 @@ class Cli(object):
                args = tornado.options.parse_command_line(args)
 
                if not len(args) >= 1:
-                       print >>sys.stderr, "Insufficient number of arguments"
+                       print("Insufficient number of arguments", file=sys.stderr)
                        return 2
 
                args = list(args)
@@ -72,7 +72,7 @@ class Cli(object):
                try:
                        command = self._commands[command]
                except KeyError:
-                       print >>sys.stderr, "Command not found: %s" % command
+                       print("Command not found: %s" % command, file=sys.stderr)
                        return 2
 
                # Execute command
@@ -85,13 +85,13 @@ class Cli(object):
                # Get distribution
                distro = self.backend.distros.get_by_name(distro_name)
                if not distro:
-                       print >>sys.stderr, "Could not find distribution: %s" % distro_name
+                       print("Could not find distribution: %s" % distro_name, file=sys.stderr)
                        return 2
 
                # Get repository
                repo = distro.get_repo(repo_name)
                if not repo:
-                       print >>sys.stderr, "Could not find repository: %s" % repo_name
+                       print("Could not find repository: %s" % repo_name, file=sys.stderr)
                        return 2
 
                # Iterate through all of it
@@ -105,7 +105,7 @@ class Cli(object):
                                        continue
 
                                for pkg in job:
-                                       print pkg
+                                       print(pkg)
 
 # main
 
index 77541961f35c534c111a73a8a5cb33fdb0df1a09..631280a291934bf92db07de8d7f0a49fd42eecfd 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-import httplib
+import http.client
 import pytz
 import time
 import tornado.locale
@@ -95,7 +95,7 @@ class BaseHandler(tornado.web.RequestHandler):
                        error_document = "errors/error.html"
 
                try:
-                       status_message = httplib.responses[status_code]
+                       status_message = http.client.responses[status_code]
                except KeyError:
                        status_message = None
 
index 0e8b29a1207bbfd8568ce990f38de685a36b57aa..b1eba13f08aefca4d9882bd50a136452a9bae2ee 100644 (file)
@@ -40,7 +40,7 @@ class BuildDetailHandler(BuildBaseHandler):
                log = build.get_log()
 
                if build.repo:
-                       next_repo = build.repo.next
+                       next_repo = build.repo.__next__
                else:
                        next_repo = None
 
@@ -247,7 +247,7 @@ class BuildManageHandler(base.BaseHandler):
 
                # Get the next repo.
                if build.repo:
-                       next_repo = build.repo.next
+                       next_repo = build.repo.__next__
                else:
                        next_repo = build.distro.first_repo
 
@@ -280,7 +280,7 @@ class BuildManageHandler(base.BaseHandler):
                                raise tornado.web.HTTPError(404, "No such repository: %s" % next_repo)
 
                        if not self.current_user.is_admin():
-                               if not distro.repo.next == next_repo:
+                               if not distro.repo.__next__ == next_repo:
                                        raise tornado.web.HTTPError(403)
 
                        if current_repo:
index 16ceffeb25ffe1d47fa62a8e7c4ced568b750286..358b633b6ba90b7465921eab695a8dabe6dfb0c4 100644 (file)
@@ -62,7 +62,7 @@ class SessionsHandler(base.BaseHandler):
                users = {}
 
                for s in self.backend.sessions:
-                       print s.user, s.user in users
+                       print(s.user, s.user in users)
                        try:
                                users[s.user].append(s)
                        except KeyError:
index 3ed5c355c6b35b425f17029e78e1df5f3ad70768..dd3f4ecf507e91f860033d358bdb129aa6c77262 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/python
 
-from __future__ import division
+
 
 import datetime
 import math
@@ -199,7 +199,7 @@ class BuildTableModule(UIModule):
 
                colspan = 2
 
-               for key in settings.iterkeys():
+               for key in settings.keys():
                        if settings.get(key) == True:
                                colspan = colspan + 1
 
@@ -213,7 +213,7 @@ class BuildTableModule(UIModule):
                        except KeyError:
                                dates[b.date] = [b,]
 
-               dates = sorted(dates.items(), reverse=True)
+               dates = sorted(list(dates.items()), reverse=True)
 
                return self.render_string("modules/build-table.html", dates=dates, **settings)
 
@@ -464,23 +464,23 @@ class WatchersSidebarTableModule(UIModule):
 class SelectLocaleModule(UIModule):
        LOCALE_NAMES = [
                # local code, English name, name
-               ("ca_ES", u"Catalan", "Catal\xc3\xa0"),
-               ("da_DK", u"Danish", u"Dansk"),
-               ("de_DE", u"German", u"Deutsch"),
-               ("en_GB", u"English (UK)", u"English (UK)"),
-               ("en_US", u"English (US)", u"English (US)"),
-               ("es_ES", u"Spanish (Spain)", u"Espa\xf1ol (Espa\xf1a)"),
-               ("es_LA", u"Spanish", u"Espa\xf1ol"),
-               ("fr_CA", u"French (Canada)", u"Fran\xe7ais (Canada)"),
-               ("fr_FR", u"French", u"Fran\xe7ais"),
-               ("it_IT", u"Italian", u"Italiano"),
-               ("km_KH", u"Khmer", u"\u1797\u17b6\u179f\u17b6\u1781\u17d2\u1798\u17c2\u179a"),
-               ("nl_NL", u"Dutch", u"Nederlands"),
-               ("pt_BR", u"Portuguese (Brazil)", u"Portugu\xeas (Brasil)"),
-               ("pt_PT", u"Portuguese (Portugal)", u"Portugu\xeas (Portugal)"),
-               ("ro_RO", u"Romanian", u"Rom\xe2n\u0103"),
-               ("ru_RU", u"Russian", u"\u0440\u0443\u0441\u0441\u043a\u0438\u0439"),
-               ("uk_UA", u"Ukrainian", u"\u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430"),
+               ("ca_ES", "Catalan", "Catal\xc3\xa0"),
+               ("da_DK", "Danish", "Dansk"),
+               ("de_DE", "German", "Deutsch"),
+               ("en_GB", "English (UK)", "English (UK)"),
+               ("en_US", "English (US)", "English (US)"),
+               ("es_ES", "Spanish (Spain)", "Espa\xf1ol (Espa\xf1a)"),
+               ("es_LA", "Spanish", "Espa\xf1ol"),
+               ("fr_CA", "French (Canada)", "Fran\xe7ais (Canada)"),
+               ("fr_FR", "French", "Fran\xe7ais"),
+               ("it_IT", "Italian", "Italiano"),
+               ("km_KH", "Khmer", "\u1797\u17b6\u179f\u17b6\u1781\u17d2\u1798\u17c2\u179a"),
+               ("nl_NL", "Dutch", "Nederlands"),
+               ("pt_BR", "Portuguese (Brazil)", "Portugu\xeas (Brasil)"),
+               ("pt_PT", "Portuguese (Portugal)", "Portugu\xeas (Portugal)"),
+               ("ro_RO", "Romanian", "Rom\xe2n\u0103"),
+               ("ru_RU", "Russian", "\u0440\u0443\u0441\u0441\u043a\u0438\u0439"),
+               ("uk_UA", "Ukrainian", "\u0423\u043a\u0440\u0430\u0457\u043d\u0441\u044c\u043a\u0430"),
        ]
 
        # Sort the list of locales by their English name.