Print error messages when necessary

This commit is contained in:
Eric Torres 2022-03-24 13:01:28 -07:00
parent d683c08889
commit 7bedb53f65
3 changed files with 41 additions and 13 deletions

View File

@ -1,6 +1,14 @@
Changelog for packaging-scripts
===============================
Version 1.6.0
-------------
* pug2
* Print error messages from gist when necessary
Version 1.5.3
-------------

View File

@ -82,20 +82,39 @@ if __name__ == "__main__":
gist_id = config.get(CONFIG_SECTION, CONFIG_OPTION_ID)
if gist_id == "":
try:
print("No gist ID detected, creating new.")
gist_process = subprocess.run(
f"pacman -Qqen | gist --filename {gist_filename} --description {gist_description}",
capture_output=True,
text=True,
shell=True,
check=True,
)
config[CONFIG_SECTION][CONFIG_OPTION_ID] = extract_gist_id(gist_process.stdout)
except subprocess.CalledProcessError as e:
print(e.stdout.strip(), file=sys.stderr)
sys.exit(e.returncode)
else:
config[CONFIG_SECTION][CONFIG_OPTION_ID] = extract_gist_id(
gist_process.stdout
)
print("Gist creation complete.")
elif package_lists_match(gist_id):
print("Package lists match, no update necessary.")
sys.exit(0)
else:
try:
print("Package lists differ, updating.")
subprocess.run(
f"pacman -Qqen | gist --update {gist_id} --filename {gist_filename} --description {gist_description}",
capture_output=True,
text=True,
shell=True,
check=True,
)
except subprocess.CalledProcessError as e:
print(e.stdout.strip(), file=sys.stderr)
sys.exit(e.returncode)
else:
print("Update complete.")

View File

@ -7,5 +7,6 @@ Target = *
[Action]
Depends = coreutils
Depends = packaging-scripts
When = PostTransaction
Exec = /usr/bin/pug2