Skip to content

Commit 3c00a87

Browse files
authored
Merge pull request #112 from mendix/python3
DEP-62 Convert buildpack to Python3
2 parents cea2361 + f6d2c5c commit 3c00a87

224 files changed

Lines changed: 42571 additions & 10480 deletions

File tree

Some content is hidden

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

bin/compile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
#!/usr/bin/env python
2-
import os
3-
import sys
1+
#!/usr/bin/env python3
2+
import codecs
43
import json
5-
import shutil
64
import logging
7-
import zipfile
5+
import os
6+
import shutil
87
import subprocess
8+
import sys
9+
import zipfile
910

1011
BUILD_DIR = sys.argv[1]
1112
CACHE_DIR = os.path.join(sys.argv[2], 'bust')
@@ -250,8 +251,8 @@ def buildstatus_callback(error_file):
250251
]}
251252
input_str = ''
252253
try:
253-
with open(error_file, 'r') as b:
254-
input_str = b.read().decode('utf-8-sig')
254+
with codecs.open(error_file, 'r', encoding='utf-8-sig') as b:
255+
input_str = b.read()
255256
builddata = json.dumps(json.loads(input_str))
256257
except (IOError, ValueError):
257258
logging.exception('Could not read mxbuild error file\n%s' % input_str)

bin/release

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
cat << EOF
44
default_process_types:
5-
web: python start.py
5+
web: python3 start.py
66
EOF

lib/buildpackutil.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,14 @@
44
import errno
55
import subprocess
66
import logging
7-
import urlparse
87
import sys
8+
from urllib.parse import parse_qs
99
sys.path.insert(0, 'lib')
1010
import requests
1111

1212

1313
def get_database_config(development_mode=False):
14-
if any(map(
15-
lambda x: x.startswith('MXRUNTIME_Database'),
16-
os.environ.keys()
17-
)):
14+
if any([x.startswith('MXRUNTIME_Database') for x in list(os.environ.keys())]):
1815
return {}
1916

2017
url = get_database_uri_from_vcap()
@@ -57,7 +54,7 @@ def get_database_config(development_mode=False):
5754

5855
if 'extra' in match.groupdict() and match.group('extra'):
5956
extra = match.group('extra').lstrip('?')
60-
jdbc_params = urlparse.parse_qs(extra)
57+
jdbc_params = parse_qs(extra)
6158
if 'sslmode' in jdbc_params:
6259
sslmode = jdbc_params['sslmode']
6360
if sslmode and sslmode[0] == 'require':
@@ -136,7 +133,7 @@ def get_database_uri_from_vcap():
136133

137134

138135
def appdynamics_used():
139-
for k, v in os.environ.iteritems():
136+
for k, v in os.environ.items():
140137
if k.startswith('APPDYNAMICS_'):
141138
return True
142139
return False
@@ -150,7 +147,7 @@ def get_new_relic_license_key():
150147

151148

152149
def get_blobstore_url(filename):
153-
main_url = os.environ.get('BLOBSTORE', 'http://cdn.mendix.com')
150+
main_url = os.environ.get('BLOBSTORE', 'https://cdn.mendix.com')
154151
if main_url[-1] == '/':
155152
main_url = main_url[0:-1]
156153
return main_url + filename
@@ -214,7 +211,7 @@ def download(url, destination):
214211
logging.debug('downloading {url} to {destination}'.format(
215212
url=url, destination=destination
216213
))
217-
with open(destination, 'w') as file_handle:
214+
with open(destination, 'wb') as file_handle:
218215
response = requests.get(url, stream=True)
219216
if not response.ok:
220217
response.raise_for_status()
@@ -249,7 +246,7 @@ def get_java_version(mx_version):
249246
default = '7'
250247
main_java_version = os.getenv('JAVA_VERSION', default)
251248

252-
if main_java_version not in versions.keys():
249+
if main_java_version not in list(versions.keys()):
253250
raise Exception(
254251
'Invalid Java version specified: %s'
255252
% main_java_version
@@ -258,7 +255,7 @@ def get_java_version(mx_version):
258255

259256

260257
def get_mpr_file_from_dir(directory):
261-
mprs = filter(lambda x: x.endswith('.mpr'), os.listdir(directory))
258+
mprs = [x for x in os.listdir(directory) if x.endswith('.mpr')]
262259
if len(mprs) == 1:
263260
return os.path.join(directory, mprs[0])
264261
elif len(mprs) > 1:

lib/certifi/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .core import where, old_where
2+
3+
__version__ = "2017.04.17"

lib/certifi/__main__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from certifi import where
2+
print(where())

lib/certifi/cacert.pem

Lines changed: 5246 additions & 0 deletions
Large diffs are not rendered by default.

lib/certifi/core.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
"""
5+
certifi.py
6+
~~~~~~~~~~
7+
8+
This module returns the installation location of cacert.pem.
9+
"""
10+
import os
11+
import warnings
12+
13+
14+
class DeprecatedBundleWarning(DeprecationWarning):
15+
"""
16+
The weak security bundle is being deprecated. Please bother your service
17+
provider to get them to stop using cross-signed roots.
18+
"""
19+
20+
21+
def where():
22+
f = os.path.split(__file__)[0]
23+
24+
return os.path.join(f, 'cacert.pem')
25+
26+
27+
def old_where():
28+
warnings.warn(
29+
"The weak security bundle is being deprecated.",
30+
DeprecatedBundleWarning
31+
)
32+
f = os.path.split(__file__)[0]
33+
return os.path.join(f, 'weak.pem')
34+
35+
if __name__ == '__main__':
36+
print(where())

0 commit comments

Comments
 (0)