-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
113 lines (72 loc) · 2.39 KB
/
main.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
"""
Kristoffer Langeland Knudsen
"""
import re
import sys
import urllib
import httplib
import os.path
import sqlite3 as sql
import xml.etree.ElementTree as ElementTree
import key
import cache
import update
import database
import container
def isEnabled(elm):
return elm.get('enabled') in ['true', 'True', '1', 'yes', 'Yes', None]
def main(userconfig):
versionfile = open('version', 'r')
version = versionfile.read()
versionfile.close()
print("")
print("Collective Refining Program")
print("Version: " + version)
print("")
print('Using userconfig:\t' + userconfig)
userconfig = ElementTree.parse(open(userconfig, 'r'))
configfile = userconfig.findtext(".//config")
print('Using config file:\t' + configfile)
configtree = ElementTree.parse(open(configfile, 'r'))
db_file = configtree.findtext(".//updates/database/filename")
cache_file = configtree.findtext("./cache/filename")
cache_directory = configtree.findtext("./cache/directory")
print("")
print(" Database file:\t" + db_file)
print(" Cache directory:\t" + cache_directory)
print(" Cache file:\t\t" + cache_file)
print("")
cache.initialize(configtree, userconfig, cache_directory, cache_file)
## Good, do we need an update?
print("")
print("Checking for software updates...")
if cache.checkUpdateTimer('core'):
update.update(configtree)
print("")
print("Checking for EVE online database updates...")
if cache.checkUpdateTimer('database'):
database.update(configtree)
# Load the game data.
container.initialize(configtree)
database.initialize(configtree)
## All right - initialize the keys.
keys = []
for elm in userconfig.iter('apikey'):
if not isEnabled(elm): continue
keys += [key.fromXML(elm)]
print("")
print("Requesting AssetLists...")
containers = []
for k in keys:
containers += cache.getContainers(k)
print("")
print("Generating Output...")
for o in configtree.iter('output'):
if not isEnabled(o): continue
module = __import__(o.get('module'))
module.output(containers, o.find("args").attrib)
if __name__ == "__main__":
args = sys.argv[1:]
configfile = args[0] if args else "userconfig.xml"
main(configfile)