Merge ~cjwatson/launchpad-mojo-specs:utils-check-python-version into launchpad-mojo-specs:master

Proposed by Colin Watson
Status: Merged
Merged at revision: 476e947625c401a29b366bd731abf086a7a3a669
Proposed branch: ~cjwatson/launchpad-mojo-specs:utils-check-python-version
Merge into: launchpad-mojo-specs:master
Diff against target: 248 lines (+65/-16)
17 files modified
lp-codeimport/update-code-asset (+3/-1)
lp-codeimport/upgrade-charms (+3/-1)
mojo-lp-git/run-payload-tests (+3/-1)
mojo-lp-git/update-code-asset (+3/-1)
mojo-lp-git/upgrade-charms (+3/-1)
mojo-lp-signing/update-code-asset (+3/-1)
mojo-lp-signing/upgrade-charms (+3/-1)
utils/add-floating-ip (+3/-1)
utils/check_version.py (+17/-0)
utils/custom-secgroups.py (+3/-1)
utils/get-last-build-label (+3/-1)
utils/get-swift-storage-url (+3/-1)
utils/make-branches (+3/-1)
utils/publish-build-assets (+3/-1)
utils/publish-last-build-label (+3/-1)
utils/set-local-config (+3/-1)
utils/set-service-options (+3/-1)
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+404120@code.launchpad.net

Commit message

Re-exec scripts using Python 2 where necessary

Description of the change

