Example #1
0
 def setup(self, location=None):
     """Setup the data connector."""
     if location is None:
         raise exceptions.InsufficientConfiguration(
                 "the location for storing datas was not specified for " \
                 "the YAML data connector")
     
     location = location.replace("\\", "/")
     if location.startswith("~"):
         location = os.path.expanduser("~") + location[1:]
     
     if location.endswith("/"):
         location = location[:-1]
     
     if not os.path.exists(location):
         # Try to create it
         os.makedirs(location)
     
     if not os.access(location, os.R_OK):
         raise exceptions.DriverInitializationError(
                 "cannot read in {}".format(location))
     if not os.access(location, os.W_OK):
         raise exceptions.DriverInitializationError(
                 "cannot write in {}".format(location))
     
     DataConnector.__init__(self)
     self.location = location
     self.files = {}
Example #2
0
    def setup(self, location=None):
        """Setup the data connector."""
        if location is None:
            raise exceptions.InsufficientConfiguration(
                    "the location for storing datas was not specified for " \
                    "the YAML data connector")

        location = location.replace("\\", "/")
        if location.startswith("~"):
            location = os.path.expanduser("~") + location[1:]

        if location.endswith("/"):
            location = location[:-1]

        if not os.path.exists(location):
            # Try to create it
            os.makedirs(location)

        if not os.access(location, os.R_OK):
            raise exceptions.DriverInitializationError(
                "cannot read in {}".format(location))
        if not os.access(location, os.W_OK):
            raise exceptions.DriverInitializationError(
                "cannot write in {}".format(location))

        DataConnector.__init__(self)
        self.location = location
        self.files = {}
Example #3
0
 def __init__(self):
     """Check the driver presence.
     
     If not found, raise a DriverNotFound exception.
     
     """
     if not driver:
         raise exceptions.DriverNotFound(
                 "the pymongo library can not be found")
     
     DataConnector.__init__(self)
     self.db_name = "datas"
     self.inc_name = "increments"
Example #4
0
 def __init__(self):
     """Check the driver presence.
     
     If not found, raise a DriverNotFound exception.
     
     """
     if not driver:
         raise exceptions.DriverNotFound(
                 "the pymongo library can not be found")
     
     DataConnector.__init__(self)
     self.db_name = "datas"
     self.inc_name = "increments"
Example #5
0
 def setup(self, location=None):
     """Setup the data connector."""
     if location is None:
         raise exceptions.InsufficientConfiguration(
                 "the location for storing datas was not specified for " \
                 "the sqlite3 data connector")
     
     location = location.replace("\\", "/")
     if location.startswith("~"):
         location = os.path.expanduser("~") + location[1:]
     
     location_dir = os.path.split(location)[0]
     if location_dir and not os.path.exists(location_dir):
         # Try to create it
         os.makedirs(location_dir)
     
     DataConnector.__init__(self)
     self.location = location
     self.connection = sqlite3.connect(self.location)
Example #6
0
    def setup(self, location=None):
        """Setup the data connector."""
        if location is None:
            raise exceptions.InsufficientConfiguration(
                    "the location for storing datas was not specified for " \
                    "the sqlite3 data connector")

        location = location.replace("\\", "/")
        if location.startswith("~"):
            location = os.path.expanduser("~") + location[1:]

        location_dir = os.path.split(location)[0]
        if location_dir and not os.path.exists(location_dir):
            # Try to create it
            os.makedirs(location_dir)

        DataConnector.__init__(self)
        self.location = location
        self.connection = sqlite3.connect(self.location)
Example #7
0
 def setup(self, host=None, port=None, dbname=None, dbuser=None,
         dbpass=""):
     """Setup the data connector."""
     if host is None:
         raise exceptions.InsufficientConfiguration(
                 "the database host was not specified for " \
                 "the postgresql data connector")
     
     if port is None:
         raise exceptions.InsufficientConfiguration(
                 "the database port was not specified for " \
                 "the postgresql data connector")
     
     if dbname is None:
         raise exceptions.InsufficientConfiguration(
                 "the database name was not specified for " \
                 "the postgresql data connector")
     
     if dbuser is None:
         raise exceptions.InsufficientConfiguration(
                 "the database user was not specified for " \
                 "the postgresql data connector")
     
     DataConnector.__init__(self)
     if dbpass is None:
         dbpass = ""
     else:
         dbpass = str(dbpass)
     
     self.db_host = host
     self.db_port = port
     self.db_name = dbname
     self.db_user = dbuser
     self.db_pass = dbpass
     self.connection = postgresql.open(
             "pq://{user}:{password}@{host}:{port}/{database}".format(
             user=dbuser, password=dbpass, host=host, port=port,
             database=dbname))