Skip to content

Commit

Permalink
Allow -q to specify a program
Browse files Browse the repository at this point in the history
  • Loading branch information
hammy275 committed Jun 3, 2020
1 parent d8c0384 commit 219826c
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 25 deletions.
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
###VERSIONS###

version = "1.5.3"
prog_internal_version = 91
prog_internal_version = 92
file_version = 15

#############
Expand Down
3 changes: 3 additions & 0 deletions prog_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def update_program(program):
return "Success"
except OSError:
return "OSError"
return "Does not update"


def update_script(program, script_path):
Expand Down Expand Up @@ -224,6 +225,8 @@ def update_programs():
statuses[p] = update_program(p)
elif (config.db["programs"][p]["update_url"] and config.read_config("UpdateURLPrograms")):
statuses[p] = update_program(p)
else:
statuses[p] = "Does not update"
progress += increment
generic.progress(progress)
if progress < 100:
Expand Down
69 changes: 46 additions & 23 deletions tarstall_execs/tarstall
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,38 @@ def install_wrap_up(program):
generic.pprint("Installation complete!")


def update_program_gui(program):
"""Update a Program and Print Result to User.
Args:
program (str): Program to update.
"""
status = prog_manage.update_program(program)
if status == "Success":
generic.ppause("Program upgrading successful!")
elif status == "No update":
generic.ppause("Program is already up to date!")
elif status == "No git":
generic.ppause("Git not installed, please install it!")
elif status == "Error updating":
generic.ppause("Error while upgrading through git!")
elif status == "No script":
generic.ppause("Upgrade script no longer exists! The update script reference has been removed!")
elif status == "Script error":
generic.ppause("Error while executing the supplied upgrade script!")
elif status == "OSError":
generic.ppause("Shell not specified! Please specify one at the top of the supplied script (ex. #!/bin/sh)")
elif status == "No wget":
generic.ppause("Wget is not installed!")
elif status == "Wget error":
generic.ppause("An error occured while downloading the archive!")
elif status == "Install error":
generic.ppause("An error occured while installing the program!")
elif status == "Does not update": # Can only be reached through -q, so no need to ppause here
generic.pprint("Program does not have any way of updating!")


def manage(program):
"""Manage Installed Program.
Expand Down Expand Up @@ -512,27 +544,7 @@ E - Exit program management""".format(program=program, git=git_msg, g=g_msg, us=
elif option == 'w' and g_msg == "w/":
wget_wizard(program)
elif option == 'q' and q != "":
status = prog_manage.update_program(program)
if status == "Success":
generic.ppause("Program upgrading successful!")
elif status == "No update":
generic.ppause("Program is already up to date!")
elif status == "No git":
generic.ppause("Git not installed, please install it!")
elif status == "Error updating":
generic.ppause("Error while upgrading through git!")
elif status == "No script":
generic.ppause("Upgrade script no longer exists! The update script reference has been removed!")
elif status == "Script error":
generic.ppause("Error while executing the supplied upgrade script!")
elif status == "OSError":
generic.ppause("Shell not specified! Please specify one at the top of the supplied script (ex. #!/bin/sh)")
elif status == "No wget":
generic.ppause("Wget is not installed!")
elif status == "Wget error":
generic.ppause("An error occured while downloading the archive!")
elif status == "Install error":
generic.ppause("An error occured while installing the program!")
update_program_gui(program)
elif option == 'us':
msg = """
Please input the path to a script you would like to run to upgrade an installed program.
Expand Down Expand Up @@ -603,7 +615,7 @@ def parse_args(args=None):
group.add_argument('-k', '--remove-lock', help="Remove tarstall lock file (only do this if tarstall isn't already "
"running)", action="store_true")
group.add_argument('-c', '--config', help="Change tarstall options", action="store_true")
group.add_argument('-q', '--update-programs', help="Update programs installed through git, ones with upgrade scripts, and ones with a URL assigned to them", action="store_true")
group.add_argument('-q', '--update-programs', help="Update programs that can be updated, or a single program if supplied.", nargs='?', const="True", type=str)
if args is None:
args = parser.parse_args()
else:
Expand Down Expand Up @@ -794,7 +806,7 @@ def parse_args(args=None):
elif args.config:
configure()

elif args.update_programs:
elif args.update_programs == "True":
status = prog_manage.update_programs()
if status == "No git":
generic.pprint("git isn't installed, please install it!")
Expand All @@ -812,13 +824,24 @@ def parse_args(args=None):
msg += p + " is already up to date!\n"
elif status[p] == "OSError":
msg += p + " does not have #!/bin/sh or similar specified at the top of its file!"
exit_code = 1
elif status[p] == "Does not update":
msg += p + " does not update or has a URL as its only update option!"
else:
msg += p + " did not update successfully!\n"
exit_code = 1
generic.pprint(msg)

elif args.update_programs:
if not args.update_programs in config.db["programs"]:
generic.pprint("{} not installed!".format(args.update_programs))
exit_code = 1
else:
update_program_gui(args.update_programs)


elif not did_fts:
print(args.update_programs)
generic.pprint("""
tarstall. A Python based package manager to manage archives.
Written by: hammy3502
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
15.91
15.92

0 comments on commit 219826c

Please sign in to comment.