]> git.ipfire.org Git - collecty.git/blobdiff - src/collecty/plugins/base.py
psi: Add graph template
[collecty.git] / src / collecty / plugins / base.py
index 561fa7b04c863754f05046a6091460eae05d8b44..e8f8f308c0e2d6a842d3b112c1be1a8693e886cf 100644 (file)
@@ -55,7 +55,7 @@ class Environment(object):
 
                        # Apply the new one
                        if self.new_environment[k]:
-                               os.environ.update(self.new_environment[k])
+                               os.environ[k] = self.new_environment[k]
 
        def __exit__(self, type, value, traceback):
                # Roll back to the previous environment
@@ -448,8 +448,11 @@ class Object(object):
                """
                filename = os.path.join(*args)
 
-               with open(filename) as f:
-                       value = f.read()
+               try:
+                       with open(filename) as f:
+                               value = f.read()
+               except FileNotFoundError as e:
+                       return None
 
                # Strip any excess whitespace
                if strip:
@@ -465,7 +468,7 @@ class Object(object):
 
                try:
                        return int(value)
-               except ValueError:
+               except (TypeError, ValueError):
                        return None
 
        def read_proc_stat(self):