]> TLD Linux GIT Repositories - tld-builder.git/blobdiff - TLD_Builder/config.py
- more python3 fixes, dropped python2 support
[tld-builder.git] / TLD_Builder / config.py
index 3351b22e770b86c9052f804d1bd208c621aaf8bf..d8c42c4bebd51d676ba552192188714f5348d4af 100644 (file)
@@ -1,6 +1,7 @@
 # vi: encoding=utf-8 ts=8 sts=4 sw=4 et
 
-import ConfigParser
+import sys
+import configparser as ConfigParser
 import string
 import os
 import syslog
@@ -40,11 +41,11 @@ class Builder_Conf:
         p = ConfigParser.ConfigParser()
         def get(o, d = None, sec=None):
             if p.has_option(sec, o):
-                return string.strip(p.get(sec, o))
+                return p.get(sec, o).strip()
             elif p.has_option(builder, o):
-                return string.strip(p.get(builder, o))
+                return p.get(builder, o).strip()
             elif p.has_option("all", o):
-                return string.strip(p.get("all", o))
+                return p.get("all", o).strip()
             elif d != None:
                 return d
             else:
@@ -58,7 +59,7 @@ class Builder_Conf:
         if p.has_option("all", "syslog"):
             f = p.get("all", "syslog")
             if f != "":
-                if syslog_facilities.has_key(f):
+                if f in syslog_facilities:
                     log.open_syslog("builder", syslog_facilities[f])
                 else:
                     log.panic("no such syslog facility: %s" % f)
@@ -67,8 +68,8 @@ class Builder_Conf:
             builder = get("src_builder", builder)
         self.builder = builder
 
-        self.binary_builders = string.split(get("binary_builders"))
-        self.src_builder = string.strip(get("src_builder", ""))
+        self.binary_builders = get("binary_builders").split()
+        self.src_builder = get("src_builder", "").strip()
         self.max_keep_time = int(get("max_keep_time", 168))*60*60
         self.bot_email = get("bot_email", "")
         self.control_url = get("control_url")
@@ -112,7 +113,7 @@ class Builder_Conf:
 
         f = get("syslog", "")
         if f != "":
-            if syslog_facilities.has_key(f):
+            if f in syslog_facilities:
                 log.open_syslog(self.builder, syslog_facilities[f])
             else:
                 log.panic("no such syslog facility: %s" % f)
@@ -123,11 +124,11 @@ config = Builder_Conf()
 
 def init_conf(builder=None):
     try:
-       _create_unverified_https_context = ssl._create_unverified_context
+        _create_unverified_https_context = ssl._create_unverified_context
     except AttributeError:
-       pass
+        pass
     else:
-       ssl._create_default_https_context = _create_unverified_https_context
+        ssl._create_default_https_context = _create_unverified_https_context
     os.environ['LC_ALL'] = "C"
     status.push("reading builder config")
     log.builder = builder