Bladeren bron

added torrent path config

master
Robin Thoni 8 jaren geleden
bovenliggende
commit
37a8720296
2 gewijzigde bestanden met toevoegingen van 18 en 3 verwijderingen
  1. 1
    0
      config.conf
  2. 17
    3
      config.py

+ 1
- 0
config.conf Bestand weergeven

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

+ 17
- 3
config.py Bestand weergeven

13
                 path = "./fake-tracker.conf"
13
                 path = "./fake-tracker.conf"
14
         configParser = ConfigParser.ConfigParser()
14
         configParser = ConfigParser.ConfigParser()
15
         configParser.read(path)
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
     def configSectionMap(self, configParser, section):
23
     def configSectionMap(self, configParser, section):
19
         dict1 = {}
24
         dict1 = {}
25
                 dict1[option] = None
30
                 dict1[option] = None
26
         return dict1
31
         return dict1
27
 
32
 
33
+    def getOption(self, option):
34
+        try:
35
+            return self.general[option]
36
+        except:
37
+            return None
38
+
28
     def getMaxRatio(self):
39
     def getMaxRatio(self):
29
-        return int(self.general['maxratio'])
40
+        return int(self.getOption('maxratio'))
30
 
41
 
31
     def getMaxRate(self):
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'))

Laden…
Annuleren
Opslaan