-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelper.py
29 lines (26 loc) · 817 Bytes
/
helper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import yaml
import logging
import sys, os
logger = logging.getLogger(__name__)
# Load and test config.yml
try:
config = yaml.safe_load(open('config.yml'))
log_level = config['general']['loglevel']
token = config['general']['token']
threads = config['general']['threads']
tmp_dir = os.path.join(os.path.abspath(config['general']['tmpdir']),'')
ncmapi = config['netease']['neteaseapi']
ncmuserid = config['netease']['userid']
except Exception as e:
logger.critical("config.yml is not valid!")
logger.debug(e)
sys.exit()
# Check if temporary directory is writable
try:
if not os.path.exists(tmp_dir):
os.makedirs(tmp_dir)
os.access(tmp_dir, os.W_OK)
except Exception as e:
logger.critical("Temp directory not writable!!!")
logger.debug(e)
sys.exit()