Skip to content

Commit

Permalink
- main.py: force curses termination on Windows
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
s-n-g committed Oct 17, 2024
1 parent dd1d40f commit 3f2af22
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 9 deletions.
5 changes: 1 addition & 4 deletions devel/build_install_pyradio.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion devel/unreg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
20 changes: 19 additions & 1 deletion pyradio/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 == ''
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -1410,24 +1413,31 @@ 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 '''
args.force = True
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)
Expand All @@ -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(
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion pyradio/keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions pyradio/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions pyradio/win.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3f2af22

Please sign in to comment.