Skip to content

Commit afbeaa4

Browse files
committed
version 0.8.9.33 (0.9-beta30)
adding message for module netifaces module not found
1 parent 284b707 commit afbeaa4

File tree

8 files changed

+47
-6
lines changed

8 files changed

+47
-6
lines changed

Changelog

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
(python2 not affected)
77
* fixing Windows lnk installation
88
* editing gruvbox themes
9+
* adding "Border" parameter to themes as per #173
10+
(not used by default in any of the existing themes)
911
* updating docs, creating pyradio_server man page
1012

1113
2022-12-09 s-n-g

README.html

+2
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ <h2 id="changelog">Changelog <span style="padding-left: 10px;"><sup style="font-
200200
(python2 not affected)
201201
* fixing Windows lnk installation
202202
* editing gruvbox themes
203+
* adding "Border" parameter to themes as per #173
204+
(not used by default in any of the existing themes)
203205
* updating docs, creating pyradio_server man page
204206

205207
2022-12-09 s-n-g

build.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ <h3 id="linux">Linux</h3>
9191
<li><em>python-requests</em></li>
9292
<li><em>python-dnspython</em></li>
9393
<li><em>python-psutil</em></li>
94+
<li><em>python-netifaces</em></li>
9495
<li><em>sed</em></li>
9596
<li>any one of <em>MPV</em>, <em>MPlayer</em> and/or <em>VLC</em>.</li>
9697
</ol>
@@ -115,7 +116,7 @@ <h4 id="rasberry-pi-installation">Rasberry Pi installation</h4>
115116
</ol>
116117
<h3 id="macos">macOS</h3>
117118
<p>First thing you do is install python dependencies (assuming python 3 is installed):</p>
118-
<pre>python3 -m pip install --upgrade pip wheel setuptools requests dnspython psutil</pre>
119+
<pre>python3 -m pip install --upgrade pip wheel setuptools requests dnspython psutil netifaces</pre>
119120
<p>Everything else you need to install and run <strong>pyradio</strong> is available on <a target="_blank" href="https://github.com/Homebrew/homebrew">Homebrew</a>. If you haven’t already downloaded its client, go ahead and do it.</p>
120121
<p>Open a <strong>terminal</strong> and type:</p>
121122
<pre>/usr/bin/ruby -e &quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&quot;</pre>

build.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ Use your distribution method to install
5858
4. *python-requests*
5959
5. *python-dnspython*
6060
6. *python-psutil*
61+
6. *python-netifaces*
6162
7. *sed*
6263
8. any one of *MPV*, *MPlayer* and/or *VLC*.
6364

@@ -98,7 +99,7 @@ If installing on a Rasberry Pi, there are a couple of things you should be aware
9899

99100
First thing you do is install python dependencies (assuming python 3 is installed):
100101

101-
python3 -m pip install --upgrade pip wheel setuptools requests dnspython psutil
102+
python3 -m pip install --upgrade pip wheel setuptools requests dnspython psutil netifaces
102103

