Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions continuous-delivery/pip-install-with-retry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import time
import sys
import subprocess

DOCS = """Given cmdline args, executes: python3 -m pip install [args...]
Keeps retrying until the new version becomes available in pypi (or we time out)"""
if len(sys.argv) < 2:
sys.exit(DOCS)

RETRY_INTERVAL_SECS = 10
GIVE_UP_AFTER_SECS = 60 * 15

pip_install_args = [sys.executable, '-m', 'pip', 'install'] + sys.argv[1:]

start_time = time.time()
while True:
print(subprocess.list2cmdline(pip_install_args))
result = subprocess.run(pip_install_args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

stdout = result.stdout.decode().strip()
if stdout:
print(stdout)

if result.returncode == 0:
# success
sys.exit(0)

if "could not find a version" in stdout.lower():
elapsed_secs = time.time() - start_time
if elapsed_secs < GIVE_UP_AFTER_SECS:
# try again
print("Retrying in", RETRY_INTERVAL_SECS, "secs...")
time.sleep(RETRY_INTERVAL_SECS)
continue
else:
print("Giving up on retries after", int(elapsed_secs), "total secs.")

# fail
sys.exit(result.returncode)
3 changes: 1 addition & 2 deletions continuous-delivery/test_prod_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ phases:
- echo Build started on `date`
- cd aws-iot-device-sdk-python-v2
- CURRENT_TAG_VERSION=$(git describe --tags | cut -f2 -dv)
- python3 continuous-delivery/wait-for-pypi.py awsiotsdk $CURRENT_TAG_VERSION --index https://pypi.python.org/pypi
- python3 -m pip install --no-cache-dir --user awsiotsdk==$CURRENT_TAG_VERSION
- python3 continuous-delivery/pip-install-with-retry.py --no-cache-dir --user awsiotsdk==$CURRENT_TAG_VERSION
- python3 samples/basic_discovery.py --region us-east-1 --cert /tmp/certificate.pem --key /tmp/privatekey.pem --root-ca /tmp/AmazonRootCA1.pem --thing-name aws-sdk-crt-unit-test --print-discover-resp-only -v Trace

post_build:
Expand Down
3 changes: 1 addition & 2 deletions continuous-delivery/test_test_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ phases:
- CURRENT_TAG_VERSION=$(git describe --tags | cut -f2 -dv)
# this is here because typing isn't in testpypi, so pull it from prod instead
- python3 -m pip install typing
- python3 continuous-delivery/wait-for-pypi.py awsiotsdk $CURRENT_TAG_VERSION --index https://test.pypi.org/pypi
- python3 -m pip install --no-cache-dir -i https://testpypi.python.org/simple --user awsiotsdk==$CURRENT_TAG_VERSION
- python3 continuous-delivery/pip-install-with-retry.py -i https://testpypi.python.org/simple --user awsiotsdk==$CURRENT_TAG_VERSION
- python3 samples/basic_discovery.py --region us-east-1 --cert /tmp/certificate.pem --key /tmp/privatekey.pem --root-ca /tmp/AmazonRootCA1.pem --thing-name aws-sdk-crt-unit-test --print-discover-resp-only -v Trace

post_build:
Expand Down
43 changes: 0 additions & 43 deletions continuous-delivery/wait-for-pypi.py

This file was deleted.