def __open_dbms_conn(self): """opens a connection to postgresql""" try: return HelperPg.connect(self.pgsql_conf) except psycopg2.Error as e: self.logger.error(e) raise DocBuilderError("dbms was not connected") except KeyError as e: self.logger.error(e) raise DocBuilderError("slack pgsql configuration")
def __init__(self, logger, resdir=None, rdirs_conf=None): self.logger = logger if resdir == None: raise DocBuilderError('resources directory not fed!!') self.resdir = resdir if rdirs_conf == None: raise DocBuilderError("rdirs config info not fed!!") self.rdirs_conf = rdirs_conf
def __init__(self, logger, rdirs_conf = None, pgsql_conf = None): self.logger = logger if pgsql_conf == None: raise DocBuilderError("pgsql config info not fed!!") self.pgsql_conf = pgsql_conf if rdirs_conf == None: raise DocBuilderError("rdirs config info not fed!!") self.rdirs_conf = rdirs_conf
def __create(self, conn, d_rdirs, output_file, **kwargs): """runs pipeline's steps""" dat = None if len(d_rdirs) > 0: pass else: raise DocBuilderError("slack resource dirs configuration") fullpath_dirs = {} for k, v in d_rdirs.items(): fullpath_dirs[k] = '{}/{}'.format(self.resdir, v) try: dat = self.builder.data_acq(conn, fullpath_dirs, **kwargs) except DocBuilderStepError: raise finally: conn.close() try: self.builder.format_wrt(output_file, dat) except DocBuilderStepError: raise try: self.builder.data_rel(dat) except DocBuilderStepError: raise
def __create(conn, d_rdirs, output_file, **kwargs): """runs pipeline's steps""" dat = None if len(d_rdirs) > 0: pass else: raise DocBuilderError("slack resource dirs configuration") try: dat = self.builder.data_acq(conn, d_rdirs, **kwargs) except DocBuilderStepError: raise finally: conn.close() try: self.builder.format_wrt(output_file, dat) except DocBuilderStepError: raise try: self.builder.data_rel(dat) except DocBuilderStepError: raise
def __open_dbms_conn(self): """opens a connection to postgresql""" try: conn_str = "dbname={0} user={1} host={2} password={3} port={4}".format( ProfileReader.get_content(self.pgsql_conf.db, ProfileReader.PNODE_UNIQUE) ProfileReader.get_content(self.pgsql_conf.user, ProfileReader.PNODE_UNIQUE) ProfileReader.get_content(self.pgsql_conf.host, ProfileReader.PNODE_UNIQUE) ProfileReader.get_content(self.pgsql_conf.passwd, ProfileReader.PNODE_UNIQUE) ProfileReader.get_content(self.pgsql_conf.port, ProfileReader.PNODE_UNIQUE) ) return psycopg2.connect(conn_str) except psycopg2.Error as e: self.logger.error(e) raise DocBuilderError("dbms was not connected") except KeyError as e: self.logger.error(e) raise DocBuilderError("slack pgsql configuration")