From 3f2af2207e8c44b5f44a1e9bfe2d82a032cd2f86 Mon Sep 17 00:00:00 2001 From: Spiros Georgaras Date: Thu, 17 Oct 2024 12:20:40 +0300 Subject: [PATCH] - main.py: force curses termination on Windows - install.py: fixing a bug and adding temporary debug info - build_install_pyradio.bat: actuall uninstall pyradio after answering no to question to delete user files - unreg.py: fixing a SyntaxWarning on rkey (Windows) - win.py: fixing a couple of bugs - keyboard.py: fix ^Y curses code --- devel/build_install_pyradio.bat | 5 +---- devel/unreg.py | 2 +- pyradio/install.py | 20 +++++++++++++++++++- pyradio/keyboard.py | 2 +- pyradio/main.py | 4 ++++ pyradio/win.py | 4 ++-- 6 files changed, 28 insertions(+), 9 deletions(-) diff --git a/devel/build_install_pyradio.bat b/devel/build_install_pyradio.bat index 360f578a..e6940be2 100755 --- a/devel/build_install_pyradio.bat +++ b/devel/build_install_pyradio.bat @@ -246,10 +246,7 @@ ECHO User files are under "%APPDATA%\pyradio" SET /p ANS="Do you want to remove them (y/n)?: " :: ECHO %ANS% IF "%ANS%" == "y" GOTO :addtobat -IF "%ANS%" == "n" ( - IF EXIST "DOPAUSE" ( GOTO endofscript ) - GOTO endnopause -) +IF "%ANS%" == "n" GOTO :addtobat GOTO :readit :addtobat diff --git a/devel/unreg.py b/devel/unreg.py index f16b6b63..a1e74be6 100644 --- a/devel/unreg.py +++ b/devel/unreg.py @@ -2,7 +2,7 @@ import winreg hkey = winreg.HKEY_CURRENT_USER -rkey = 'Software\Microsoft\Windows\CurrentVersion\Run' +rkey = r'Software\Microsoft\Windows\CurrentVersion\Run' rhandle = winreg.OpenKey(hkey, rkey, 0, winreg.KEY_ALL_ACCESS) diff --git a/pyradio/install.py b/pyradio/install.py index f6575085..7e0730b1 100644 --- a/pyradio/install.py +++ b/pyradio/install.py @@ -1080,7 +1080,6 @@ def _change_git_discription_in_config_py(self): def _download_pyradio(self): os.chdir(self._dir) - VERSION == '' if self._package == 0: try: VERSION == '' @@ -1120,6 +1119,7 @@ def _download_pyradio(self): with open(os.path.join(self._dir, self.ZIP_DIR[self._package], 'DEV'), 'w', encoding='utf-8'): pass # input('Please update files as needed. Then press ENTER to continue...') + sys.exit() def _mkdir(self, name, dir_exist_function=None, _permission_error_function=None): if os.path.isdir(name): @@ -1387,9 +1387,11 @@ def _do_it(self, mode='update'): sys.exit(1) ''' download official release ''' + print('-- start') package = 0 tag_name = github_long_description = None if args.sng_master: + print('== sng-master') ''' sng master ''' args.force = True package = 1 @@ -1400,6 +1402,7 @@ def _do_it(self, mode='update'): # github_long_description = github_long_description.replace('-', '-r', 1) # github_long_description += '-sng' elif args.sng_devel: + print('== sng-devel') '''' sng devel ''' args.force = True package = 2 @@ -1410,6 +1413,7 @@ def _do_it(self, mode='update'): # github_long_description = github_long_description.replace('-', '-r', 1) # github_long_description += '-sng-dev' elif args.devel: + print('== devel') ''' official devel ''' package = 3 ''' go back to master ''' @@ -1417,17 +1421,23 @@ def _do_it(self, mode='update'): package = 0 VERSION = get_github_tag() elif args.master or args.git: + print('== master / devel') ''' official master ''' args.force = True package = 4 VERSION, github_long_description = get_github_long_description() else: + print('== normal') VERSION = get_github_tag() if VERSION is None: VERSION = PyRadioInstallPyReleaseVersion + print(f'== {package = }') + if args.uninstall: + print('** uninstall') + print(f'** {package = }') if platform.system().lower().startswith('win'): ''' ok, create BAT file on Windows''' uni = PyRadioUpdateOnWindows(package=package) @@ -1438,6 +1448,8 @@ def _do_it(self, mode='update'): uni.remove_pyradio() sys.exit() elif args.update: + print('** update') + print(f'** {package = }') if platform.system().lower().startswith('win'): ''' ok, create BAT file on Windows''' upd = PyRadioUpdateOnWindows( @@ -1459,6 +1471,8 @@ def _do_it(self, mode='update'): upd.update_pyradio() sys.exit() elif args.do_uninstall: + print('** do uninstall') + print(f'** {package = }') ''' coming from uninstall BAT file on Windows''' uni = PyRadioUpdateOnWindows( package=package, @@ -1467,6 +1481,8 @@ def _do_it(self, mode='update'): uni.remove_pyradio() sys.exit() elif args.do_update: + print('** do update') + print(f'** {package = }') ''' coming from update BAT file on Windows''' upd = PyRadioUpdateOnWindows( package=package, @@ -1476,6 +1492,8 @@ def _do_it(self, mode='update'): upd.update_pyradio() sys.exit() + print('** installation') + print(f'** {package = }') ''' Installation!!! ''' if platform.system().lower().startswith('win'): exe = find_pyradio_win_exe() diff --git a/pyradio/keyboard.py b/pyradio/keyboard.py index 48dae670..7467006b 100644 --- a/pyradio/keyboard.py +++ b/pyradio/keyboard.py @@ -131,7 +131,7 @@ kbkey_orig['rb_p_prev'] = ( ord('[') , 'Go to previous search results page: ') kbkey_orig['rb_h_next'] = ( curses.ascii.SO , 'Go to next search item: ') # default: ^N kbkey_orig['rb_h_prev'] = ( curses.ascii.DLE , 'Go to previous search item: ') # default: ^P -kbkey_orig['rb_h_add'] = ( curses.ascii.ENQ , 'Add search item: ') # default: ^Y +kbkey_orig['rb_h_add'] = ( curses.ascii.EM , 'Add search item: ') # default: ^Y kbkey_orig['rb_h_del'] = ( curses.ascii.CAN , 'Delete search item: ') # default: ^X kbkey_orig['rb_h_def'] = ( curses.ascii.STX , 'Make item default: ') # default: ^B kbkey_orig['rb_h_0'] = ( curses.ascii.ACK , 'Go to template (item 0): ') # default: ^F diff --git a/pyradio/main.py b/pyradio/main.py index b104cf2f..b263d53a 100644 --- a/pyradio/main.py +++ b/pyradio/main.py @@ -945,6 +945,10 @@ def shell(): https://github.com/zephyrproject-rtos/windows-curses/issues/50#issuecomment-1840485627 ''' pyradio.setup(_win_python_3_12()) + try: + curses.endwin() + except: + pass else: curses.wrapper(pyradio.setup) diff --git a/pyradio/win.py b/pyradio/win.py index f7f58c16..3a5050a6 100644 --- a/pyradio/win.py +++ b/pyradio/win.py @@ -231,7 +231,7 @@ def get_latest_x86_64_mplayer_url(): if n.startswith('r'): rev = n.split('"')[0][1:] try: - r = int(rev) + int(rev) except ValueError: return None existing = zurl[1].split('-svn-')[1].split('-')[0] @@ -355,7 +355,7 @@ def download_player(output_folder=None, package=1, do_not_exit=False): along with the archive named "{0}".'''.format(basename(out_file))) if player_name == 'mpv': if exists(join(output_folder, 'mpv')): - print(''' Please extract the archive in the "[rev]mpv[/red]" folder + print(''' Please extract the archive in the "[red]mpv[/red]" folder (overwriting any existing files).''') else: print(''' Please create a folder named "[red]mpv[/red]" and extract