summaryrefslogtreecommitdiff
path: root/lorrycontroller
diff options
context:
space:
mode:
authorPedro Alvarez <pedro.alvarez@codethink.co.uk>2019-11-26 14:29:03 +0000
committerPedro Alvarez <pedro.alvarez@codethink.co.uk>2019-11-27 15:06:12 +0000
commit95505797df503a086a311cab9aecbd2318522407 (patch)
tree1e3cf32a50ac10e9c95d59db883069051683f49e /lorrycontroller
parent2d54f8036d1f58df9690849f5b82134927561d1e (diff)
downloadlorry-controller-95505797df503a086a311cab9aecbd2318522407.tar.gz
Update to python3
Diffstat (limited to 'lorrycontroller')
-rw-r--r--lorrycontroller/__init__.py50
-rw-r--r--lorrycontroller/gitano.py10
-rw-r--r--lorrycontroller/gitlab.py12
-rw-r--r--lorrycontroller/lstroves.py4
-rw-r--r--lorrycontroller/proxy.py6
-rw-r--r--lorrycontroller/readconf.py4
-rw-r--r--lorrycontroller/showlorry.py10
-rw-r--r--lorrycontroller/status.py6
8 files changed, 51 insertions, 51 deletions
diff --git a/lorrycontroller/__init__.py b/lorrycontroller/__init__.py
index 72696fa..c5bf0ad 100644
--- a/lorrycontroller/__init__.py
+++ b/lorrycontroller/__init__.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2016 Codethink Limited
+# Copyright (C) 2014-2019 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -14,38 +14,38 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-from statedb import (
+from .statedb import (
StateDB,
LorryNotFoundError,
WrongNumberLorriesRunningJob,
TroveNotFoundError)
-from route import LorryControllerRoute
-from readconf import ReadConfiguration
-from status import Status, StatusHTML, StatusRenderer
-from listqueue import ListQueue
-from showlorry import ShowLorry, ShowLorryHTML
-from startstopqueue import StartQueue, StopQueue
-from givemejob import GiveMeJob
-from jobupdate import JobUpdate
-from listrunningjobs import ListRunningJobs
-from movetopbottom import MoveToTop, MoveToBottom
-from stopjob import StopJob
-from listjobs import ListAllJobs, ListAllJobsHTML
-from showjob import ShowJob, ShowJobHTML, JobShower
-from removeghostjobs import RemoveGhostJobs
-from removejob import RemoveJob
-from lstroves import LsTroves, ForceLsTrove
-from pretendtime import PretendTime
-from maxjobs import GetMaxJobs, SetMaxJobs
-from gitano import (
+from .route import LorryControllerRoute
+from .readconf import ReadConfiguration
+from .status import Status, StatusHTML, StatusRenderer
+from .listqueue import ListQueue
+from .showlorry import ShowLorry, ShowLorryHTML
+from .startstopqueue import StartQueue, StopQueue
+from .givemejob import GiveMeJob
+from .jobupdate import JobUpdate
+from .listrunningjobs import ListRunningJobs
+from .movetopbottom import MoveToTop, MoveToBottom
+from .stopjob import StopJob
+from .listjobs import ListAllJobs, ListAllJobsHTML
+from .showjob import ShowJob, ShowJobHTML, JobShower
+from .removeghostjobs import RemoveGhostJobs
+from .removejob import RemoveJob
+from .lstroves import LsTroves, ForceLsTrove
+from .pretendtime import PretendTime
+from .maxjobs import GetMaxJobs, SetMaxJobs
+from .gitano import (
GitanoCommand,
LocalTroveGitanoCommand,
GitanoCommandFailure,
new_gitano_command)
-from static import StaticFile
-from proxy import setup_proxy
-from gerrit import Gerrit
-from gitlab import Gitlab
+from .static import StaticFile
+from .proxy import setup_proxy
+from .gerrit import Gerrit
+from .gitlab import Gitlab
__all__ = locals()
diff --git a/lorrycontroller/gitano.py b/lorrycontroller/gitano.py
index c0cca05..d0d1a0c 100644
--- a/lorrycontroller/gitano.py
+++ b/lorrycontroller/gitano.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2014 Codethink Limited
+# Copyright (C) 2014-2019 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -17,8 +17,8 @@
import collections
import logging
import re
-import urllib2
-import urlparse
+import urllib.request, urllib.error, urllib.parse
+import urllib.parse
import cliapp
import requests
@@ -104,8 +104,8 @@ class GitanoCommand(object):
return stdout
def _http_command(self, gitano_args):
- quoted_args = urllib2.quote(' '.join(gitano_args))
- url = urlparse.urlunsplit((
+ quoted_args = urllib.parse.quote(' '.join(gitano_args))
+ url = urllib.parse.urlunsplit((
self.protocol,
self.trovehost,
'/gitano-command.cgi',
diff --git a/lorrycontroller/gitlab.py b/lorrycontroller/gitlab.py
index a426b0d..6938cae 100644
--- a/lorrycontroller/gitlab.py
+++ b/lorrycontroller/gitlab.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2016 Codethink Limited
+# Copyright (C) 2016-2019 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -13,9 +13,9 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-from __future__ import absolute_import
+
import re
-import urlparse
+import urllib.parse
import itertools
try:
import gitlab
@@ -46,7 +46,7 @@ class Gitlab(object):
'\tpython-gitlab is required with GitLab as the git server')
def first(self, predicate, iterable):
- return next(itertools.ifilter(predicate, iterable))
+ return next(filter(predicate, iterable))
def split_and_unslashify_path(self, path):
group, project = path.split('/', 1)
@@ -137,6 +137,6 @@ class Gitlab(object):
if protocol == 'ssh':
return project.ssh_url_to_repo
elif protocol in ('http', 'https'):
- split = urlparse.urlsplit(project.http_url_to_repo)
- return urlparse.urlunsplit((
+ split = urllib.parse.urlsplit(project.http_url_to_repo)
+ return urllib.parse.urlunsplit((
protocol, split.netloc, split.path, '', ''))
diff --git a/lorrycontroller/lstroves.py b/lorrycontroller/lstroves.py
index 456359c..34648cb 100644
--- a/lorrycontroller/lstroves.py
+++ b/lorrycontroller/lstroves.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2016 Codethink Limited
+# Copyright (C) 2014-2019 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -126,7 +126,7 @@ class TroveRepositoryLister(object):
def update_lorries_for_trove(self, statedb, trove_info, repo_map):
trovehost = trove_info['trovehost']
- for remote_path, local_path in repo_map.items():
+ for remote_path, local_path in list(repo_map.items()):
lorry = self.construct_lorry(trove_info, local_path, remote_path)
statedb.add_to_lorries(
path=local_path,
diff --git a/lorrycontroller/proxy.py b/lorrycontroller/proxy.py
index b9e75b8..5eea4f1 100644
--- a/lorrycontroller/proxy.py
+++ b/lorrycontroller/proxy.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2014 Codethink Limited
+# Copyright (C) 2014-2019 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -16,13 +16,13 @@
import json
import os
-import urllib
+import urllib.request, urllib.parse, urllib.error
def build_proxy_url(protocol, proxy_config):
"""Build a proxy URL from data in our proxy configuration format."""
- hostname = urllib.quote(proxy_config['hostname'])
+ hostname = urllib.parse.quote(proxy_config['hostname'])
url = '%s:%s' % (hostname, proxy_config['port'])
if 'username' not in proxy_config:
diff --git a/lorrycontroller/readconf.py b/lorrycontroller/readconf.py
index 162e116..a8949c1 100644
--- a/lorrycontroller/readconf.py
+++ b/lorrycontroller/readconf.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2016 Codethink Limited
+# Copyright (C) 2014-2019 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -394,7 +394,7 @@ class LorryControllerConfValidator(object):
def _check_is_list_of_strings(self, section, field):
obj = section[field]
if not isinstance(obj, list) or not all(
- isinstance(s, basestring) for s in obj):
+ isinstance(s, str) for s in obj):
raise ValidationError(
'%s field in %r must be a list of strings' %
(field, section))
diff --git a/lorrycontroller/showlorry.py b/lorrycontroller/showlorry.py
index d54073a..b553b9c 100644
--- a/lorrycontroller/showlorry.py
+++ b/lorrycontroller/showlorry.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2014 Codethink Limited
+# Copyright (C) 2014-2019 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
import json
import logging
import time
-import urlparse
+import urllib.parse
import bottle
@@ -65,7 +65,7 @@ class ShowLorryHTML(ShowLorryBase, lorrycontroller.LorryControllerRoute):
renderer = lorrycontroller.StatusRenderer()
shower = lorrycontroller.JobShower()
- lorry_obj = json.loads(lorry_info['text']).values()[0]
+ lorry_obj = list(json.loads(lorry_info['text']).values())[0]
lorry_info['url'] = lorry_obj['url']
lorry_info['interval_nice'] = renderer.format_secs_nicely(
@@ -85,9 +85,9 @@ class ShowLorryHTML(ShowLorryBase, lorrycontroller.LorryControllerRoute):
timestamp = time.strftime('%Y-%m-%d %H:%M:%S UTC', time.gmtime(now))
- parts = urlparse.urlparse(bottle.request.url)
+ parts = urllib.parse.urlparse(bottle.request.url)
host, port = parts.netloc.split(':', 1)
- http_server_root = urlparse.urlunparse(
+ http_server_root = urllib.parse.urlunparse(
(parts.scheme, host, '', '', '', ''))
return bottle.template(
diff --git a/lorrycontroller/status.py b/lorrycontroller/status.py
index 9d65c4e..2e6334d 100644
--- a/lorrycontroller/status.py
+++ b/lorrycontroller/status.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2017 Codethink Limited
+# Copyright (C) 2014-2019 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -61,7 +61,7 @@ class StatusRenderer(object):
try:
temp_filename = self.temp_filename_in_same_dir_as(filename)
- with open(temp_filename, 'w') as f:
+ with open(temp_filename, 'wb') as f:
f.write(html.encode("UTF-8"))
os.rename(temp_filename, filename)
@@ -85,7 +85,7 @@ class StatusRenderer(object):
def temp_filename_in_same_dir_as(self, filename):
dirname = os.path.dirname(filename)
fd, temp_filename = tempfile.mkstemp(dir=dirname)
- os.fchmod(fd, 0644)
+ os.fchmod(fd, 0o644)
os.close(fd)
return temp_filename