103104
Everything else you need to install and run **pyradio** is available on [Homebrew](https://github.com/Homebrew/homebrew). If you haven't already downloaded its client, go ahead and do it.
104105

pyradio/config.py

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import requests
2626
except:
2727
HAS_REQUESTS = False
28+
2829
from .log import Log
2930
HAS_DNSPYTHON = True
3031
try:

pyradio/radio.py

+28
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ def __init__(self, pyradio_config,
281281
req_player='',
282282
theme='',
283283
force_update=''):
284+
self._no_netifaces = False
284285
self._current_selection = 0
285286
self._force_print_all_lines = False
286287
self._system_asked_to_terminate = False
@@ -378,6 +379,7 @@ def __init__(self, pyradio_config,
378379
self.ws.EDIT_STATION_URL_ERROR: self._print_editor_url_error,
379380
self.ws.PY2_EDITOR_ERROR: self._print_py2_editor_error,
380381
self.ws.REQUESTS_MODULE_NOT_INSTALLED_ERROR: self._print_requests_not_installed_error,
382+
self.ws.NETIFACES_MODULE_NOT_INSTALLED_ERROR: self._print_netifaces_not_installed_error,
381383
self.ws.DNSPYTHON_MODULE_NOT_INSTALLED_ERROR: self._print_dnspython_not_installed_error,
382384
self.ws.CLEAR_REGISTER_MODE: self._print_clear_register,
383385
self.ws.CLEAR_ALL_REGISTERS_MODE: self._print_clear_all_registers,
@@ -992,6 +994,9 @@ def refreshBody(self, start=0):
992994
self._show_theme_not_supported()
993995
elif self._cnf.user_param_id == -1:
994996
self._print_user_parameter_error()
997+
elif self._no_netifaces:
998+
self._no_netifaces = False
999+
self._print_netifaces_not_installed_error()
9951000
# elif not self._cnf.use_themes:
9961001
# self._show_no_themes()
9971002

@@ -1026,6 +1031,8 @@ def refreshNoDepencency(self):
10261031
self.bodyWin.addstr('dnspython', curses.color_pair(4))
10271032
self.bodyWin.addstr(14,1, ' 3. ', curses.color_pair(5))
10281033
self.bodyWin.addstr('psutil ', curses.color_pair(4))
1034+
self.bodyWin.addstr(15,1, ' 3. ', curses.color_pair(5))
1035+
self.bodyWin.addstr('netifaces', curses.color_pair(4))
10291036
self.outerBodyWin.refresh()
10301037
self.bodyWin.refresh()
10311038

@@ -3213,6 +3220,23 @@ def _print_dnspython_not_installed_error(self):
32133220
prompt=' Press any key ',
32143221
is_message=True)
32153222

3223+
def _print_netifaces_not_installed_error(self):
3224+
txt = '''
3225+
Module "|netifaces|" not found!
3226+
3227+
In order to use the |Remote Control Server|, the
3228+
"|netifaces|" module must be installed.
3229+
3230+
Exit |PyRadio| now, install the module (named
3231+
|python-netifaces| or |python{}-netifaces|) and try
3232+
executing |PyRadio| again.
3233+
'''
3234+
self._show_help(txt.format(python_version[0]),
3235+
self.ws.NETIFACES_MODULE_NOT_INSTALLED_ERROR,
3236+
caption=' Module Error ',
3237+
prompt=' Press any key ',
3238+
is_message=True)
3239+
32163240
def _print_requests_not_installed_error(self):
32173241
txt = '''
32183242
Module "|requests|" not found!
@@ -9256,6 +9280,10 @@ def _start_remote_control_server(self):
92569280
'/html_init': self._html_init_song_title,
92579281
}
92589282
)
9283+
if not self._remote_control_server.has_netifaces:
9284+
self._remote_control_server = None
9285+
self._no_netifaces = True
9286+
return
92599287
self._remote_control_server_thread = threading.Thread(
92609288
target=self._remote_control_server.start_remote_control_server,
92619289
args=(

pyradio/server.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# https://stackoverflow.com/questions/10114224/how-to-properly-send-http-response-with-python-using-socket-library-only
21
import socket
32
import logging
43
from os.path import basename
@@ -7,15 +6,18 @@
76
from time import sleep
87
from .simple_curses_widgets import SimpleCursesLineEdit
98

10-
119
PY2 = version_info[0] == 2
1210
logger = logging.getLogger(__name__)
1311

1412
import locale
1513
locale.setlocale(locale.LC_ALL, "")
1614

17-
if not platform.lower().startswith('win'):
18-
import netifaces
15+
HAS_NETIFACES = True
16+
try:
17+
if not platform.lower().startswith('win'):
18+
import netifaces
19+
except:
20+
HAS_NETIFACES = False
1921

2022
class IPs(object):
2123
def __init__(self, fetch_public_ip=False):
@@ -463,6 +465,7 @@ class PyRadioServer(object):
463465
}
464466

465467
def __init__(self, bind_ip, bind_port, commands):
468+
self.has_netifaces = HAS_NETIFACES
466469
self._bind_ip = bind_ip
467470
if bind_ip.lower() == 'localhost':
468471
self._bind_ip = '127.0.0.1'

pyradio/window_stack.py

+3
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ class Window_Stack_Constants(object):
128128
REMOTE_CONTROL_SERVER_START_ERROR_MODE = 318
129129
REMOTE_CONTROL_SERVER_DEAD_ERROR_MODE = 319
130130
REMOTE_CONTROL_SERVER_ERROR_MODE = 320
131+
NETIFACES_MODULE_NOT_INSTALLED_ERROR = 209
131132
THEME_MODE = 400
132133
HISTORY_EMPTY_NOTIFICATION = 500
133134
STATIONS_INTEGRATED_MODE = 501
@@ -205,6 +206,7 @@ class Window_Stack_Constants(object):
205206
EDIT_STATION_URL_ERROR: 'EDIT_STATION_URL_ERROR',
206207
PY2_EDITOR_ERROR: 'PY2_EDITOR_ERROR',
207208
REQUESTS_MODULE_NOT_INSTALLED_ERROR: 'REQUESTS_MODULE_NOT_INSTALLED_ERROR',
209+
NETIFACES_MODULE_NOT_INSTALLED_ERROR: 'NETIFACES_MODULE_NOT_INSTALLED_ERROR',
208210
UNKNOWN_BROWSER_SERVICE_ERROR: 'UNKNOWN_BROWSER_SERVICE_ERROR',
209211
SERVICE_CONNECTION_ERROR: 'SERVICE_CONNECTION_ERROR',
210212
PLAYER_CHANGED_INFO_MODE: 'PLAYER_CHANGED_INFO_MODE',
@@ -313,6 +315,7 @@ class Window_Stack_Constants(object):
313315
EDIT_STATION_URL_ERROR,
314316
PY2_EDITOR_ERROR,
315317
REQUESTS_MODULE_NOT_INSTALLED_ERROR,
318+
NETIFACES_MODULE_NOT_INSTALLED_ERROR,
316319
DNSPYTHON_MODULE_NOT_INSTALLED_ERROR,
317320
UNKNOWN_BROWSER_SERVICE_ERROR,
318321
SERVICE_CONNECTION_ERROR,

0 commit comments

Comments
 (0)