From 57797e47237d8520583d6a23049c99a7549286a5 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 25 May 2015 20:57:49 +0000 Subject: [PATCH] Normalise the filenames of the RRDs --- src/collecty/plugins/base.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/collecty/plugins/base.py b/src/collecty/plugins/base.py index 6c31ede..32afb02 100644 --- a/src/collecty/plugins/base.py +++ b/src/collecty/plugins/base.py @@ -275,7 +275,19 @@ class Object(object): """ The absolute path to the RRD file of this plugin. """ - return os.path.join(DATABASE_DIR, self.plugin.path, "%s.rrd" % self.id) + filename = self._normalise_filename("%s.rrd" % self.id) + + return os.path.join(DATABASE_DIR, self.plugin.path, filename) + + @staticmethod + def _normalise_filename(filename): + # Convert the filename into ASCII characters only + filename = filename.encode("ascii", "ignore") + + # Replace any spaces by dashes + filename = filename.replace(" ", "-") + + return filename ### Basic methods -- 2.47.2