wendigo (the devops management host for PS4.5) is old and lacks a number of Python 3 libraries that we use; however, when deploying to PS5, we need to run on Ubuntu 20.04 LTS, which lacks Python 2 versions of the same libraries. To escape this Catch-22, re-exec ourselves using Python 2 if we find ourselves on a system that's known to be too old to support the Python 3 libraries we need.

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/lp-codeimport/update-code-asset b/lp-codeimport/update-code-asset
index fdc7fbf..e7386e3 100755
--- a/lp-codeimport/update-code-asset
+++ b/lp-codeimport/update-code-asset
@@ -1,4 +1,6 @@
1#! /usr/bin/python1#! /usr/bin/python3
2
3import utils.check_version # noqa: F401
24
3import os5import os
4import subprocess6import subprocess
diff --git a/lp-codeimport/upgrade-charms b/lp-codeimport/upgrade-charms
index ef477c7..10bf64e 100755
--- a/lp-codeimport/upgrade-charms
+++ b/lp-codeimport/upgrade-charms
@@ -1,4 +1,6 @@
1#! /usr/bin/python1#! /usr/bin/python3
2
3import utils.check_version # noqa: F401
24
3import os.path5import os.path
4import subprocess6import subprocess
diff --git a/mojo-lp-git/run-payload-tests b/mojo-lp-git/run-payload-tests
index 8d9e5eb..7e61ac4 100755
--- a/mojo-lp-git/run-payload-tests
+++ b/mojo-lp-git/run-payload-tests
@@ -1,4 +1,6 @@
1#! /usr/bin/python1#! /usr/bin/python3
2
3import utils.check_version # noqa: F401
24
3import os5import os
4import subprocess6import subprocess
diff --git a/mojo-lp-git/update-code-asset b/mojo-lp-git/update-code-asset
index bfc3c23..12492d9 100755
--- a/mojo-lp-git/update-code-asset
+++ b/mojo-lp-git/update-code-asset
@@ -1,4 +1,6 @@
1#! /usr/bin/python1#! /usr/bin/python3
2
3import utils.check_version # noqa: F401
24
3import os5import os
4import subprocess6import subprocess
diff --git a/mojo-lp-git/upgrade-charms b/mojo-lp-git/upgrade-charms
index f215db1..4f5d386 100755
--- a/mojo-lp-git/upgrade-charms
+++ b/mojo-lp-git/upgrade-charms
@@ -1,4 +1,6 @@
1#! /usr/bin/python1#! /usr/bin/python3
2
3import utils.check_version # noqa: F401
24
3import os.path5import os.path
4import subprocess6import subprocess
diff --git a/mojo-lp-signing/update-code-asset b/mojo-lp-signing/update-code-asset
index b140f51..aebf69b 100755
--- a/mojo-lp-signing/update-code-asset
+++ b/mojo-lp-signing/update-code-asset
@@ -1,4 +1,6 @@
1#! /usr/bin/python1#! /usr/bin/python3
2
3import utils.check_version # noqa: F401
24
3import os5import os
4import subprocess6import subprocess
diff --git a/mojo-lp-signing/upgrade-charms b/mojo-lp-signing/upgrade-charms
index 9c69500..aa339ee 100755
--- a/mojo-lp-signing/upgrade-charms
+++ b/mojo-lp-signing/upgrade-charms
@@ -1,4 +1,6 @@
1#! /usr/bin/python1#! /usr/bin/python3
2
3import utils.check_version # noqa: F401
24
3import os.path5import os.path
4import subprocess6import subprocess
diff --git a/utils/add-floating-ip b/utils/add-floating-ip
index 4540b3f..2024af6 100755
--- a/utils/add-floating-ip
+++ b/utils/add-floating-ip
@@ -1,10 +1,12 @@
1#!/usr/bin/python1#!/usr/bin/python3
2#2#
3# Authors: Paul Gear, Neale Pickett3# Authors: Paul Gear, Neale Pickett
4# Description: Manage floating IP allocations in mojo local directory for a juju service or unit.4# Description: Manage floating IP allocations in mojo local directory for a juju service or unit.
5# NOTE: $MOJO_PROJECT and $MOJO_STAGE must be set before calling this script.5# NOTE: $MOJO_PROJECT and $MOJO_STAGE must be set before calling this script.
6#6#
77
8import check_version # noqa: F401
9
8import json10import json
9import os11import os
10import subprocess12import subprocess
diff --git a/utils/check_version.py b/utils/check_version.py
11new file mode 10064413new file mode 100644
index 0000000..acf82ea
--- /dev/null
+++ b/utils/check_version.py
@@ -0,0 +1,17 @@
1# At the time of writing (June 2021), we still need to deploy code to PS4.5.
2# The devops management host for that cloud runs Ubuntu 14.04, which has
3# Python 3.4, and which also doesn't have many of the libraries we need
4# packaged for Python 3. This abominable hack checks whether we're on 3.4,
5# and if so re-execs itself using Python 2.
6#
7# The Python version itself isn't really the important factor here, but it's
8# a proxy indicator that we can check easily.
9#
10# We should drop this as soon as we no longer need to support deploying from
11# Ubuntu 14.04.
12
13import os
14import sys
15
16if sys.version_info[0] == 3 and sys.version_info[1] < 5:
17 os.execv('/usr/bin/python2', [sys.argv[0]] + sys.argv)
diff --git a/utils/custom-secgroups.py b/utils/custom-secgroups.py
index af4eab5..f4e1059 100755
--- a/utils/custom-secgroups.py
+++ b/utils/custom-secgroups.py
@@ -1,9 +1,11 @@
1#! /usr/bin/python1#! /usr/bin/python3
2# By wgrant, with some neutron manipulation stolen from cjwatson's2# By wgrant, with some neutron manipulation stolen from cjwatson's
3# clean-up-secgroups.py.3# clean-up-secgroups.py.
44
5from __future__ import print_function5from __future__ import print_function
66
7import check_version # noqa: F401
8
7__metaclass__ = type9__metaclass__ = type
810
9import argparse11import argparse
diff --git a/utils/get-last-build-label b/utils/get-last-build-label
index fa26837..a12e797 100755
--- a/utils/get-last-build-label
+++ b/utils/get-last-build-label
@@ -1,4 +1,4 @@
1#! /usr/bin/python1#! /usr/bin/python3
22
3"""Print the last build label in a particular state.3"""Print the last build label in a particular state.
44
@@ -8,6 +8,8 @@ shell.
88
9from __future__ import print_function9from __future__ import print_function
1010
11import check_version # noqa: F401
12
11import os13import os
1214
13import utils15import utils
diff --git a/utils/get-swift-storage-url b/utils/get-swift-storage-url
index 3119867..e34a597 100755
--- a/utils/get-swift-storage-url
+++ b/utils/get-swift-storage-url
@@ -1,9 +1,11 @@
1#! /usr/bin/python1#! /usr/bin/python3
22
3"""Print the Swift storage URL."""3"""Print the Swift storage URL."""
44
5from __future__ import print_function5from __future__ import print_function
66
7import check_version # noqa: F401
8
7import utils9import utils
810
911
diff --git a/utils/make-branches b/utils/make-branches
index f4ab582..c34bcb5 100755
--- a/utils/make-branches
+++ b/utils/make-branches
@@ -1,4 +1,6 @@
1#! /usr/bin/python1#! /usr/bin/python3
2
3import check_version # noqa: F401
24
3import os5import os
4import shutil6import shutil
diff --git a/utils/publish-build-assets b/utils/publish-build-assets
index 158bdc8..11ddd18 100755
--- a/utils/publish-build-assets
+++ b/utils/publish-build-assets
@@ -1,4 +1,6 @@
1#! /usr/bin/python1#! /usr/bin/python3
2
3import check_version # noqa: F401
24
3import os5import os
46
diff --git a/utils/publish-last-build-label b/utils/publish-last-build-label
index 7bdf13c..0ff812b 100755
--- a/utils/publish-last-build-label
+++ b/utils/publish-last-build-label
@@ -1,8 +1,10 @@
1#! /usr/bin/python1#! /usr/bin/python3
22
3"""Publishes the last attempted build label to a specific swift file3"""Publishes the last attempted build label to a specific swift file
4for use by other jobs which may trigger a spec run."""4for use by other jobs which may trigger a spec run."""
55
6import check_version # noqa: F401
7
6import os8import os
7import shutil9import shutil
8import tempfile10import tempfile
diff --git a/utils/set-local-config b/utils/set-local-config
index 21ab9e1..123059c 100755
--- a/utils/set-local-config
+++ b/utils/set-local-config
@@ -1,7 +1,9 @@
1#! /usr/bin/python1#! /usr/bin/python3
22
3from __future__ import print_function3from __future__ import print_function
44
5import check_version # noqa: F401
6
5import argparse7import argparse
6import os.path8import os.path
79
diff --git a/utils/set-service-options b/utils/set-service-options
index bb5c1e1..8b12678 100755
--- a/utils/set-service-options
+++ b/utils/set-service-options
@@ -1,7 +1,9 @@
1#! /usr/bin/python1#! /usr/bin/python3
22
3from __future__ import print_function3from __future__ import print_function
44
5import check_version # noqa: F401
6
5import base647import base64
6import numbers8import numbers
7import sys9import sys

Subscribers

People subscribed via source and target branches