summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-11-26 13:21:09 -0500
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-11-26 13:21:18 -0500
commit939f363c12993e6a30a48720845f737f0b13d082 (patch)
tree730460beb759685e0a8d49013a4cc69e10e83e2f /src
parent62bc304fe0ea0457dd1707420acd01b3e2fb3b37 (diff)
downloadbcfg2-939f363c12993e6a30a48720845f737f0b13d082.tar.gz
bcfg2-939f363c12993e6a30a48720845f737f0b13d082.tar.bz2
bcfg2-939f363c12993e6a30a48720845f737f0b13d082.zip
create data directory for reporting Transports
Diffstat (limited to 'src')
-rw-r--r--src/lib/Bcfg2/Reporting/Transport/base.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/lib/Bcfg2/Reporting/Transport/base.py b/src/lib/Bcfg2/Reporting/Transport/base.py
index cca7beda0..ea2098b52 100644
--- a/src/lib/Bcfg2/Reporting/Transport/base.py
+++ b/src/lib/Bcfg2/Reporting/Transport/base.py
@@ -2,17 +2,21 @@
The base for all server -> collector Transports
"""
-import os.path
-import logging
+import os
+import sys
+import logging
+
class TransportError(Exception):
"""Generic TransportError"""
pass
+
class TransportImportError(TransportError):
"""Raised when a transport fails to import"""
pass
+
class TransportBase(object):
"""The base for all transports"""
@@ -22,6 +26,14 @@ class TransportBase(object):
self.logger = logging.getLogger(clsname)
self.logger.debug("Loading %s transport" % clsname)
self.data = os.path.join(setup['repo'], 'Reporting', clsname)
+ if not os.path.exists(self.data):
+ self.logger.info("%s does not exist, creating" % self.data)
+ try:
+ os.makedirs(self.data)
+ except OSError:
+ self.logger.warning("Could not create %s: %s" %
+ (self.data, sys.exc_info()[1]))
+ self.logger.warning("The transport may not function properly")
self.setup = setup
self.timeout = 2