Skip to content

Commit 6c66253

Browse files
authored
Try updating to python3 (#48367)
* Try updating to python3 * Fix submods * Print syntax * More * More fixups * Fix iteritems * Headers
1 parent 3d55a2b commit 6c66253

File tree

7 files changed

+20
-20
lines changed

7 files changed

+20
-20
lines changed

eng/docker/bionic.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RUN apt-get update && \
1414
jq \
1515
wget \
1616
locales \
17-
python \
17+
python3 \
1818
fakeroot \
1919
debhelper \
2020
build-essential \

src/Installers/Debian/tools/build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ validate_inputs(){
126126
}
127127

128128
parse_config_and_set_env_vars(){
129-
extract_base_cmd="python $SCRIPT_DIR/scripts/extract_json_value.py"
129+
extract_base_cmd="python3 $SCRIPT_DIR/scripts/extract_json_value.py"
130130

131131
# Arguments Take Precedence over Config
132132
[ -z "$PACKAGE_VERSION" ] && PACKAGE_VERSION="$($extract_base_cmd $CONFIG "release.package_version")"
@@ -232,15 +232,15 @@ package_install_scripts(){
232232

233233
## Generation Functions ##
234234
generate_config_templates(){
235-
python ${SCRIPT_DIR}/scripts/config_template_generator.py $CONFIG $SCRIPT_DIR/templates/debian $DEBIAN_DIR $PACKAGE_NAME $PACKAGE_VERSION
235+
python3 ${SCRIPT_DIR}/scripts/config_template_generator.py $CONFIG $SCRIPT_DIR/templates/debian $DEBIAN_DIR $PACKAGE_NAME $PACKAGE_VERSION
236236
}
237237

238238
generate_manpages(){
239239
if [[ -f "$DOCS_JSON_PATH" ]]; then
240240
mkdir -p $DOCS_DIR
241241

242242
# Generate the manpages from json spec
243-
python ${SCRIPT_DIR}/scripts/manpage_generator.py ${DOCS_JSON_PATH} ${DOCS_DIR}
243+
python3 ${SCRIPT_DIR}/scripts/manpage_generator.py ${DOCS_JSON_PATH} ${DOCS_DIR}
244244
fi
245245
}
246246

src/Installers/Debian/tools/scripts/config_template_generator.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/python3
22
#
33
# Copyright (c) .NET Foundation and contributors. All rights reserved.
44
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
@@ -47,7 +47,7 @@ def generate_and_write_all(config_data, template_dir, output_dir, package_name=N
4747
symlink_contents = generate_symlinks(config_data, package_name=package_name)
4848
rules_contents = generate_rules(config_data, template_dir)
4949
except Exception as exc:
50-
print exc
50+
print(exc)
5151
help_and_exit("Error: Generation Failed, check your config file.")
5252

5353
write_file(changelog_contents, output_dir, FILE_CHANGELOG)
@@ -157,7 +157,7 @@ def generate_symlinks(config_data, package_name=None):
157157

158158
symlink_data = config_data.get("symlinks", dict())
159159

160-
for package_rel_path, symlink_path in symlink_data.iteritems():
160+
for package_rel_path, symlink_path in iter(symlink_data.items()):
161161

162162
package_abs_path = os.path.join(package_root_path, package_rel_path)
163163

@@ -222,11 +222,11 @@ def write_file(contents, output_dir, name):
222222

223223
# Tool Functions
224224
def help_and_exit(msg):
225-
print msg
225+
print(msg)
226226
sys.exit(1)
227227

228228
def print_usage():
229-
print "Usage: config_template_generator.py [config file path] [template directory path] [output directory] (package name) (package version)"
229+
print("Usage: config_template_generator.py [config file path] [template directory path] [output directory] (package name) (package version)")
230230

231231
def parse_and_validate_args():
232232
if len(sys.argv) < 4:

src/Installers/Debian/tools/scripts/extract_json_value.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/python3
22
#
33
# Copyright (c) .NET Foundation and contributors. All rights reserved.
44
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
@@ -12,13 +12,13 @@
1212
import json
1313

1414
def print_usage():
15-
print """
15+
print("""
1616
Usage: extract_json_value.py [json file path] [key of value to extract]
1717
For nested keys, use . separator
18-
"""
18+
""")
1919

2020
def help_and_exit(msg=None):
21-
print msg
21+
print(msg)
2222
print_usage()
2323
sys.exit(1)
2424

@@ -60,5 +60,5 @@ def execute():
6060
return value
6161

6262
if __name__ == "__main__":
63-
print execute()
63+
print(execute())
6464

src/Installers/Debian/tools/scripts/manpage_generator.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/python3
22
#
33
# Copyright (c) .NET Foundation and contributors. All rights reserved.
44
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
@@ -271,8 +271,8 @@ def _option_string_helper(specifier_short, specifier_long, parameter, include_br
271271

272272

273273
def print_usage():
274-
print "Usage: argv[1] = path to docs.json; argv[2] = output path"
275-
print "Example: manpage_generator.py ../docs.json ./dotnet-1.0/debian"
274+
print("Usage: argv[1] = path to docs.json; argv[2] = output path")
275+
print("Example: manpage_generator.py ../docs.json ./dotnet-1.0/debian")
276276

277277
def parse_args():
278278
doc_path = sys.argv[1]
@@ -296,7 +296,7 @@ def execute_command_line():
296296
generate_man_pages(doc_path, output_dir)
297297

298298
except Exception as exc:
299-
print "Error: ", exc
299+
print("Error: ", exc)
300300
print_usage()
301301

302302
if __name__ == "__main__":

src/Installers/Debian/tools/test/test_assets/test_package_layout/debian_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"curl": {
3232
"package_version" : "0.5.3"
3333
},
34-
"python":{}
34+
"python3":{}
3535
},
3636

3737
"symlinks": {

src/Installers/Debian/tools/test/unit_tests/test_scripts.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ setup(){
1414
@test "manpage generation is identical to lkg file" {
1515
# Output is file "tool1.1"
1616
# LKG file is "lkgtestman.1"
17-
python $PACKAGIFY_DIR/scripts/manpage_generator.py $PACKAGIFY_DIR/test/test_assets/testdocs.json $PACKAGIFY_DIR/test/test_assets
17+
python3 $PACKAGIFY_DIR/scripts/manpage_generator.py $PACKAGIFY_DIR/test/test_assets/testdocs.json $PACKAGIFY_DIR/test/test_assets
1818

1919
# Test Output existence
2020
[ -f $PACKAGIFY_DIR/test/test_assets/tool1.1 ]

0 commit comments

Comments
 (0)