From: Michael Tremer Date: Mon, 25 May 2015 20:57:49 +0000 (+0000) Subject: Normalise the filenames of the RRDs X-Git-Tag: 003~22 X-Git-Url: http://git.ipfire.org/?p=collecty.git;a=commitdiff_plain;h=57797e47237d8520583d6a23049c99a7549286a5 Normalise the filenames of the RRDs --- 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