-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replaced the walrus operations with something compatible with python-…
…3.6; Changed pprint in the dynamic width same as the terminal width; Added 'digest' info into the imageInfo printout; Added a guide to start the corresponding image if a sole image is found
- Loading branch information
Shuwei Ye
authored and
Shuwei Ye
committed
Mar 2, 2024
1 parent
9ac93d9
commit e7f357d
Showing
2 changed files
with
42 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/bin/bash | ||
# coding: utf-8 | ||
# version=2024-02-27-r01 | ||
# version=2024-03-02-r01 | ||
# author: Shuwei Ye <[email protected]> | ||
"true" '''\' | ||
myScript="${BASH_SOURCE:-$0}" | ||
|
@@ -213,13 +213,24 @@ def parseArgTags(inputArgs, requireRelease=False): | |
print("The input arg tags=", argTags) | ||
print("!!Warning!! No project is given from the available choices:", ATLAS_PROJECTS) | ||
for argTag in argTags: | ||
if closeProject := difflib.get_close_matches(argTag.lower(), ATLAS_PROJECTS, n=1, cutoff=0.8): | ||
closeProject = None | ||
argTag_1 = re.split(r'[-.=;]', argTag, 1)[0].lower() | ||
if argTag_1 in ATLAS_PROJECTS: | ||
closeProject = argTag_1 | ||
if not closeProject: | ||
closeMatch = difflib.get_close_matches(argTag.lower(), ATLAS_PROJECTS, n=1, cutoff=0.8) | ||
if closeMatch: | ||
closeProject = closeMatch[0] | ||
if closeProject: | ||
print() | ||
print("The closest matched project=", closeProject[0]) | ||
if isinstance(closeProject, list): | ||
closeProject = closeProject[0] | ||
print("The closest matched project=", closeProject) | ||
print(" against the input arg tag=", argTag) | ||
print("\nPlease correct it, then rerun\n") | ||
break | ||
sys.exit(1) | ||
if requireRelease and 'releases' not in releaseTags: | ||
print("!!Warning!! No release is given") | ||
sys.exit(1) | ||
|
@@ -333,12 +344,15 @@ def listReleases(args): | |
tags += [ tagName ] | ||
tags.sort(key=Version) | ||
if len(tags) > 0: | ||
pp = pprint.PrettyPrinter(indent=4, compact=True) | ||
columns = os.get_terminal_size().columns | ||
pp = pprint.PrettyPrinter(indent=4, compact=True, width=columns) | ||
print("Found the following release containers for the project= %s, %s\n" % (project, releasePrint)) | ||
pp.pprint(tags) | ||
if len(tags) == 1: | ||
print() | ||
getImageInfo(project, tags[0]) | ||
print("\nTo run the above image, just run") | ||
print("\tsource %s %s,%s" % (sys.argv[0], project, tags[0])) | ||
else: | ||
print("No release container found for the project=%s, and %s" % (project, releasePrint)) | ||
|
@@ -357,12 +371,14 @@ def getImageInfo(project, release, printOut=True): | |
imageInfo['dockerPath' ] = json_obj['location'] | ||
imageInfo['imageCompressedSize'] = json_obj['total_size'] | ||
imageInfo['lastUpdate'] = json_obj['created_at'] | ||
imageInfo['digest'] = json_obj['digest'] | ||
if len(imageInfo) > 0 and printOut: | ||
print("The matched image info:") | ||
print("\tdockerPath=", imageInfo['dockerPath'], | ||
"\n\timage compressed size=", imageInfo['imageCompressedSize'], | ||
"\n\tlast update time=", imageInfo['lastUpdate']) | ||
"\n\tlast update time=", imageInfo['lastUpdate'], | ||
"\n\tdigest=", imageInfo['digest']) | ||
return imageInfo | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#!/bin/bash | ||
# coding: utf-8 | ||
# version=2024-02-27-r01 | ||
# version=2024-03-02-r01 | ||
# author: Shuwei Ye <[email protected]> | ||
"true" '''\' | ||
myScript="${BASH_SOURCE:-$0}" | ||
|
@@ -185,13 +185,24 @@ def parseArgTags(inputArgs, requireRelease=False): | |
print("The input arg tags=", argTags) | ||
print("!!Warning!! No project is given from the available choices:", ATLAS_PROJECTS) | ||
for argTag in argTags: | ||
if closeProject := difflib.get_close_matches(argTag.lower(), ATLAS_PROJECTS, n=1, cutoff=0.8): | ||
closeProject = None | ||
argTag_1 = re.split(r'[-.=;]', argTag, 1)[0].lower() | ||
if argTag_1 in ATLAS_PROJECTS: | ||
closeProject = argTag_1 | ||
if not closeProject: | ||
closeMatch = difflib.get_close_matches(argTag.lower(), ATLAS_PROJECTS, n=1, cutoff=0.8) | ||
if closeMatch: | ||
closeProject = closeMatch[0] | ||
if closeProject: | ||
print() | ||
print("The closest matched project=", closeProject[0]) | ||
if isinstance(closeProject, list): | ||
closeProject = closeProject[0] | ||
print("The closest matched project=", closeProject) | ||
print(" against the input arg tag=", argTag) | ||
print("\nPlease correct it, then rerun\n") | ||
break | ||
sys.exit(1) | ||
if requireRelease and 'releases' not in releaseTags: | ||
print("!!Warning!! No release is given") | ||
sys.exit(1) | ||
|
@@ -249,7 +260,7 @@ def listImageTags(project): | |
digest = tagObj['images'][0]['digest'] | ||
imageSize = tagObj['full_size'] | ||
lastUpdate = tagObj['tag_last_pushed'] | ||
imageTags[name] = {'imageCompressedSize':imageSize, 'lastUpdate':lastUpdate, 'releaseName':name} | ||
imageTags[name] = {'imageCompressedSize':imageSize, 'lastUpdate':lastUpdate, 'releaseName':name, 'digest':digest} | ||
if name == 'latest': | ||
latest_digest = digest | ||
elif latest_digest != '': | ||
|
@@ -314,12 +325,15 @@ def listReleases(args): | |
tags += [ tagName ] | ||
tags.sort(key=Version) | ||
if len(tags) > 0: | ||
pp = pprint.PrettyPrinter(indent=4, compact=True) | ||
columns = os.get_terminal_size().columns | ||
pp = pprint.PrettyPrinter(indent=4, compact=True, width=columns) | ||
print("Found the following release containers for the project= %s, %s\n" % (project, releasePrint)) | ||
pp.pprint(tags) | ||
if len(tags) == 1: | ||
print() | ||
getImageInfo(project, tags[0]) | ||
print("\nTo run the above image, just run") | ||
print("\tsource %s %s,%s" % (sys.argv[0], project, tags[0])) | ||
else: | ||
print("No release container found for the project=%s, and %s" % (project, releasePrint)) | ||
|
@@ -339,7 +353,8 @@ def getImageInfo(project, release, printOut=True): | |
print("The matched image info:") | ||
print("\tdockerPath=", imageInfo['dockerPath'], | ||
"\n\timage compressed size=", imageInfo['imageCompressedSize'], | ||
"\n\tlast update time=", imageInfo['lastUpdate']) | ||
"\n\tlast update time=", imageInfo['lastUpdate'], | ||
"\n\tdigest=", imageInfo['digest']) | ||
return imageInfo | ||
|