Skip to content

Commit

Permalink
Add assume-yes to skip interaction on update
Browse files Browse the repository at this point in the history
  • Loading branch information
LyzardKing committed Apr 27, 2024
1 parent 3f67a87 commit 95076c9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions umake/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def main():
parser.add_argument('--help', action=_HelpAction, help=_('Show this help')) # add custom help
parser.add_argument("-v", "--verbose", action="count", default=0, help=_("Increase output verbosity (2 levels)"))
parser.add_argument('-u', '--update', action='store_true', help=_('Update installed frameworks'))
parser.add_argument('-y', '--assume-yes', action='store_true', help=_('Assume yes at interactive prompts'))
parser.add_argument('-r', '--remove', action="store_true", help=_("Remove specified framework if installed"))

list_group = parser.add_argument_group("List frameworks").add_mutually_exclusive_group()
Expand Down
6 changes: 5 additions & 1 deletion umake/frameworks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,19 @@ def run_for(self, args):
install_path = None
auto_accept_license = False
dry_run = False
assume_yes = False
if args.destdir:
install_path = os.path.abspath(os.path.expanduser(args.destdir))
if self.expect_license and args.accept_license:
auto_accept_license = True
if args.dry_run:
dry_run = True
if args.assume_yes:
assume_yes = True
self.setup(install_path=install_path,
auto_accept_license=auto_accept_license,
dry_run=dry_run)
dry_run=dry_run,
assume_yes=assume_yes)

def get_latest_version(self):
return (re.search(self.version_regex, self.package_url).group(1).replace('_', '.')
Expand Down
14 changes: 11 additions & 3 deletions umake/frameworks/baseinstaller.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,22 @@ def is_installed(self):
logger.debug("{} is installed".format(self.name))
return True

def setup(self, install_path=None, auto_accept_license=False, dry_run=False):
def setup(self, install_path=None, auto_accept_license=False, dry_run=False, assume_yes=False):
self.arg_install_path = install_path
self.auto_accept_license = auto_accept_license
self.dry_run = dry_run
self.assume_yes = assume_yes
super().setup()

# first step, check if installed or dry_run
if self.dry_run:
self.download_provider_page()
elif self.is_installed:
UI.display(YesNo("{} is already installed on your system, do you want to reinstall "
"it anyway?".format(self.name), self.reinstall, UI.return_main_screen))
if self.assume_yes:
self.reinstall()
else:
UI.display(YesNo("{} is already installed on your system, do you want to reinstall "
"it anyway?".format(self.name), self.reinstall, UI.return_main_screen))
else:
self.confirm_path(self.arg_install_path)

Expand Down Expand Up @@ -163,6 +167,10 @@ def set_exec_path(self):
def confirm_path(self, path_dir=""):
"""Confirm path dir"""

if self.assume_yes:
UI.display(DisplayMessage("Assuming default path: " + self.install_path))
path_dir = self.install_path

if not path_dir:
logger.debug("No installation path provided. Requesting one.")
UI.display(InputText("Choose installation path:", self.confirm_path, self.install_path))
Expand Down
5 changes: 5 additions & 0 deletions umake/ui/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ def mangle_args_for_default_framework(args):
if not category_name and arg in ("--remove", "-r"):
args_to_append.append(arg)
continue
if arg in ("--assume-yes", '-y'):
args_to_append.append(arg)
continue
if not arg.startswith('-') and not skip_all:
if not category_name:
if arg in BaseCategory.categories.keys():
Expand Down Expand Up @@ -283,6 +286,7 @@ def main(parser):
# manipulate sys.argv for default frameworks:
arg_to_parse = mangle_args_for_default_framework(arg_to_parse)
args = parser.parse_args(arg_to_parse)
assume_yes = args.assume_yes

if args.list or args.list_installed or args.list_available:
print(get_frameworks_list_output(args))
Expand Down Expand Up @@ -334,6 +338,7 @@ def main(parser):
pretty_print_versions(outdated_frameworks)
for outdated_framework in outdated_frameworks:
args = parser.parse_args([outdated_framework['category_name'], outdated_framework['framework_name']])
args.assume_yes = assume_yes
CliUI()
run_command_for_args(args)
return
Expand Down

0 comments on commit 95076c9

Please sign in to comment.