Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use 2to3 to update to Python3 #103

Merged
merged 41 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
096414b
Use 2to3 to update to Python3
lrineau Jan 2, 2020
495936f
Refresh one more script
lrineau Feb 21, 2020
f3c5040
Merge branch 'master' into python3
lrineau May 15, 2020
4c8e507
Add coreutils, for the `timeout` utility
lrineau May 20, 2020
da974e4
Merge branch 'master' into python3
lrineau May 20, 2020
0b6cf59
Merge branch 'master' into python3
lrineau Jun 23, 2020
7d2aa1c
Merge branch 'master' into python3
lrineau Jun 26, 2020
f62192d
Merge branch 'master' into python3
lrineau Aug 27, 2020
c6f81a2
Merge branch 'master' into python3
lrineau Aug 27, 2020
d3f712b
Merge remote-tracking branch 'origin/master' into python3
lrineau Aug 31, 2020
0a72d18
Merge remote-tracking branch 'origin/master' into python3
lrineau Dec 3, 2020
4039d07
Merge branch 'master' into python3
lrineau Mar 9, 2021
b093d19
Merge branch 'master' into python3
lrineau Mar 16, 2021
edf1bad
Merge branch 'master' into python3
lrineau Mar 29, 2021
9e4ef99
Merge branch 'master' into python3
lrineau Mar 29, 2021
146fad6
Merge branch 'master' into python3
lrineau Aug 4, 2021
85fd5a4
Merge remote-tracking branch 'origin/master' into python3
lrineau Sep 17, 2021
f4e4e96
Merge branch 'master' into python3
lrineau Sep 17, 2021
b7303ef
Merge branch 'master' into python3
lrineau Nov 8, 2021
2bf18c0
Merge remote-tracking branch 'origin/master' into python3
lrineau Apr 28, 2022
b687197
Merge remote-tracking branch 'origin/master' into python3
lrineau Apr 29, 2022
96fcee6
Merge branch 'master' into python3
lrineau May 3, 2022
1f04f02
Merge branch 'master' into python3
lrineau Jun 7, 2022
23a0fea
Install libasan
lrineau Jun 21, 2022
726738c
Merge branch 'master' into python3
lrineau Jun 21, 2022
5d64a97
Merge branch 'master' into python3
lrineau Jun 22, 2022
5f924ed
Merge remote-tracking branch 'origin/master' into python3
lrineau Jun 22, 2023
78f7943
Merge branch 'master' into python3
lrineau Jun 23, 2023
5614b39
Merge branch 'master' into python3
lrineau Jul 19, 2023
f873936
Merge branch 'master' into python3
lrineau Jul 19, 2023
5a45e14
Merge branch 'master' into python3
lrineau Sep 18, 2023
93b3977
Merge branch 'master' into python3
lrineau Sep 18, 2023
2a10401
allow back the possibility to run from a branch
lrineau Sep 19, 2023
68f7ce0
Merge branch 'master' into python3
lrineau Sep 19, 2023
f7d83ac
Merge branch 'master' into python3
lrineau Sep 20, 2023
66c50fc
Merge branch 'master' into python3
lrineau Sep 20, 2023
2269b8e
Merge branch 'master' into python3
lrineau Oct 12, 2023
48ef5c0
Merge remote-tracking branch 'origin/master' into python3
lrineau Jan 3, 2024
fbcfe30
Merge branch 'master' into python3
lrineau Jan 18, 2024
563d9ac
Merge branch 'master' into python3
lrineau Jun 10, 2024
54ee7ec
python3 !
lrineau Aug 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ def main():
fullnames = (os.path.join(os.getcwd(), name) for name in os.listdir(os.getcwd()))
args.dirs = [name for name in fullnames if os.path.isfile(os.path.join(name, 'Dockerfile'))]

print args.dirs
print(args.dirs)

for d in args.dirs:
tag = 'cgal-testsuite/' + os.path.basename(d).lower()
print 'Building directory {} with tag {}'.format(d, tag)
print('Building directory {} with tag {}'.format(d, tag))
response = client.build(path=d, rm=True, tag=tag, stream=False)
for l in response:
print l
print(l)

if __name__ == "__main__":
main()
20 changes: 10 additions & 10 deletions cgal_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import docker
import re
import StringIO
import io

