diff --git a/winpython/__init__.py b/winpython/__init__.py index a3618f0b..037814ed 100644 --- a/winpython/__init__.py +++ b/winpython/__init__.py @@ -28,6 +28,6 @@ OTHER DEALINGS IN THE SOFTWARE. """ -__version__ = '7.5.20240401' +__version__ = '7.5.20240410' __license__ = __doc__ __project_url__ = 'http://winpython.github.io/' diff --git a/winpython/associate.py b/winpython/associate.py index 247eb108..3ac02004 100644 --- a/winpython/associate.py +++ b/winpython/associate.py @@ -70,10 +70,12 @@ def _get_shortcut_data(target, current=True): return data -def register(target, current=True): +def register(target, current=True, verbose=True): """Register a Python distribution in Windows registry""" root = winreg.HKEY_CURRENT_USER if current else winreg.HKEY_LOCAL_MACHINE + # Creating Registry entries + print(f'Creating WinPython registry entries for {target}') # Extensions winreg.SetValueEx( winreg.CreateKey(root, KEY_C % ".py"), @@ -333,13 +335,15 @@ def register(target, current=True): ) # Create start menu entries for all WinPython launchers + print(f'Creating WinPython menu for all icons in {target}') for path, desc, fname in _get_shortcut_data(target, current=current): - utils.create_shortcut(path, desc, fname) + utils.create_shortcut(path, desc, fname, verbose=verbose) -def unregister(target, current=True): +def unregister(target, current=True, verbose=True): """Unregister a Python distribution in Windows registry""" - # Registry entries + # Removing Registry entries + print(f'Removing WinPython registry entries for {target}') root = winreg.HKEY_CURRENT_USER if current else winreg.HKEY_LOCAL_MACHINE short_version = utils.get_python_infos(target)[0] key_core = (KEY_S1 % short_version) + r"\%s" @@ -391,15 +395,18 @@ def unregister(target, current=True): KEY_S, ): try: - print(key) + if verbose: + print(key) winreg.DeleteKey(root, key) except WindowsError: rootkey = "HKEY_CURRENT_USER" if current else "HKEY_LOCAL_MACHINE" - print( + if verbose: + print( r"Unable to remove %s\%s" % (rootkey, key), file=sys.stderr, ) # remove menu shortcuts + print(f'Removing WinPython menu for all icons in {target}') _remove_start_menu_folder(target, current=current) #for path, desc, fname in _get_shortcut_data(target, current=current): diff --git a/winpython/utils.py b/winpython/utils.py index 0bc28c26..c2a992d7 100644 --- a/winpython/utils.py +++ b/winpython/utils.py @@ -214,7 +214,7 @@ def get_winpython_start_menu_folder(current=True): return str(Path(folder) / 'WinPython') def remove_winpython_start_menu_folder(current=True): - """Create WinPython Start menu folder -- remove it if it already exists""" + """Remove WinPython Start menu folder -- remove it if it already exists""" path = get_winpython_start_menu_folder(current=current) if Path(path).is_dir(): try: @@ -249,6 +249,7 @@ def create_shortcut( workdir="", iconpath="", iconindex=0, + verbose=True, ): """Create Windows shortcut (.lnk file)""" import pythoncom @@ -272,7 +273,8 @@ def create_shortcut( ipf = ilink.QueryInterface(pythoncom.IID_IPersistFile) if not filename.endswith('.lnk'): filename += '.lnk' - print(f'ipf.save *{filename}*') + if verbose: + print(f'create menu *{filename}*') try: ipf.Save(filename, 0) except: @@ -386,7 +388,7 @@ def python_query(cmd, path): """Execute Python command using the Python interpreter located in *path*""" the_exe = get_python_executable(path) # debug2021-09-12 - print(f'"{the_exe}" -c "{cmd}"', ' * ', path) + # print(f'"{the_exe}" -c "{cmd}"', ' * ', path) return exec_shell_cmd(f'"{the_exe}" -c "{cmd}"', path).splitlines()[0] def python_execmodule(cmd, path): diff --git a/winpython/wppm.py b/winpython/wppm.py index 22b65f58..f490263b 100644 --- a/winpython/wppm.py +++ b/winpython/wppm.py @@ -894,7 +894,7 @@ def main(test=False): if theAnswer == "Y": from winpython import associate - associate.register(dist.target) + associate.register(dist.target, verbose=args.verbose) sys.exit() if args.unregisterWinPython: print(unregisterWinPythonHelp) @@ -908,7 +908,7 @@ def main(test=False): if theAnswer == "Y": from winpython import associate - associate.unregister(dist.target) + associate.unregister(dist.target, verbose=args.verbose) sys.exit() elif not args.install and not args.uninstall: args.install = True