You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

config.py 885B

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