-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from USEPA/owld_stubs
Owld stubs
- Loading branch information
Showing
79 changed files
with
2,058 additions
and
401 deletions.
There are no files selected for viewing
149 changes: 149 additions & 0 deletions
149
admin/jupyter/notebooks/setup/git_checkout_cipsrv_gis.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## git_checkout cipsrv_gis" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os,sys,git,tempfile,psycopg2,argparse;\n", | ||
"from ipywidgets import IntProgress,HTML,VBox;\n", | ||
"from IPython.display import display;\n", | ||
"parser = argparse.ArgumentParser();\n", | ||
"parser.add_argument(\"--override_branch\" ,required=False);\n", | ||
"parser.add_argument(\"--use_existing_sql\",required=False);\n", | ||
"args, _ = parser.parse_known_args();\n", | ||
"\n", | ||
"sys.path.append(os.path.join(os.path.expanduser('~'),'notebooks'));\n", | ||
"import common;\n", | ||
"\n", | ||
"gith = os.environ['GITHUB_REPO_URL'];\n", | ||
"# override: \"[email protected]:USEPA/CIPv2.git\"\n", | ||
"if args.override_branch is not None:\n", | ||
" brnh = args.override_branch;\n", | ||
"else:\n", | ||
" brnh = os.environ['GITHUB_DEFAULT_BRANCH'];\n", | ||
"# override: \"mybranch\"\n", | ||
"\n", | ||
"dbse = os.environ['POSTGRESQL_DB'];\n", | ||
"host = os.environ['POSTGRESQL_HOST'];\n", | ||
"port = os.environ['POSTGRESQL_PORT'];\n", | ||
"user = 'cipsrv';\n", | ||
"pasw = os.environ['POSTGRESQL_CIP_PASS'];\n", | ||
"\n", | ||
"depf = os.path.join('src','database','cipsrv_gis','cipsrv_gis_deploy.sql');\n", | ||
"\n", | ||
"print(\"repo: \" + gith);\n", | ||
"print(\"branch: \" + brnh);" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"cs = \"dbname=%s user=%s password=%s host=%s port=%s\" % (\n", | ||
" dbse\n", | ||
" ,user\n", | ||
" ,pasw\n", | ||
" ,host\n", | ||
" ,port\n", | ||
");\n", | ||
"\n", | ||
"try:\n", | ||
" conn = psycopg2.connect(cs);\n", | ||
"except:\n", | ||
" raise Exception(\"database connection error\");\n", | ||
" \n", | ||
"print(\"database is ready\");" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"if args.use_existing_sql is not None:\n", | ||
" trg = args.use_existing_sql;\n", | ||
" print(\"using existing \" + trg);\n", | ||
" \n", | ||
"else:\n", | ||
" td = tempfile.TemporaryDirectory();\n", | ||
" \n", | ||
" repo = git.Repo.clone_from(\n", | ||
" url = gith\n", | ||
" ,branch = brnh\n", | ||
" ,to_path = td.name\n", | ||
" ,depth = 1\n", | ||
" );\n", | ||
" \n", | ||
" print(\"checkout of \" + td.name + \" complete.\");\n", | ||
" trg = os.path.join(td.name,depf);\n", | ||
" " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"if not os.path.exists(trg):\n", | ||
" raise Exception(trg + ' not found.');\n", | ||
" \n", | ||
"z = common.load_sqlfile(conn,trg,echo=True);\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"conn.close();\n", | ||
"\n", | ||
"if args.use_existing_sql is None:\n", | ||
" td.cleanup();\n", | ||
"\n", | ||
"print(\"logic load complete.\");" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.12.3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.