|
@@ -2,11 +2,11 @@ import logging
|
|
import os
|
|
import os
|
|
|
|
|
|
import yaml
|
|
import yaml
|
|
|
|
+from ycast import generic
|
|
|
|
|
|
-VAR_PATH = os.path.expanduser("~") + '/.ycast'
|
|
|
|
MAX_ENTRIES = 15
|
|
MAX_ENTRIES = 15
|
|
|
|
|
|
-config_file = VAR_PATH + '/recently.yml'
|
|
|
|
|
|
+recently_file = generic.get_var_path() + '/recently.yml'
|
|
|
|
|
|
|
|
|
|
def signal_station_selected(name, url, icon):
|
|
def signal_station_selected(name, url, icon):
|
|
@@ -44,20 +44,20 @@ def set_stations_yaml(heared_stations):
|
|
return None
|
|
return None
|
|
|
|
|
|
try:
|
|
try:
|
|
- with open(config_file, 'w') as f:
|
|
|
|
|
|
+ with open(recently_file, 'w') as f:
|
|
f.writelines(heared_stations)
|
|
f.writelines(heared_stations)
|
|
- logging.info("File written '%s'", config_file)
|
|
|
|
|
|
+ logging.info("File written '%s'", recently_file)
|
|
|
|
|
|
except Exception as ex:
|
|
except Exception as ex:
|
|
- logging.error("File not written '%s': %s", config_file, ex)
|
|
|
|
|
|
+ logging.error("File not written '%s': %s", recently_file, ex)
|
|
|
|
|
|
|
|
|
|
def get_stations_list():
|
|
def get_stations_list():
|
|
try:
|
|
try:
|
|
- with open(config_file, 'r') as f:
|
|
|
|
|
|
+ with open(recently_file, 'r') as f:
|
|
heared_stations = f.readlines()
|
|
heared_stations = f.readlines()
|
|
except FileNotFoundError:
|
|
except FileNotFoundError:
|
|
- logging.warning("File not found '%s' not found", config_file)
|
|
|
|
|
|
+ logging.warning("File not found '%s' not found", recently_file)
|
|
return []
|
|
return []
|
|
except yaml.YAMLError as e:
|
|
except yaml.YAMLError as e:
|
|
logging.error("Station configuration format error: %s", e)
|
|
logging.error("Station configuration format error: %s", e)
|
|
@@ -67,10 +67,10 @@ def get_stations_list():
|
|
|
|
|
|
def get_recently_stations_yaml():
|
|
def get_recently_stations_yaml():
|
|
try:
|
|
try:
|
|
- with open(config_file, 'r') as f:
|
|
|
|
|
|
+ with open(recently_file, 'r') as f:
|
|
my_stations = yaml.safe_load(f)
|
|
my_stations = yaml.safe_load(f)
|
|
except FileNotFoundError:
|
|
except FileNotFoundError:
|
|
- logging.error("Station configuration '%s' not found", config_file)
|
|
|
|
|
|
+ logging.error("Station configuration '%s' not found", recently_file)
|
|
return None
|
|
return None
|
|
except yaml.YAMLError as e:
|
|
except yaml.YAMLError as e:
|
|
logging.error("Station configuration format error: %s", e)
|
|
logging.error("Station configuration format error: %s", e)
|