-
Notifications
You must be signed in to change notification settings - Fork 7
/
config.py
73 lines (60 loc) · 2.07 KB
/
config.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import os
CHECK_INTERVAL = 3600 # dload feed once per hour
### You sholdn't need to edit below here ###
base_dir = os.path.dirname(os.path.abspath( __file__ ))
data_dir = os.path.join(base_dir, "data")
BASE_HREF_FILE = os.path.join(data_dir, 'base_href')
# TODO: improve error handling for local file setup.
BASE_HREF = "/"
if os.path.exists(BASE_HREF_FILE):
with open (BASE_HREF_FILE, 'r') as FILE:
BASE_HREF = FILE.readline().strip()
if not BASE_HREF.endswith('/'):
BASE_HREF += '/'
OUTPUT_DIR = os.path.join(base_dir, "www")
VERSION = "2.1.0"
DATA_FORMAT_VERSION = "0.1.0"
MAX_ENTRIES = 100
FEED_TIMEOUT = 100
# calculate value of domain here
# be nice. handle errors
opt={'website_name':"Planeteria",
'title':"Planeteria",
'generator':"Planeteria %s" % VERSION,
'generator_uri':"http://planeteria.org/copyright.html",
'force_check': False,
'new_planet_dir':os.path.join(base_dir, "new_planet_skel"),
'base_dir':base_dir,
'log_dir':os.path.join(base_dir, "log"),
'base_href':BASE_HREF,
# Set domain to the precomputed value
'domain':BASE_HREF.split("//")[1],
'data_dir':data_dir,
'output_dir':OUTPUT_DIR,
'check_interval':CHECK_INTERVAL,
'version':VERSION,
'data_format_version':DATA_FORMAT_VERSION,
'check_interval':CHECK_INTERVAL,
'max_entries':MAX_ENTRIES,
}
#opt.update(locals())
try:
os.makedirs(opt['log_dir'])
except OSError:
pass
import logging
logger = logging.getLogger('planeteria')
logger.setLevel(logging.DEBUG)
fh = logging.FileHandler(os.path.join(opt['log_dir'], 'planeteria.log'), encoding = "UTF-8")
fh.set_name("planeteria file logger")
fh.setLevel(logging.DEBUG)
fh_formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
fh.setFormatter(fh_formatter)
logger.addHandler(fh)
# create console handler with a higher log level
ch = logging.StreamHandler()
ch.set_name("planeteria console logger")
ch.setLevel(logging.DEBUG)
ch_formatter = logging.Formatter('%(levelname)s - %(message)s')
ch.setFormatter(ch_formatter)
logger.addHandler(ch)