Skip to content

Commit f21d8c7

Browse files
committed
adding F8 and F9 shortcuts for windows
1 parent b931cc2 commit f21d8c7

14 files changed

+707
-103
lines changed

Changelog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2022-02-14 s-n-g
2+
* version 0.8.9.14 (0.9-beta11)
3+
* fixing typo in player.py
4+
5+
2022-02-13 s-n-g
6+
* version 0.8.9.13 (0.9-beta10)
7+
* fixing #148
8+
* fixing a potential psutil crash
9+
110
2022-01-26 s-n-g
211
* version 0.8.9.12 (0.9-beta9)
312
* Fixing install.py

README.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,15 @@ <h2 id="requirements">Requirements <span style="padding-left: 10px;"><sup style=
143143
<h2 id="changelog">Changelog <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></style></h2>
144144
<pre style="height: 200px;">
145145

146+
2022-02-14 s-n-g
147+
* version 0.8.9.14 (0.9-beta11)
148+
* fixing typo in player.py
149+
150+
2022-02-13 s-n-g
151+
* version 0.8.9.13 (0.9-beta10)
152+
* fixing #148
153+
* fixing a potential psutil crash
154+
146155
2022-01-26 s-n-g
147156
* version 0.8.9.12 (0.9-beta9)
148157
* Fixing install.py

devel/build_install_pyradio

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
#!/bin/bash
22
function help(){
3-
if [[ $(uname -s) = "Darwin" ]] || [[ $(uname -s) = "darwin" ]]; then
4-
echo "Usage: $0 [2/-u]"
5-
else
6-
echo "Usage: $0 [2/-u/--root]"
7-
fi
3+
echo "Usage: $0 [2/-R/--system]"
84
echo "
95
Available options:
10-
2 build using python v. 2.x
11-
-R remove (uninstall) pyradi
12-
--root system wide installation
6+
2 build using python v. 2.x
7+
-R remove (uninstall) pyradi
8+
--system system wide installation
139
1410
If no option is used, will build using Python 3
1511
and will install in your HOME directory
@@ -59,6 +55,17 @@ done < /tmp/pyradio-delete.$$
5955
rm -f /tmp/pyradio-uninstall.$$ /tmp/pyradio-delete.$$ 2>/dev/null
6056
}
6157

58+
59+
function remove_pip_install(){
60+
if [ -z "$TO_USER" ]; then
61+
sudo python -m pip uninstall -y pyradio 2>/dev/null 1>&2
62+
sudo python2 -m pip uninstall -y pyradio 2>/dev/null 1>&2
63+
else
64+
python -m pip uninstall -y pyradio 2>/dev/null 1>&2
65+
python2 -m pip uninstall -y pyradio 2>/dev/null 1>&2
66+
fi
67+
}
68+
6269
function uninstall(){
6370
local user
6471
[ -z "$1" ] && {
@@ -99,6 +106,7 @@ function uninstall(){
99106
}
100107
#set -x
101108
remove_paths
109+
remove_pip_install
102110
echo "PyRadio successfully uninstalled"
103111
}
104112

@@ -206,18 +214,10 @@ do
206214
uninstall
207215
exit
208216
;;
209-
--root)
217+
--system)
210218
unset TO_USER
211219
shift
212220
;;
213-
# --user)
214-
# TO_USER=1
215-
# if [[ $(uname -s) = "Darwin" ]] || [[ $(uname -s) = "darwin" ]]; then
216-
# echo "Parameter --user not supported on this OS"
217-
# exit 1
218-
# fi
219-
# shift
220-
# ;;
221221
2)
222222
[ -z "${TO_PYTHON_FROM_X}" ] && TO_PYTHON=2
223223
shift

