refaktor to use workingdirectory

This commit is contained in:
Thomas Hanika 2022-01-31 22:27:16 +01:00
parent 9eefaa01e6
commit 1338430f27
6 changed files with 44 additions and 20 deletions

View file

@ -123,7 +123,7 @@ You can redirect all traffic destined for the original request URL (e.g. `radioy
__Attention__: Do not rewrite the requests transparently. YCast expects the complete URL (i.e. including `/ycast` or `/setupapp`). It also need an intact `Host` header; so if you're proxying YCast you need to pass the original header on. For Nginx, this can be accomplished with `proxy_set_header Host $host;`.
In case you are using (or plan on using) Nginx to proxy requests, have a look at [this example](examples/nginx-ycast.conf.example).
This can be used together with [this systemd service example](examples/ycast.service.example) for a fully functional deployment.
This can be used together with [this systemd service example](examples/ycast.service.example_ycast) for a fully functional deployment.
#### With WSGI

View file

@ -1,12 +0,0 @@
[Unit]
Description=YCast internet radio service
After=network.target
[Service]
Type=simple
User=ycast
Group=ycast
ExecStart=/usr/bin/python3 -m ycast -l 127.0.0.1 -p 8010
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,15 @@
[Unit]
Description=YCast internet radio service
After=network.target
[Service]
Type=simple
WorkingDirectory=/var/www/ycast
StandardOutput=file:/var/www/ycast/service.log
StandardError=file:/var/www/ycast/ycast.log
Restart=always
RestartSec=130
ExecStart=/usr/bin/python3 -m ycast -c /var/www/ycast/stations.yml -d
[Install]
WantedBy=multi-user.target

View file

@ -0,0 +1,15 @@
[Unit]
Description=YCast internet radio service
After=network.target
[Service]
Type=simple
User=ycast
Group=ycast
WorkingDirectory=/home/ycast
StandardOutput=file:/home/ycast/service.log
StandardError=file:/home/ycast/ycast.log
ExecStart=/usr/bin/python3 -m ycast -l 127.0.0.1 -p 8010 -d -c /home/ycast/.ycast/stations.yml
[Install]
WantedBy=multi-user.target

View file

@ -4,7 +4,7 @@ import hashlib
import yaml
USER_AGENT = 'YCast'
VAR_PATH = os.path.expanduser("~") + '/.ycast'
VAR_PATH = '.ycast'
CACHE_PATH = VAR_PATH + '/cache'

View file

@ -23,11 +23,15 @@ def init_filter():
count_hit = 0
filter_dictionary = generic.read_yaml_file(generic.get_var_path() + '/filter.yml')
if filter_dictionary:
white_list = filter_dictionary['whitelist']
black_list = filter_dictionary['blacklist']
else:
white_list = {'lastcheckok': 1}
black_list = {}
if 'whitelist' in filter_dictionary:
white_list = filter_dictionary['whitelist']
else:
white_list = {'lastcheckok': 1}
if 'blacklist' in filter_dictionary:
black_list = filter_dictionary['blacklist']
else:
black_list = {}
filter_dictionary = {'whitelist': white_list, 'blacklist': black_list}
generic.write_yaml_file(generic.get_var_path() + '/filter.yml', filter_dictionary)
@ -111,7 +115,9 @@ def check_station(station_json):
def get_limit(param_name, default):
global filter_dictionary
filter_dictionary = generic.read_yaml_file(generic.get_var_path() + '/filter.yml')
tempdict = generic.read_yaml_file(generic.get_var_path() + '/filter.yml')
if tempdict is not None:
filter_dictionary = tempdict
limits_dict = {}
if LIMITS_NAME in filter_dictionary:
limits_dict = filter_dictionary[LIMITS_NAME]