Browse Source

added torrent path config

master
Robin Thoni 8 years ago
parent
commit
37a8720296
2 changed files with 18 additions and 3 deletions
  1. 1
    0
      config.conf
  2. 17
    3
      config.py

+ 1
- 0
config.conf View File

@@ -1,3 +1,4 @@
1 1
 [General]
2 2
 maxRatio: 3
3 3
 maxRate: 120
4
+torrentsPath: "."

+ 17
- 3
config.py View File

@@ -13,7 +13,12 @@ class Config:
13 13
                 path = "./fake-tracker.conf"
14 14
         configParser = ConfigParser.ConfigParser()
15 15
         configParser.read(path)
16
-        self.general = self.configSectionMap(configParser, "General")
16
+        try:
17
+            self.general = self.configSectionMap(configParser, "General")
18
+        except:
19
+            self.general = {'maxratio' : 1,
20
+                    "maxrate" : 120,
21
+                    "torrentspath" : "."}
17 22
 
18 23
     def configSectionMap(self, configParser, section):
19 24
         dict1 = {}
@@ -25,8 +30,17 @@ class Config:
25 30
                 dict1[option] = None
26 31
         return dict1
27 32
 
33
+    def getOption(self, option):
34
+        try:
35
+            return self.general[option]
36
+        except:
37
+            return None
38
+
28 39
     def getMaxRatio(self):
29
-        return int(self.general['maxratio'])
40
+        return int(self.getOption('maxratio'))
30 41
 
31 42
     def getMaxRate(self):
32
-        return int(self.general['maxrate'])
43
+        return int(self.getOption('maxrate'))
44
+
45
+    def getTorrentsPath(self):
46
+        return str(self.getOption('torrentspath'))

Loading…
Cancel
Save