class TestsuiteException(Exception):
pass
Expand All @@ -24,7 +24,7 @@ def __str__(self):
def container_by_id(docker_client, Id):
"""Returns a container given an `Id`. Raises `TestsuiteError` if the
`Id` cannot be found."""
contlist = [cont for cont in docker_client.containers(all=True) if Id == cont[u'Id']]
contlist = [cont for cont in docker_client.containers(all=True) if Id == cont['Id']]
if len(contlist) != 1:
raise TestsuiteError('Requested Container Id ' + Id + 'does not exist')
return contlist[0]
Expand All @@ -45,7 +45,7 @@ def images(docker_client, release, images):
def _default_images(docker_client):
images = []
for img in docker_client.images():
tag = next((x for x in img[u'RepoTags'] if x.startswith(u'cgal-testsuite/')), None)
tag = next((x for x in img['RepoTags'] if x.startswith('cgal-testsuite/')), None)
if tag:
images.append(tag)
return images
Expand Down Expand Up @@ -117,7 +117,7 @@ def run(self, image, cpuset):
container_id = self._create_container(image, cpuset)
cont = container_by_id(self.docker_client, container_id)
logging.info('Created container: {0} with id {1[Id]} from image {1[Image]} on cpus {2}'
.format(', '.join(cont[u'Names']), cont, cpuset))
.format(', '.join(cont['Names']), cont, cpuset))
self.docker_client.start(container_id)
return container_id

Expand All @@ -132,10 +132,10 @@ def _create_container(self, img, cpuset):
else:
chosen_name = 'CGAL-{}-testsuite'.format(res.group(2))

existing = [cont for cont in self.docker_client.containers(all=True) if '/' + chosen_name in cont[u'Names']]
existing = [cont for cont in self.docker_client.containers(all=True) if '/' + chosen_name in cont['Names']]
assert len(existing) == 0 or len(existing) == 1, 'Length of existing containers is odd'

if len(existing) != 0 and u'Exited' in existing[0][u'Status']:
if len(existing) != 0 and 'Exited' in existing[0]['Status']:
logging.info('An Exited container with name {} already exists. Removing.'.format(chosen_name))
self.docker_client.remove_container(container=chosen_name)
elif len(existing) != 0 and self.force_rm:
Expand All @@ -160,10 +160,10 @@ def _create_container(self, img, cpuset):
mac_address=self.mac_address
)

if container[u'Warnings']:
logging.warning('Container of image {} got created with warnings: {}'.format(img, container[u'Warnings']))
if container['Warnings']:
logging.warning('Container of image {} got created with warnings: {}'.format(img, container['Warnings']))

return container[u'Id']
return container['Id']

class ContainerScheduler:
def __init__(self, runner, images, cpusets):
Expand All @@ -173,7 +173,7 @@ def __init__(self, runner, images, cpusets):
self.running_containers = {}
# error handling
self.errors_encountered = False
self.error_buffer=StringIO.StringIO()
self.error_buffer=io.StringIO()
self.error_handler=logging.StreamHandler(self.error_buffer)
self.error_handler.setFormatter( logging.Formatter('%(levelname)s: %(message)s') )
self.error_logger = logging.getLogger("Error_logger")
Expand Down
18 changes: 9 additions & 9 deletions cgal_release.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import urllib2
import urllib.request, urllib.error, urllib.parse
import os
import tarfile
import shutil
Expand All @@ -16,11 +16,11 @@ class Release:
def __init__(self, testsuite, use_local, user, passwd):
if not use_local and user and passwd:
logging.info('Setting up user and password for download.')
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
password_mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
password_mgr.add_password(None, Release._release_url, user, passwd)
handler = urllib2.HTTPBasicAuthHandler(password_mgr)
opener = urllib2.build_opener(handler)
urllib2.install_opener(opener)
handler = urllib.request.HTTPBasicAuthHandler(password_mgr)
opener = urllib.request.build_opener(handler)
urllib.request.install_opener(opener)

if use_local:
logging.info('Using local CGAL release at {}'.format(testsuite))
Expand All @@ -35,7 +35,7 @@ def __init__(self, testsuite, use_local, user, passwd):
self.path = Release._extract_release(path_to_tar)
logging.info('Removing {}'.format(path_to_tar))
os.remove(path_to_tar)
except urllib2.URLError as e:
except urllib.error.URLError as e:
if hasattr(e, 'code') and e.code == 401:
logging.warning('URLError 401: Did you forget to provide --user and --passwd?')
raise
Expand All @@ -49,8 +49,8 @@ def __str__(self):

