Skip to content

Commit b0506b2

Browse files
banasiakadam60Elfoniok
authored andcommitted
Switch to Python 3 (golemfactory#1128)
* wqRemove OpenEXR Signed-off-by: Adam Banasiak <[email protected]> * Update CI to Python 3.6 Signed-off-by: Adam Banasiak <[email protected]> * 2to3 applied Signed-off-by: Lukasz Foniok <[email protected]> * Adding dependencies from devp2p.crypto Signed-off-by: Lukasz Foniok <[email protected]> * 2to3 on latest commits Signed-off-by: Lukasz Foniok <[email protected]> * Removing class advice, adds decorator Signed-off-by: Lukasz Foniok <[email protected]> * Changin keys.privtoaddr to privttoaddr Signed-off-by: Lukasz Foniok <[email protected]> * Forking pystun, fix keys encoding Signed-off-by: Lukasz Foniok <[email protected]> * Fixes for encode/decode strings Signed-off-by: Lukasz Foniok <[email protected]> * Fix ui generation and pystun imports Signed-off-by: Lukasz Foniok <[email protected]> * Fix for DataBuffer Signed-off-by: Lukasz Foniok <[email protected]> * DataBuffer, use bytes instead of bytes strings Signed-off-by: Lukasz Foniok <[email protected]> * Fix window_resize method Signed-off-by: Lukasz Foniok <[email protected]> * Fix docker scripts are python2 compatible Signed-off-by: Lukasz Foniok <[email protected]> * Flooring bucket midpoint Signed-off-by: Lukasz Foniok <[email protected]> * Fix etherum address format Signed-off-by: Lukasz Foniok <[email protected]> * Runnable tests * Runnable tests, continued * circle.yml * circle.yml, continued * UI files generation * Test imports * Requirements * Fix test_startapp Signed-off-by: Lukasz Foniok <[email protected]> * Correct SHA3 function * Correct SHA3 function (old behaviour) * Minor fixes and tests * keysauth * Batch of micro fixes + tests * Fix tests imports Signed-off-by: Lukasz Foniok <[email protected]> * Ethereum * CircleCI: Python 3.5 * Ethereum, continued * Fix for blender task exr/sgi read/write Signed-off-by: Lukasz Foniok <[email protected]> * CLI * Monitor * Docker manager * Core + misc * Client * Network * Lux docker task fix * Resources * RPC * Ethereum * Task * Resources * GUI * Apps * PaymentProcessor quickfix * Circle CI * Convert MSE to int in calculate_mse tests * Dummy task * Change seed option is not crashing Signed-off-by: Lukasz Foniok <[email protected]> * Unified encode_hex and decode_hex; explicit '0x' prefixing * Travis CI * Appveyor CI * Enable remote debugging (Appveyor) * Taskcollector Temp dir fixture fix (Windows specific) An attempt on fixing dummy task tests (Windows specific) * Configure txaio in config_logging (first/only use of txaio in tests) * Docker tests (Windows specific) * Core tests (Windows specific) * Remove datadir on node shutdown in DummyTask test * Remove datadir on node shutdown in DummyTask test, continued * Cleanup 2to3 print statements * Cleanup 2to3 'for' loops * Docker image build fix * macOS tests * python3 syntax in spec file Signed-off-by: Lukasz Foniok <[email protected]> * Fix --peer option Signed-off-by: Lukasz Foniok <[email protected]> * enum34 dependency removed * Handle HTTPS redirects in stats.golem.network * Python 3: extra python package repository (golemfactory#1237) * Python 3 Windows requirements (golemfactory#1239)
1 parent cfcfa03 commit b0506b2

File tree

295 files changed

+2890
-2763
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

295 files changed

+2890
-2763
lines changed

.travis.yml

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
language: generic
22

3-
43
os: osx
54
osx_image: xcode8.3 # OS X 10.12
65

@@ -18,7 +17,7 @@ cache:
1817
- $HOME/Library/Caches/pip
1918

2019
before_install:
21-
- brew install [email protected] openexr freeimage
20+
- brew install python3 qt5 openexr freeimage
2221

2322
- wget https://gethstore.blob.core.windows.net/builds/${GETH_VER}.tar.gz
2423
- tar xvf ${GETH_VER}.tar.gz
@@ -28,15 +27,13 @@ before_install:
2827
- cd golem-hyperdrive && npm install --save && cd ..
2928
- node golem-hyperdrive/src/index.js &
3029

31-
- sudo -HE pip install --upgrade pip setuptools six virtualenv pytest-cov codecov
32-
- pip install https://github.com/golemfactory/golem/wiki/wheels/sip-4.19-cp27-cp27m-macosx_10_12_x86_64.whl
33-
- pip install https://github.com/golemfactory/golem/wiki/wheels/PyQt5-5.7.1-cp27-cp27m-macosx_10_12_x86_64.whl
34-
- sudo -HE pip install -r requirements.txt
35-
- sudo -HE pip install -r requirements-test.txt
36-
- sudo -HE python setup.py develop
30+
- sudo -HE pip3 install --upgrade pip setuptools six virtualenv pytest-cov codecov
31+
- sudo -HE pip3 install -r requirements.txt
32+
- sudo -HE pip3 install -r requirements-test.txt
33+
- sudo -HE python3 setup.py develop
3734

3835
script:
39-
- pytest --cov=golem
36+
- python3 -m pytest --cov=golem
4037

4138
after_success:
42-
- codecov
39+
- python3 -m codecov

apps/appsmanager.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
from __future__ import absolute_import
2-
31
import os
4-
from ConfigParser import ConfigParser
2+
from configparser import ConfigParser
53
from collections import OrderedDict
64
from importlib import import_module
75

apps/blender/benchmark/benchmark.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __init__(self):
2525
task_def.output_format = "png"
2626
task_def.options = BlenderRendererOptions()
2727
task_def.options.frames = "1"
28-
task_def.task_id = u"blender_benchmark"
28+
task_def.task_id = "blender_benchmark"
2929
main_scene_file = pathlib.Path(self.blender_task_path)
3030
main_scene_file /= "bmw27_cpu.blend"
3131
task_def.main_scene_file = str(main_scene_file)

apps/blender/resources/blenderloganalyser.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ def make_log_analyses(log_content, return_data):
88
_get_warnings(log_content, return_data)
99
rendering_time = find_rendering_time(log_content)
1010
if rendering_time:
11-
return_data[u"rendering_time"] = to_unicode(rendering_time)
11+
return_data["rendering_time"] = to_unicode(rendering_time)
1212
output_path = find_filepath(log_content)
1313
if output_path:
14-
return_data[u"output_path"] = to_unicode(output_path)
14+
return_data["output_path"] = to_unicode(output_path)
1515
frames = find_frames(log_content)
1616
# FIXME Convert to nice string and to unicode
1717
if frames:
18-
return_data[u"frames"] = frames
18+
return_data["frames"] = frames
1919
resolution = find_resolution(log_content)
2020
if resolution:
21-
return_data[u"resolution"] = resolution
21+
return_data["resolution"] = resolution
2222
file_format = find_file_format(log_content)
2323
if file_format:
24-
return_data[u"file_format"] = to_unicode(file_format)
24+
return_data["file_format"] = to_unicode(file_format)
2525

2626

2727
def _get_warnings(log_content, return_data):
@@ -33,13 +33,13 @@ def _get_warnings(log_content, return_data):
3333

3434
wrong_engine = find_wrong_renderer_warning(log_content)
3535
if wrong_engine:
36-
warnings.append(u"\n{}\n".format(wrong_engine))
36+
warnings.append("\n{}\n".format(wrong_engine))
3737

3838
if warnings:
39-
if return_data.get(u"warnings"):
40-
return_data[u"warnings"] += u"".join(warnings)
39+
if return_data.get("warnings"):
40+
return_data["warnings"] += "".join(warnings)
4141
else:
42-
return_data[u"warnings"] = u"".join(warnings)
42+
return_data["warnings"] = "".join(warnings)
4343

4444

4545
def find_wrong_renderer_warning(log_content):
@@ -62,10 +62,10 @@ def find_missing_files(log_content):
6262

6363

6464
def _format_missing_files_warning(missing_files):
65-
missing_files = [u" {}\n".format(missing_file)
65+
missing_files = [" {}\n".format(missing_file)
6666
for missing_file in missing_files]
67-
ret = u"Additional data is missing:\n" + u"".join(missing_files)
68-
ret += u"\nTry to add missing files to resources before " \
67+
ret = "Additional data is missing:\n" + "".join(missing_files)
68+
ret += "\nTry to add missing files to resources before " \
6969
"you start rendering."
7070
return ret
7171

@@ -99,7 +99,7 @@ def find_frames(log_content):
9999
start_frame = int(frames.group(1))
100100
end_frame = int(frames.group(2))
101101
frame_step = int(frames.group(3))
102-
return range(start_frame, end_frame + 1, frame_step)
102+
return list(range(start_frame, end_frame + 1, frame_step))
103103

104104

105105
def find_file_format(log_content):

apps/blender/task/blenderrendertask.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from __future__ import division
1+
22
import logging
33
import math
44
import os
55
import random
66
from collections import OrderedDict
7-
from itertools import ifilter
7+
88

99
import time
1010
from PIL import Image, ImageChops
@@ -229,10 +229,10 @@ def __get_border(cls, start, end, parts, res_x, res_y):
229229

230230
upper = offsets[start]
231231
lower = offsets[end + 1]
232-
for i in xrange(upper, lower):
232+
for i in range(upper, lower):
233233
border.append((0, i))
234234
border.append((x, i))
235-
for i in xrange(0, x):
235+
for i in range(0, x):
236236
border.append((i, upper))
237237
border.append((i, lower))
238238
return border
@@ -544,7 +544,7 @@ def _update_frame_preview(self, new_chunk_file_path, frame_num, part=1,
544544
self._update_frame_task_preview()
545545

546546
def _put_image_together(self):
547-
output_file_name = u"{}".format(self.output_file, self.output_format)
547+
output_file_name = "{}".format(self.output_file, self.output_format)
548548
logger.debug('_put_image_together() out: %r', output_file_name)
549549
self.collected_file_names = OrderedDict(sorted(self.collected_file_names.items()))
550550
if not self._use_outer_task_collector():
@@ -554,7 +554,7 @@ def _put_image_together(self):
554554
collector.finalize().save(output_file_name, self.output_format)
555555
else:
556556
self._put_collected_files_together(os.path.join(self.tmp_dir, output_file_name),
557-
self.collected_file_names.values(), "paste")
557+
list(self.collected_file_names.values()), "paste")
558558

559559
def mark_part_on_preview(self, part, img_task, color, preview_updater, frame_index=0):
560560
lower = preview_updater.get_offset(part)
@@ -580,7 +580,7 @@ def _mark_task_area(self, subtask, img_task, color, frame_index=0):
580580
def _put_frame_together(self, frame_num, num_start):
581581
directory = os.path.dirname(self.output_file)
582582
output_file_name = os.path.join(directory, self._get_output_name(frame_num))
583-
frame_key = unicode(frame_num)
583+
frame_key = str(frame_num)
584584
collected = self.frames_given[frame_key]
585585
collected = OrderedDict(sorted(collected.items()))
586586
if not self._use_outer_task_collector():
@@ -589,7 +589,7 @@ def _put_frame_together(self, frame_num, num_start):
589589
collector.add_img_file(file)
590590
collector.finalize().save(output_file_name, self.output_format)
591591
else:
592-
self._put_collected_files_together(output_file_name, collected.values(), "paste")
592+
self._put_collected_files_together(output_file_name, list(collected.values()), "paste")
593593
self.collected_file_names[frame_num] = output_file_name
594594
self._update_frame_preview(output_file_name, frame_num, final=True)
595595
self._update_frame_task_preview()
@@ -607,13 +607,13 @@ def build_dictionary(cls, definition):
607607
parent = super(BlenderRenderTaskBuilder, cls)
608608

609609
dictionary = parent.build_dictionary(definition)
610-
dictionary[u'options'][u'compositing'] = definition.options.compositing
610+
dictionary['options']['compositing'] = definition.options.compositing
611611
return dictionary
612612

613613
@classmethod
614614
def build_full_definition(cls, task_type, dictionary):
615615
parent = super(BlenderRenderTaskBuilder, cls)
616-
options = dictionary[u'options']
616+
options = dictionary['options']
617617

618618
definition = parent.build_full_definition(task_type, dictionary)
619619
definition.options.compositing = options.get('compositing', False)

apps/blender/task/verificator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from __future__ import division
1+
22
import math
33
import random
44

apps/core/benchmark/minilight/src/camera.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66

77
from math import pi, tan
8-
from raytracer import RayTracer
9-
from vector3f import Vector3f
8+
from .raytracer import RayTracer
9+
from .vector3f import Vector3f
1010

1111
import re
1212
SEARCH = re.compile('(\(.+\))\s*(\(.+\))\s*(\S+)').search
@@ -18,12 +18,12 @@ class Camera(object):
1818

1919
def __init__(self, in_stream):
2020
for l in in_stream:
21-
if type(l) == type(u""):
21+
if type(l) == type(""):
2222
line = l.encode('ascii','ignore')
2323
else:
2424
line = l
2525
if not line.isspace():
26-
p, d, a = SEARCH(line).groups()
26+
p, d, a = SEARCH(line.decode('utf-8')).groups()
2727
self.view_position = Vector3f(p)
2828
self.view_direction = Vector3f(d).unitize()
2929
if self.view_direction.is_zero():

apps/core/benchmark/minilight/src/image.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
from math import log10
8-
from vector3f import Vector3f
8+
from .vector3f import Vector3f
99

1010
IMAGE_DIM_MAX = 4000
1111
PPM_ID = 'P6'
@@ -19,8 +19,7 @@ class Image(object):
1919
def __init__(self, in_stream):
2020
for line in in_stream:
2121
if not line.isspace():
22-
self.width, self.height = map(lambda dimension:
23-
min(max(1, int(dimension)), IMAGE_DIM_MAX), line.split())
22+
self.width, self.height = [min(max(1, int(dimension)), IMAGE_DIM_MAX) for dimension in line.split()]
2423
self.pixels = [0.0] * self.width * self.height * 3
2524
break
2625

apps/core/benchmark/minilight/src/img.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
from math import log10
8-
from vector3f import Vector3f
8+
from .vector3f import Vector3f
99

1010
IMAGE_DIM_MAX = 4000
1111
PPM_ID = 'P6'

apps/core/benchmark/minilight/src/maxilight.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from camera import Camera
2-
from image import Image
3-
from scene import Scene
1+
from .camera import Camera
2+
from .image import Image
3+
from .scene import Scene
44

55
from mtrenderer import RenderWorker
66

@@ -59,9 +59,9 @@ def render_taskable(image, image_file_pathname, camera, scene, num_samples, num_
5959

6060
def main():
6161
if len(argv) < 2 or argv[1] == '-?' or argv[1] == '--help':
62-
print HELP
62+
print(HELP)
6363
else:
64-
print BANNER
64+
print(BANNER)
6565
model_file_pathname = argv[1]
6666
image_file_pathname = model_file_pathname + '.ppm'
6767
model_file = open(model_file_pathname, 'r')
@@ -81,9 +81,12 @@ def main():
8181
avgSpeed = float(numSamples) / duration
8282
expectedTime = totalSamples / avgSpeed
8383

84-
print "\nSummary:"
85-
print " Rendering scene with {} rays took {} seconds".format(numSamples, duration)
86-
print " giving an average speed of {} rays/s".format(avgSpeed)
87-
print " estimated time for the whole scene is {} seconds".format(expectedTime)
84+
print("\nSummary:")
85+
print(" Rendering scene with {} rays took {} seconds"
86+
.format(numSamples, duration))
87+
print(" giving an average speed of {} rays/s"
88+
.format(avgSpeed))
89+
print(" estimated time for the whole scene is {} seconds"
90+
.format(expectedTime))
8891

8992
main()

apps/core/benchmark/minilight/src/minilight.py

+22-18
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
import sys
1212

1313
sys.path.append("src")
14-
from camera import Camera
15-
from image import Image
16-
from scene import Scene
17-
from randommini import Random
14+
from .camera import Camera
15+
from .image import Image
16+
from .scene import Scene
17+
from .randommini import Random
1818

1919

2020
BANNER = '''
@@ -69,7 +69,7 @@ def makePerfTest(filename, cfg_filename, num_cores):
6969
model_file_pathname = filename
7070
image_file_pathname = model_file_pathname + '.ppm'
7171
model_file = open(model_file_pathname, 'r')
72-
if model_file.next().strip() != MODEL_FORMAT_ID:
72+
if model_file.readline().strip() != MODEL_FORMAT_ID:
7373
raise 'invalid model file'
7474
for line in model_file:
7575
if not line.isspace():
@@ -84,9 +84,11 @@ def makePerfTest(filename, cfg_filename, num_cores):
8484
duration = render_taskable(image, image_file_pathname, camera, scene, iterations)
8585

8686
numSamples = image.width * image.height * iterations
87-
print "\nSummary:"
88-
print " Rendering scene with {} rays took {} seconds".format(numSamples, duration)
89-
print " giving an average speed of {} rays/s".format(float(numSamples) / duration)
87+
print("\nSummary:")
88+
print(" Rendering scene with {} rays took {} seconds"
89+
.format(numSamples, duration))
90+
print(" giving an average speed of {} rays/s"
91+
.format(float(numSamples) / duration))
9092
cfg_file = open(cfg_filename, 'w')
9193
average = float(numSamples) / duration
9294
average = average * num_cores
@@ -117,9 +119,9 @@ def render_orig(image, image_file_pathname, camera, scene, iterations):
117119
image_file = open(image_file_pathname, 'wb')
118120
image.get_formatted(image_file, frame_no)
119121
image_file.close()
120-
print '\nfinished'
122+
print('\nfinished')
121123
except KeyboardInterrupt:
122-
print '\ninterrupted'
124+
print('\ninterrupted')
123125

124126
@timedafunc
125127
def render_taskable(image, image_file_pathname, camera, scene, num_samples):
@@ -152,17 +154,17 @@ def render_taskable(image, image_file_pathname, camera, scene, num_samples):
152154
# image.get_formatted(image_file, num_samples)
153155
# image_file.close()
154156

155-
print '\nfinished'
157+
print('\nfinished')
156158
except KeyboardInterrupt:
157-
print '\ninterrupted'
159+
print('\ninterrupted')
158160

159161

160162

161163
def main():
162164
if len(argv) < 2 or argv[1] == '-?' or argv[1] == '--help':
163-
print HELP
165+
print(HELP)
164166
else:
165-
print BANNER
167+
print(BANNER)
166168
model_file_pathname = argv[1]
167169
image_file_pathname = model_file_pathname + '.ppm'
168170
model_file = open(model_file_pathname, 'r')
@@ -181,9 +183,11 @@ def main():
181183
duration = render_taskable(image, image_file_pathname, camera, scene, iterations)
182184

183185
numSamples = image.width * image.height * iterations
184-
print "\nSummary:"
185-
print " Rendering scene with {} rays took {} seconds".format(numSamples, duration)
186-
print " giving an average speed of {} rays/s".format(float(numSamples) / duration)
186+
print("\nSummary:")
187+
print(" Rendering scene with {} rays took {} seconds"
188+
.format(numSamples, duration))
189+
print(" giving an average speed of {} rays/s"
190+
.format(float(numSamples) / duration))
187191
cfg_file = open('minilight.ini', 'w')
188192
average = float(numSamples) / duration
189193
average = average * multiprocessing.cpu_count()
@@ -192,4 +196,4 @@ def main():
192196

193197

194198
if __name__ == "__main__":
195-
main()
199+
main()

0 commit comments

Comments
 (0)