#!/usr/bin/python
-from __future__ import absolute_import
-import ConfigParser
+
+import configparser
import logging
import os
import pakfire
return env
def read_config(self, path):
- c = ConfigParser.SafeConfigParser()
+ c = configparser.SafeConfigParser()
# Import configuration from environment
for section in self._environment_configuration:
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))
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:
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
#!/usr/bin/python
-import xmlrpclib
+import xmlrpc.client
from . import base
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 = {
try:
bug = BugzillaBug(self, bug_id)
- except xmlrpclib.Fault:
+ except xmlrpc.client.Fault:
return None
return bug
return
elif len(users) > 1:
- raise Exception, "Got more than one result."
+ raise Exception("Got more than one result.")
return users[0]
# 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)
#!/usr/bin/python
-from __future__ import absolute_import, division
+
import datetime
import hashlib
# 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":
(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)
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.
as torndb.
"""
-from __future__ import absolute_import, division, with_statement
+
import itertools
import logging
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()
return iter(packages)
- def __nonzero__(self):
+ def __bool__(self):
return True
def __len__(self):
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
#!/usr/bin/python
-from __future__ import absolute_import
+
import ldap
import logging
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
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()
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)
import socket
import time
import tornado.httpclient
-import urlparse
+import urllib.parse
from . import base
from . import logs
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)
#!/usr/bin/python
-from __future__ import division
+
import hashlib
import os
return res.len
- def __nonzero__(self):
+ def __bool__(self):
return True
@lazy_property
# 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:
#!/usr/bin/python
-from __future__ import division
+
import datetime
import hashlib
# 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))
import random
import re
import string
-import urllib
-import ldap
+import urllib.request, urllib.parse, urllib.error
+from . import ldap
import tornado.locale
# 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)
# 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
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))
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)
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
# 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
continue
for pkg in job:
- print pkg
+ print(pkg)
# main
#!/usr/bin/python
-import httplib
+import http.client
import pytz
import time
import tornado.locale
error_document = "errors/error.html"
try:
- status_message = httplib.responses[status_code]
+ status_message = http.client.responses[status_code]
except KeyError:
status_message = None
log = build.get_log()
if build.repo:
- next_repo = build.repo.next
+ next_repo = build.repo.__next__
else:
next_repo = None
# Get the next repo.
if build.repo:
- next_repo = build.repo.next
+ next_repo = build.repo.__next__
else:
next_repo = build.distro.first_repo
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:
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:
#!/usr/bin/python
-from __future__ import division
+
import datetime
import math
colspan = 2
- for key in settings.iterkeys():
+ for key in settings.keys():
if settings.get(key) == True:
colspan = colspan + 1
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)
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.