@staticmethod
def _get_latest():
response = urllib2.urlopen(Release._latest_url)
return response.read().strip()
response = urllib.request.urlopen(Release._latest_url)
return response.read().strip().decode(encoding='UTF-8')

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line I modified myself, after the run of 2to3.

@staticmethod
def _get_cgal(latest, testsuite):
Expand All @@ -62,7 +62,7 @@ def _get_cgal(latest, testsuite):
logging.warning('Path {} already exists, reusing it.'.format(download_to))
return download_to

response = urllib2.urlopen(download_from)
response = urllib.request.urlopen(download_from)
with open(download_to, "wb") as local_file:
local_file.write(response.read())
return download_to
Expand Down
14 changes: 7 additions & 7 deletions resubmit-results.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@
parser = cgal_docker_args.parser()
args = parser.parse_args()

client=docker.Client(base_url=args.docker_url)
client=docker.APIClient(base_url=args.docker_url)

if not args.images:
args.images = []
for i in client.images(name='docker.io/cgal/testsuite-docker'):
args.images.append(i['RepoTags'][0])

print 'Using images {}'.format(', '.join(args.images))
print(('Using images {}'.format(', '.join(args.images))))
release = cgal_release.Release(args.testsuite, args.use_local, args.user, args.passwd)
print 'Using release ' + release.version
print(('Using release ' + release.version))

for c in client.containers(filters={ 'status': 'exited' }):
if not c[u'Image'] in args.images:
if not c['Image'] in args.images:
continue
id = c[u'Id']
id = c['Id']
platform = platform_from_container(client, id)
print 'Resubmit results for platform ' + platform
print(('Resubmit results for platform ' + platform))
try:
handle_results(client, id, args.upload_results, args.testresults,
release, args.tester)
except TestsuiteError as e:
print ' ERROR: ' + str(e)
print((' ERROR: ' + str(e)))
20 changes: 10 additions & 10 deletions test_cgal.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python3
# Copyright (c) 2015 GeometryFactory (France). All rights reserved.
# All rights reserved.
#
Expand All @@ -15,7 +15,7 @@
#
# Author(s) : Philipp Moeller

from __future__ import division


import logging
from cgal_docker import *
Expand Down Expand Up @@ -87,7 +87,7 @@ def upload_results(local_path):

def platform_from_container(client, cont_id):
platform_regex = re.compile('^CGAL_TEST_PLATFORM=(.*)$')
for e in client.inspect_container(container=cont_id)[u'Config'][u'Env']:
for e in client.inspect_container(container=cont_id)['Config']['Env']:
res = platform_regex.search(e)
if res:
return res.group(1)
Expand Down Expand Up @@ -178,7 +178,7 @@ def main():
existing = [cont for cont in client.containers(filters = { 'status' : 'running'})]
generic_name_regex = re.compile('CGAL-.+-testsuite')
for cont in existing:
for name in cont[u'Names']:
for name in cont['Names']:
if generic_name_regex.match(name):
info.error('Testsuite Container {} of previous suite still running. Aborting. NOTE: This could also be a name clash.')
sys.exit(0)
Expand Down Expand Up @@ -243,15 +243,15 @@ def main():
try:
for ev in client.events(since=before_start, decode=True):
assert isinstance(ev, dict)
if ev[u'Type'] != u'container':
if ev['Type'] != 'container':
continue;
event_id = ev[u'id']
event_id = ev['id']

if scheduler.is_ours(event_id): # we care
if ev[u'status'] == u'die':
if ev[u'Actor'][u'Attributes'][u'exitCode']!='0':
if ev['status'] == 'die':
if ev['Actor']['Attributes']['exitCode']!='0':
logging.warning('Could not parse exit status: {}. Assuming dirty death of the container.'
.format(ev[u'Actor'][u'Attributes'][u'exitCode']))
.format(ev['Actor']['Attributes']['exitCode']))
else:
logging.info('Container died cleanly, handling results.')
try:
Expand Down Expand Up @@ -280,7 +280,7 @@ def main():
remove_pidfile()

if scheduler.errors_encountered:
print (scheduler.error_buffer.getvalue())
print((scheduler.error_buffer.getvalue()))
exit(33)

if __name__ == "__main__":
Expand Down
Loading