Sisyphus repositório
Última atualização: 1 outubro 2023 | SRPMs: 18631 | Visitas: 37755174
en ru br
ALT Linux repositórios
S:3.10.1-alt2

Group :: Monitoramento
RPM: nagstamon

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs e FR  Repocop 

Patch: nagstamon-3.10.1-system-config.patch
Download


 Nagstamon/Config.py | 76 ++++++++++++++++++++++++++++++-----------------------
 1 file changed, 43 insertions(+), 33 deletions(-)
diff --git a/Nagstamon/Config.py b/Nagstamon/Config.py
index 81a26628..735c1e5b 100644
--- a/Nagstamon/Config.py
+++ b/Nagstamon/Config.py
@@ -338,6 +338,11 @@ class Config(object):
             # nagstamon expects its conf file to be
             self.configdir = os.path.expanduser('~') + os.sep + '.nagstamon'
 
+        if not OS in OS_NON_LINUX:
+            self.sysconfigdir = os.sep + 'etc' + os.sep + 'nagstamon'
+        else:
+            self.sysconfigdir = None
+
         self.configfile = self.configdir + os.sep + 'nagstamon.conf'
 
         # make path fit for actual os, normcase for letters and normpath for path
@@ -489,40 +494,45 @@ class Config(object):
         # defaults as empty dict in case settings dir/files could not be found
         settings = OrderedDict()
 
-        try:
-            if os.path.exists(self.configdir + os.sep + settingsdir):
-                for settingsfile in sorted(os.listdir(self.configdir + os.sep + settingsdir)):
-                    if settingsfile.startswith(setting + '_') and settingsfile.endswith('.conf'):
-                        config = configparser.ConfigParser(allow_no_value=True, interpolation=None)
-                        config.read(self.configdir + os.sep + settingsdir + os.sep + settingsfile)
-
-                        # create object for every setting
-                        name = config.get(config.sections()[0], 'name')
-                        settings[name] = globals()[configobj]()
-
-                        # go through all items of the server
-                        for i in config.items(config.sections()[0]):
-                            # create a key of every config item with its appropriate value
-                            if i[1] in BOOLPOOL:
-                                value = BOOLPOOL[i[1]]
-                            # in case there are numbers intify them to avoid later conversions
-                            # treat negative value specially as .isdecimal() will not detect it
-                            elif i[1].isdecimal() or \
-                                    (i[1].startswith('-') and i[1].split('-')[1].isdecimal()):
-                                value = int(i[1])
-                            else:
-                                value = i[1]
-                            settings[name].__setattr__(i[0], value)
-
-                        # if filename is still one of the non-URL-ones delete duplicate file
-                        if settingsfile != '{0}_{1}.conf'.format(setting, quote(name, safe='')):
-                            self.delete_file(settingsdir, settingsfile)
-                            # set flag to store the settings via legacy adjustments
-                            self.save_config_after_urlencode = True
+        def readconfig(settingsfile, configdir):
+            try:
+                if settingsfile.startswith(setting + '_') and settingsfile.endswith('.conf'):
+                    config = configparser.ConfigParser(allow_no_value=True, interpolation=None)
+                    config.read(configdir + os.sep + settingsdir + os.sep + settingsfile)
 
-        except Exception:
-            import traceback
-            traceback.print_exc(file=sys.stdout)
+                    # create object for every setting
+                    name = config.get(config.sections()[0], 'name')
+                    settings[name] = globals()[configobj]()
+
+                    # go through all items of the server
+                    for i in config.items(config.sections()[0]):
+                        # create a key of every config item with its appropriate value
+                        if i[1] in BOOLPOOL:
+                            value = BOOLPOOL[i[1]]
+                        # in case there are numbers intify them to avoid later conversions
+                        # treat negative value specially as .isdecimal() will not detect it
+                        elif i[1].isdecimal() or \
+                                (i[1].startswith('-') and i[1].split('-')[1].isdecimal()):
+                            value = int(i[1])
+                        else:
+                            value = i[1]
+                        settings[name].__setattr__(i[0], value)
+
+                    # if filename is still one of the non-URL-ones delete duplicate file
+                    if settingsfile != '{0}_{1}.conf'.format(setting, quote(name, safe='')):
+                        self.delete_file(settingsdir, settingsfile)
+                        # set flag to store the settings via legacy adjustments
+                        self.save_config_after_urlencode = True
+            except Exception:
+                import traceback
+                traceback.print_exc(file=sys.stdout)
+
+        if self.sysconfigdir and os.path.exists(self.sysconfigdir + os.sep + settingsdir):
+            for settingsfile in sorted(os.listdir(self.sysconfigdir + os.sep + settingsdir)):
+                readconfig(settingsfile, self.sysconfigdir)
+        if os.path.exists(self.configdir + os.sep + settingsdir):
+            for settingsfile in sorted(os.listdir(self.configdir + os.sep + settingsdir)):
+                readconfig(settingsfile, self.configdir)
 
         return settings
 
 
projeto & código: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
mantenedor atual: Michael Shigorin
mantenedor da tradução: Fernando Martini aka fmartini © 2009