devel/build_install_pyradio.bat

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,33 +35,48 @@ IF "%version%" == "6.0" ( GOTO win7exit )
3535
IF "%1"=="" (
3636
CLS
3737
ECHO Installing / Updating python modules
38-
pip install windows-curses --upgrade 1>NUL 2>NUL
38+
pip install --upgrade windows-curses 1>NUL 2>NUL
3939
if %ERRORLEVEL% == 1 (
4040
set ERRPKG=windows-curses
4141
GOTO piperror
4242
)
43-
pip install pywin32 --upgrade 1>NUL 2>NUL
43+
pip install --upgrade pywin32 1>NUL 2>NUL
4444
if %ERRORLEVEL% == 1 (
4545
set ERRPKG=pywin32
4646
GOTO piperror
4747
)
48-
pip install requests --upgrade 1>NUL 2>NUL
48+
pip install --upgrade requests 1>NUL 2>NUL
4949
if %ERRORLEVEL% == 1 (
5050
set ERRPKG=requests
5151
GOTO piperror
5252
)
53-
pip install dnspython --upgrade 1>NUL 2>NUL
53+
pip install --upgrade dnspython 1>NUL 2>NUL
5454
if %ERRORLEVEL% == 1 (
5555
set ERRPKG=dnspython
5656
GOTO piperror
5757
)
58-
pip install psutil --upgrade 1>NUL 2>NUL
58+
pip install --upgrade psutil 1>NUL 2>NUL
5959
if %ERRORLEVEL% == 1 (
6060
set ERRPKG=psutil
6161
GOTO piperror
6262
)
63+
pip install --upgrade patool 1>NUL 2>NUL
64+
if %ERRORLEVEL% == 1 (
65+
set ERRPKG=patool
66+
GOTO piperror
67+
)
68+
pip install --upgrade psutil 1>NUL 2>NUL
69+
if %ERRORLEVEL% == 1 (
70+
set ERRPKG=pyunpack
71+
GOTO piperror
72+
)
73+
pip install --upgrade wheel 1>NUL 2>NUL
74+
if %ERRORLEVEL% == 1 (
75+
set ERRPKG=wheel
76+
GOTO piperror
77+
)
6378
)
64-
79+
goto START
6580
IF '%1'=='ELEV' ( GOTO START ) ELSE ( ECHO Running elevated in a different window)
6681
ECHO >>DOPAUSE
6782

@@ -149,7 +164,7 @@ REM ECHO ###############################################
149164
REM GOTO endofscript
150165

151166
:install
152-
%PROGRAM% -m pip install . 2>NUL
167+
%PROGRAM% -m pip install .
153168
IF %ERRORLEVEL% == 0 GOTO installhtml
154169
:installationerror
155170
ECHO.
@@ -165,7 +180,7 @@ GOTO endofscript
165180

