|
@@ -0,0 +1,32 @@
|
|
1
|
+#! /usr/bin/env python
|
|
2
|
+
|
|
3
|
+import ConfigParser
|
|
4
|
+import sys
|
|
5
|
+
|
|
6
|
+class Config:
|
|
7
|
+ general = {}
|
|
8
|
+
|
|
9
|
+ def __init__(self, path=""):
|
|
10
|
+ if path == "":
|
|
11
|
+ path = "/etc/fake-tracker.conf"
|
|
12
|
+ if sys.platform == "win32":
|
|
13
|
+ path = "./fake-tracker.conf"
|
|
14
|
+ configParser = ConfigParser.ConfigParser()
|
|
15
|
+ configParser.read(path)
|
|
16
|
+ self.general = self.configSectionMap(configParser, "General")
|
|
17
|
+
|
|
18
|
+ def configSectionMap(self, configParser, section):
|
|
19
|
+ dict1 = {}
|
|
20
|
+ options = configParser.options(section)
|
|
21
|
+ for option in options:
|
|
22
|
+ try:
|
|
23
|
+ dict1[option] = configParser.get(section, option)
|
|
24
|
+ except:
|
|
25
|
+ dict1[option] = None
|
|
26
|
+ return dict1
|
|
27
|
+
|
|
28
|
+ def getMaxRatio(self):
|
|
29
|
+ return int(self.general['maxratio'])
|
|
30
|
+
|
|
31
|
+ def getMaxRate(self):
|
|
32
|
+ return int(self.general['maxrate'])
|