Loading README.md +2 −2 Original line number Diff line number Diff line Loading @@ -9,11 +9,11 @@ Everything is configurable with environmental variables. Run this command to install version 0.1.10 via pip: `python3 -m pip --no-cache-dir install common==0.1.10 --index-url https://Install:dzK386VBsiR-iV8g2Ekc@code.ornl.gov/api/v4/projects/9965/packages/pypi/simple --trusted-host code.ornl.gov` `python3 -m pip --no-cache-dir install common==0.1.10 --index-url https://code.ornl.gov/api/v4/projects/10568/packages/pypi/simple --trusted-host code.ornl.gov` This will install latest (not recommended): `python3 -m pip --no-cache-dir install common --index-url https://Install:dzK386VBsiR-iV8g2Ekc@code.ornl.gov/api/v4/projects/9965/packages/pypi/simple --trusted-host code.ornl.gov` `python3 -m pip --no-cache-dir install common --index-url https://code.ornl.gov/api/v4/projects/10568/packages/pypi/simple --trusted-host code.ornl.gov` ## Usage Loading build.sh +2 −2 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ done # logic {{{1 banner DOCKER_BUILDKIT=1 docker build -f "$DOCKER_FILE" $NOCACHED \ -t "code.ornl.gov:4567/eagle-i/common_package/common:$TAG" . || \ -t "code.ornl.gov:4567/nset-utilities/common-package/common:$TAG" . || \ die "Image failed to build." docker push "code.ornl.gov:4567/eagle-i/common_package/common:$TAG" docker push "code.ornl.gov:4567/nset-utilities/common-package/common:$TAG" # 1}}} src/common/mixins/postgres.py +23 −14 Original line number Diff line number Diff line Loading @@ -2,12 +2,19 @@ # -*- coding: utf-8 -*- """Allow opening with a psycopg2 connection.""" import psycopg2 from common.env import check_environment as ce class PostgresMixin(): """Serve common connection method for postgres.""" """Serve common connection method for postgres. def open(self, search_path='public'): The default `search_path` variable can be set with the following operating system variable: - DATABASE_SEARCH_PATH """ DEFAULT_SEARCH_PATH = ce('DATABASE_SEARCH_PATH', 'public') def open(self, search_path=DEFAULT_SEARCH_PATH): """ Explicitly open the database connection :param search_path: the search path to default to Loading @@ -16,8 +23,6 @@ class PostgresMixin(): """ self.logger.debug('Opening Database Connection and creating Cursor') try: """ print(self.dbName + ',' + self.user + ',' + self.host + "," + str(self.port) + "," + str(self.timeout)) """ self.connection = psycopg2.connect( database=self.connection_info['dbName'], user=self.connection_info['dbUser'], Loading @@ -29,15 +34,19 @@ class PostgresMixin(): self.logger.debug('Successfully opened connection to database') self.cursor = self.connection.cursor() self.logger.debug('Successfully created a cursor') # TODO @Jonathan v--- not the default search paths - env var? """ ^---- need this re-explained """ # @TODO @Jonathan add searth_paths as a possible variable to pass if isinstance(search_path, list): self.search_path = (',').join(search_path) # if passed as a list, split and concat into commas self.cursor.execute("""SET search_path TO public, outage_data, utility, system_monitoring;""") elif isinstance(search_path, str): self.search_path = search_path else: self.logger.error(f'Unknown type: {search_path}.') self.search_path = 'public' self.cursor.execute(f"""SET search_path TO {self.search_path};""") self.cursor.commit() self.logger.debug('Successfully set search_path') except psycopg2.OperationalError as e: # TODO @Jonathan other errors? self.logger.error(f'Database Error: {e}') except psycopg2.OperationalError as error: self.logger.error(f'Database Error: {error}') return False return True Loading @@ -50,9 +59,9 @@ class PostgresMixin(): """ if not self.is_open(): self.logger.info(f'Database not open, opening now.') self.logger.info('Database not open, opening now.') self.open() # assume that it is already open - check if it is self.logger.debug(f'Submitting user specified query to database.') self.logger.debug('Submitting user specified query to database.') try: self.cursor.execute(query) if self.cursor.description is not None: Loading src/install.sh +2 −4 Original line number Diff line number Diff line #!/usr/bin/env bash user="Install" key="dzK386VBsiR-iV8g2Ekc" site="code.ornl.gov/api/v4/projects/9965/packages/pypi/simple" site="code.ornl.gov/api/v4/projects/10568/packages/pypi/simple" python3 -m pip --no-cache-dir install common \ --index-url "https://$user:$key@$site" --trusted-host code.ornl.gov --index-url "https://$site" --trusted-host code.ornl.gov src/pypirc.cfg +2 −2 Original line number Diff line number Diff line Loading @@ -3,6 +3,6 @@ index-servers = gitlab [gitlab] repository = https://code.ornl.gov/api/v4/projects/9965/packages/pypi repository = https://code.ornl.gov/api/v4/projects/10568/packages/pypi username = __token__ password = r9AjJy-BpDf-s7qo9CEt password = 3t2LFTptHcudHsKRsgr8 src/common/database.py +11 −11 File changed.Contains only whitespace changes. Show changes Loading
README.md +2 −2 Original line number Diff line number Diff line Loading @@ -9,11 +9,11 @@ Everything is configurable with environmental variables. Run this command to install version 0.1.10 via pip: `python3 -m pip --no-cache-dir install common==0.1.10 --index-url https://Install:dzK386VBsiR-iV8g2Ekc@code.ornl.gov/api/v4/projects/9965/packages/pypi/simple --trusted-host code.ornl.gov` `python3 -m pip --no-cache-dir install common==0.1.10 --index-url https://code.ornl.gov/api/v4/projects/10568/packages/pypi/simple --trusted-host code.ornl.gov` This will install latest (not recommended): `python3 -m pip --no-cache-dir install common --index-url https://Install:dzK386VBsiR-iV8g2Ekc@code.ornl.gov/api/v4/projects/9965/packages/pypi/simple --trusted-host code.ornl.gov` `python3 -m pip --no-cache-dir install common --index-url https://code.ornl.gov/api/v4/projects/10568/packages/pypi/simple --trusted-host code.ornl.gov` ## Usage Loading
build.sh +2 −2 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ done # logic {{{1 banner DOCKER_BUILDKIT=1 docker build -f "$DOCKER_FILE" $NOCACHED \ -t "code.ornl.gov:4567/eagle-i/common_package/common:$TAG" . || \ -t "code.ornl.gov:4567/nset-utilities/common-package/common:$TAG" . || \ die "Image failed to build." docker push "code.ornl.gov:4567/eagle-i/common_package/common:$TAG" docker push "code.ornl.gov:4567/nset-utilities/common-package/common:$TAG" # 1}}}
src/common/mixins/postgres.py +23 −14 Original line number Diff line number Diff line Loading @@ -2,12 +2,19 @@ # -*- coding: utf-8 -*- """Allow opening with a psycopg2 connection.""" import psycopg2 from common.env import check_environment as ce class PostgresMixin(): """Serve common connection method for postgres.""" """Serve common connection method for postgres. def open(self, search_path='public'): The default `search_path` variable can be set with the following operating system variable: - DATABASE_SEARCH_PATH """ DEFAULT_SEARCH_PATH = ce('DATABASE_SEARCH_PATH', 'public') def open(self, search_path=DEFAULT_SEARCH_PATH): """ Explicitly open the database connection :param search_path: the search path to default to Loading @@ -16,8 +23,6 @@ class PostgresMixin(): """ self.logger.debug('Opening Database Connection and creating Cursor') try: """ print(self.dbName + ',' + self.user + ',' + self.host + "," + str(self.port) + "," + str(self.timeout)) """ self.connection = psycopg2.connect( database=self.connection_info['dbName'], user=self.connection_info['dbUser'], Loading @@ -29,15 +34,19 @@ class PostgresMixin(): self.logger.debug('Successfully opened connection to database') self.cursor = self.connection.cursor() self.logger.debug('Successfully created a cursor') # TODO @Jonathan v--- not the default search paths - env var? """ ^---- need this re-explained """ # @TODO @Jonathan add searth_paths as a possible variable to pass if isinstance(search_path, list): self.search_path = (',').join(search_path) # if passed as a list, split and concat into commas self.cursor.execute("""SET search_path TO public, outage_data, utility, system_monitoring;""") elif isinstance(search_path, str): self.search_path = search_path else: self.logger.error(f'Unknown type: {search_path}.') self.search_path = 'public' self.cursor.execute(f"""SET search_path TO {self.search_path};""") self.cursor.commit() self.logger.debug('Successfully set search_path') except psycopg2.OperationalError as e: # TODO @Jonathan other errors? self.logger.error(f'Database Error: {e}') except psycopg2.OperationalError as error: self.logger.error(f'Database Error: {error}') return False return True Loading @@ -50,9 +59,9 @@ class PostgresMixin(): """ if not self.is_open(): self.logger.info(f'Database not open, opening now.') self.logger.info('Database not open, opening now.') self.open() # assume that it is already open - check if it is self.logger.debug(f'Submitting user specified query to database.') self.logger.debug('Submitting user specified query to database.') try: self.cursor.execute(query) if self.cursor.description is not None: Loading
src/install.sh +2 −4 Original line number Diff line number Diff line #!/usr/bin/env bash user="Install" key="dzK386VBsiR-iV8g2Ekc" site="code.ornl.gov/api/v4/projects/9965/packages/pypi/simple" site="code.ornl.gov/api/v4/projects/10568/packages/pypi/simple" python3 -m pip --no-cache-dir install common \ --index-url "https://$user:$key@$site" --trusted-host code.ornl.gov --index-url "https://$site" --trusted-host code.ornl.gov
src/pypirc.cfg +2 −2 Original line number Diff line number Diff line Loading @@ -3,6 +3,6 @@ index-servers = gitlab [gitlab] repository = https://code.ornl.gov/api/v4/projects/9965/packages/pypi repository = https://code.ornl.gov/api/v4/projects/10568/packages/pypi username = __token__ password = r9AjJy-BpDf-s7qo9CEt password = 3t2LFTptHcudHsKRsgr8