166181
:installhtml
167182
IF "%NO_DEV%"=="1" (
168-
DEL DEV
183+
DEL DEV 1>NUL 2>NUL
169184
CD pyradio
170185
DEL config.py
171186
RENAME config.py.dev config.py
@@ -181,9 +196,19 @@ python devel\reg.py
181196
ECHO *** HTML files copyed to "%APPDATA%\pyradio\help"
182197

183198

199+
:: Update lnk file
200+
CD pyradio
201+
python -c "from win import create_pyradio_link; create_pyradio_link()"
202+
CD ..
203+
184204
:: Install lnk file
185-
IF NOT EXIST %DESKTOP%\PyRadio.lnk GOTO linkcopy
186-
ECHO === Dekstop Shortcut already exists
205+
ECHO *** Installing Dekstop Shortcut
206+
COPY /Y %APPDATA%\pyradio\help\*.lnk %DESKTOP% >NUL
207+
208+
:: Clean up
209+
CD pyradio
210+
python -c "from win import clean_up; clean_up()"
211+
CD ..
187212
GOTO toend
188213

189214
:piperror
@@ -212,12 +237,6 @@ ECHO.
212237
ECHO.
213238
GOTO endnopause
214239

215-
:linkcopy
216-
ECHO *** Installing Dekstop Shortcut
217-
COPY %APPDATA%\pyradio\help\*.lnk %DESKTOP% >NUL
218-
GOTO toend
219-
220-
221240
:displayhelp
222241
ECHO Build and install PyRadio
223242
ECHO.

pyradio/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
" pyradio -- Console radio player. "
22

3-
version_info = (0, 8, 9, 12)
3+
version_info = (0, 8, 9, 14)
44

55
# Application state:
66
# New stable version: ''

pyradio/config.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,12 @@ class PyRadioConfig(PyRadioStations):
11381138
PROGRAM_UPDATE = False
11391139
current_pyradio_version = None
11401140

1141+
''' Windows manage players trigger '''
1142+
MANAGE_PLAYERS = False
1143+
1144+
''' Windows print EXE location trigger '''
1145+
PRINT_PATHS = False
1146+
11411147
def __init__(self):
11421148
self.backup_player_params = None
11431149
self._profile_name = 'pyradio'
@@ -1432,7 +1438,7 @@ def get_pyradio_version(self):
14321438
if so, revision will be shown along with the version
14331439
'''
14341440
# if revision is not 0
1435-
git_description = ''
1441+
git_description = 'PyRadio 0.8.9.14'
14361442
if git_description:
14371443
if git_description.endswith('-git') or \
14381444
git_description.endswith('-sng') or \

pyradio/install.py

Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
import platform
77
import json
88
from time import sleep
9+
import site
910
try:
10-
from os.path import curdir
11+
from os.path import curdir, exists
1112
import ctypes
1213
import win32api
1314
import win32ui
@@ -78,6 +79,40 @@ def print_python3():
7879
def print_trying_to_install():
7980
print(' trying to install for')
8081

82+
def find_pyradio_win_exe():
83+
''' find pyradio EXE files
84+
85+
Return (system_exe, user_exe)
86+
'''
87+
exe = [None, None]
88+
for a_path in site.getsitepackages():
89+
if a_path.split(os.sep)[-1].startswith('Python'):
90+
py_with_ver = a_path.split(os.sep)[-1]
91+
an_exe = os.path.join(a_path, 'Scripts' , 'pyradio.exe')
92+
if os.path.exists(an_exe):
93+
exe[0] = an_exe
94+
an_exe = os.path.join(site.getuserbase(), py_with_ver, 'Scripts' , 'pyradio.exe')
95+
# print('an_exe: {}'.format(an_exe))
96+
if os.path.exists(an_exe):
97+
exe[1] = an_exe
98+
# print('exe: {}'.format(exe))
99+
return exe
100+
101+
def fix_pyradio_win_exe():
102+
exe = find_pyradio_win_exe()
103+
if exe[0]:
104+
a_path = os.getenv('PROGRAMFILES(x86)')
105+
if a_path:
106+
exe[0] = exe[0].replace(a_path, '%PROGRAMFILES(x86)%')
107+
a_path = os.getenv('PROGRAMFILES')
108+
if a_path:
109+
exe[0] = exe[0].replace(a_path, '%PROGRAMFILES%')
110+
if exe[1]:
111+
a_path = os.getenv('APPDATA')
112+
if a_path:
113+
exe[1] = exe[1].replace(a_path, '%APPDATA%')
114+
return exe
115+
81116
def is_pyradio_user_installed():
82117
if platform.system().lower().startswith('darwin'):
83118
return False
@@ -492,7 +527,7 @@ def remove_pyradio(self, win_open_dir=False):
492527
print('Please report this at http://github.com/coderholic/pyradio/issues\n')
493528
sys.exit(1)
494529

495-
def update_or_uninstall_on_windows(self, mode='update', from_pyradio=False):
530+
def update_or_uninstall_on_windows(self, mode='update', from_pyradio=False, first_install=False):
496531
# Params:
497532
# mode: the type of zip file to download
498533
# from_pyradio: True if executed by "pyradio -d"
@@ -526,9 +561,9 @@ def update_or_uninstall_on_windows(self, mode='update', from_pyradio=False):
526561
with open(bat, "w") as b:
527562
b.write('@ECHO OFF\n')
528563
b.write('CLS\n')
529-
b.write('python -m pip install requests --upgrade 1>NUL 2>NUL\n')
564+
b.write('python -m pip install --upgrade requests 1>NUL 2>NUL\n')
530565
b.write('if %ERRORLEVEL% == 1 GOTO downloaderror\n')
531-
b.write('python -m pip install wheel --upgrade 1>NUL 2>NUL\n')
566+
b.write('python -m pip install --upgrade wheel 1>NUL 2>NUL\n')
532567
b.write('if %ERRORLEVEL% == 1 GOTO downloaderror\n')
533568
# b.write('PAUSE\n')
534569
if mode.startswith('update'):
@@ -540,6 +575,10 @@ def update_or_uninstall_on_windows(self, mode='update', from_pyradio=False):
540575
b.write('if %ERRORLEVEL% == 1 GOTO downloaderror\n')
541576
b.write('cd "' + os.path.join(self._dir, self.ZIP_DIR[self._package]) + '"\n')
542577
b.write('devel\\build_install_pyradio.bat -U\n')
578+
if first_install:
579+
b.write('CD pyradio\n')
580+
b.write('python -c "from win import download_player; download_player(package=0, do_not_exit=True)"\n')
581+
b.write('CD ..\n')
543582
b.write('GOTO endofscript\n')
544583
else:
545584
b.write('COPY "{}" uninstall.py 1>NUL\n'.format(os.path.abspath(__file__)))
@@ -839,6 +878,9 @@ def _do_it(self, mode='update'):
839878

840879

841880
if __name__ == '__main__':
881+
exe = find_pyradio_win_exe()
882+
print(exe)
883+
sys.exit()
842884
# l=get_github_long_description(use_sng_repo=True)
843885
# print(l)
844886
# print(get_devel_version())
@@ -987,21 +1029,28 @@ def _do_it(self, mode='update'):
9871029

9881030
''' Installation!!! '''
9891031
if platform.system().lower().startswith('win'):
1032+
exe = find_pyradio_win_exe()
1033+
first_install = False
1034+
if exe == [None, None]:
1035+
first_install = True
9901036
if not args.force:
1037+
# is pyradio.exe in PATH
9911038
ret = subprocess.call('pyradio -h 1>NUL 2>NUL', shell=True)
992-
if ret == 0:
993-
print('PyRadio is already installed.\n')
994-
sys.exit(1)
1039+
if ret == 0 or not first_install:
1040+
print('PyRadio is already installed.\n')
1041+
sys.exit(1)
9951042
for a_module in (
9961043
'windows-curses',
9971044
'pywin32',
9981045
'dnspython',
9991046
'requests',
10001047
'psutil',
1048+
'patool',
1049+
'pyunpack',
10011050
'wheel',
10021051
):
10031052
print('Checking module: ' + a_module + ' ...')
1004-
ret = subprocess.call('python -m pip install ' + a_module + ' --upgrade',
1053+
ret = subprocess.call('python -m pip install --upgrade ' + a_module,
10051054
stdout=subprocess.DEVNULL,
10061055
stderr=subprocess.DEVNULL)
10071056
if ret != 0:
@@ -1024,12 +1073,15 @@ def _do_it(self, mode='update'):
10241073
else:
10251074
print('Please make sure your internet connection is up and try again')
10261075
sys.exit(1)
1076+
10271077
uni = PyRadioUpdateOnWindows(
10281078
package=package,
10291079
github_long_description=github_long_description,
10301080
python_version_to_use=python_version_to_use
10311081
)
1032-
uni.update_or_uninstall_on_windows(mode='update-open')
1082+
uni.update_or_uninstall_on_windows(
1083+
mode='update-open',
1084+
first_install=first_install)
10331085
while not os.path.isfile(os.path.join(uni._dir, 'update.bat')):
10341086
pass
10351087
os.chdir(uni._dir)

0 commit comments

Comments
 (0)