cchdo.auth 1.0.2__tar.gz → 1.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cchdo_auth-1.2.0/.devcontainer/devcontainer.json +29 -0
- cchdo_auth-1.2.0/.github/dependabot.yml +12 -0
- cchdo_auth-1.2.0/.github/workflows/build-docs.yml +53 -0
- cchdo_auth-1.2.0/.github/workflows/do-release.yml +23 -0
- cchdo_auth-1.2.0/.github/workflows/python-app.yml +45 -0
- cchdo_auth-1.2.0/.pre-commit-config.yaml +13 -0
- cchdo_auth-1.2.0/.python-version +1 -0
- {cchdo.auth-1.0.2 → cchdo_auth-1.2.0}/LICENSE.md +1 -1
- cchdo_auth-1.2.0/PKG-INFO +35 -0
- {cchdo.auth-1.0.2 → cchdo_auth-1.2.0}/cchdo/auth/__init__.py +36 -9
- cchdo_auth-1.2.0/cchdo/auth/__main__.py +127 -0
- cchdo_auth-1.2.0/cchdo/auth/config.py +1 -0
- {cchdo.auth-1.0.2 → cchdo_auth-1.2.0}/cchdo/auth/test/test_Auth.py +4 -4
- cchdo_auth-1.2.0/cchdo.auth.egg-info/PKG-INFO +35 -0
- {cchdo.auth-1.0.2 → cchdo_auth-1.2.0}/cchdo.auth.egg-info/SOURCES.txt +7 -6
- cchdo_auth-1.2.0/cchdo.auth.egg-info/requires.txt +14 -0
- cchdo_auth-1.2.0/cchdo.auth.egg-info/scm_file_list.json +32 -0
- cchdo_auth-1.2.0/cchdo.auth.egg-info/scm_version.json +8 -0
- {cchdo.auth-1.0.2 → cchdo_auth-1.2.0}/docs/conf.py +1 -1
- cchdo_auth-1.2.0/docs/config.rst +110 -0
- {cchdo.auth-1.0.2 → cchdo_auth-1.2.0}/docs/installation.rst +2 -21
- cchdo_auth-1.2.0/docs/secrets.svg +365 -0
- {cchdo.auth-1.0.2 → cchdo_auth-1.2.0}/docs/usage.rst +63 -3
- cchdo_auth-1.2.0/pyproject.toml +90 -0
- cchdo_auth-1.2.0/setup.cfg +4 -0
- cchdo_auth-1.2.0/uv.lock +1150 -0
- cchdo.auth-1.0.2/.devcontainer/Dockerfile +0 -22
- cchdo.auth-1.0.2/.devcontainer/devcontainer.json +0 -45
- cchdo.auth-1.0.2/.github/workflows/build-docs.yml +0 -36
- cchdo.auth-1.0.2/.github/workflows/do-release.yml +0 -34
- cchdo.auth-1.0.2/.github/workflows/python-app.yml +0 -52
- cchdo.auth-1.0.2/.pre-commit-config.yaml +0 -16
- cchdo.auth-1.0.2/PKG-INFO +0 -58
- cchdo.auth-1.0.2/cchdo/auth/__main__.py +0 -27
- cchdo.auth-1.0.2/cchdo/auth/_version.py +0 -1
- cchdo.auth-1.0.2/cchdo.auth.egg-info/PKG-INFO +0 -58
- cchdo.auth-1.0.2/cchdo.auth.egg-info/not-zip-safe +0 -1
- cchdo.auth-1.0.2/cchdo.auth.egg-info/requires.txt +0 -45
- cchdo.auth-1.0.2/cchdo.auth.egg-info/top_level.txt +0 -3
- cchdo.auth-1.0.2/docs/config.rst +0 -87
- cchdo.auth-1.0.2/pyproject.toml +0 -7
- cchdo.auth-1.0.2/setup.cfg +0 -99
- cchdo.auth-1.0.2/setup.py +0 -3
- {cchdo.auth-1.0.2 → cchdo_auth-1.2.0}/.gitignore +0 -0
- {cchdo.auth-1.0.2 → cchdo_auth-1.2.0}/README.md +0 -0
- {cchdo.auth-1.0.2 → cchdo_auth-1.2.0}/cchdo/auth/py.typed +0 -0
- {cchdo.auth-1.0.2 → cchdo_auth-1.2.0}/cchdo/auth/session.py +0 -0
- {cchdo.auth-1.0.2 → cchdo_auth-1.2.0}/cchdo/auth/test/__init__.py +0 -0
- {cchdo.auth-1.0.2 → cchdo_auth-1.2.0}/cchdo.auth.egg-info/dependency_links.txt +0 -0
- /cchdo.auth-1.0.2/cchdo.auth.egg-info/namespace_packages.txt → /cchdo_auth-1.2.0/cchdo.auth.egg-info/top_level.txt +0 -0
- {cchdo.auth-1.0.2 → cchdo_auth-1.2.0}/docs/Makefile +0 -0
- {cchdo.auth-1.0.2 → cchdo_auth-1.2.0}/docs/api.rst +0 -0
- {cchdo.auth-1.0.2 → cchdo_auth-1.2.0}/docs/index.rst +0 -0
- {cchdo.auth-1.0.2 → cchdo_auth-1.2.0}/docs/make.bat +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
|
2
|
+
// README at: https://github.com/devcontainers/templates/tree/main/src/python
|
|
3
|
+
{
|
|
4
|
+
"name": "Python 3",
|
|
5
|
+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
|
|
6
|
+
"image": "mcr.microsoft.com/devcontainers/python:1-3.10-bullseye",
|
|
7
|
+
"customizations": {
|
|
8
|
+
"vscode": {
|
|
9
|
+
"extensions": [
|
|
10
|
+
"charliermarsh.ruff"
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Features to add to the dev container. More info: https://containers.dev/features.
|
|
16
|
+
// "features": {},
|
|
17
|
+
|
|
18
|
+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
|
19
|
+
// "forwardPorts": [],
|
|
20
|
+
|
|
21
|
+
// Use 'postCreateCommand' to run commands after the container is created.
|
|
22
|
+
// "postCreateCommand": "pip3 install --user -r requirements.txt",
|
|
23
|
+
|
|
24
|
+
// Configure tool-specific properties.
|
|
25
|
+
// "customizations": {},
|
|
26
|
+
|
|
27
|
+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
|
28
|
+
// "remoteUser": "root"
|
|
29
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
|
3
|
+
# Please see the documentation for more information:
|
|
4
|
+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
5
|
+
# https://containers.dev/guide/dependabot
|
|
6
|
+
|
|
7
|
+
version: 2
|
|
8
|
+
updates:
|
|
9
|
+
- package-ecosystem: "devcontainers"
|
|
10
|
+
directory: "/"
|
|
11
|
+
schedule:
|
|
12
|
+
interval: weekly
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
name: Build Docs
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ master ]
|
|
6
|
+
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
concurrency:
|
|
10
|
+
group: "pages"
|
|
11
|
+
cancel-in-progress: false
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
build-docs:
|
|
15
|
+
runs-on: ubuntu-26.04-arm
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v7
|
|
21
|
+
|
|
22
|
+
- name: Install uv
|
|
23
|
+
uses: astral-sh/setup-uv@5a7eac68fb9809dea845d802897dc5c723910fa3
|
|
24
|
+
with:
|
|
25
|
+
enable-cache: true
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: uv sync --all-extras --dev
|
|
29
|
+
|
|
30
|
+
- name: Sphinx Build HTML docs
|
|
31
|
+
working-directory: docs
|
|
32
|
+
run: uv run make html
|
|
33
|
+
|
|
34
|
+
- name: Upload static files as artifact
|
|
35
|
+
id: deployment
|
|
36
|
+
uses: actions/upload-pages-artifact@v5
|
|
37
|
+
with:
|
|
38
|
+
path: ./docs/_build/html
|
|
39
|
+
|
|
40
|
+
deploy:
|
|
41
|
+
if: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch'}}
|
|
42
|
+
permissions:
|
|
43
|
+
pages: write
|
|
44
|
+
id-token: write
|
|
45
|
+
environment:
|
|
46
|
+
name: github-pages
|
|
47
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
48
|
+
runs-on: ubuntu-26.04-arm
|
|
49
|
+
needs: build-docs
|
|
50
|
+
steps:
|
|
51
|
+
- name: Deploy to GitHub Pages
|
|
52
|
+
id: deployment
|
|
53
|
+
uses: actions/deploy-pages@v5
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
|
|
2
|
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
|
|
3
|
+
|
|
4
|
+
name: Publish to PyPI
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
release:
|
|
8
|
+
types: [published]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
publish:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
permissions:
|
|
14
|
+
id-token: write
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
- name: Install uv
|
|
19
|
+
uses: astral-sh/setup-uv@v5
|
|
20
|
+
- name: Build Dists
|
|
21
|
+
run: uv build
|
|
22
|
+
- name: Publish Python distribution to PyPI
|
|
23
|
+
run: uv publish
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# This workflow will install Python dependencies, run tests and lint with a single version of Python
|
|
2
|
+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
|
|
3
|
+
|
|
4
|
+
name: Build and Test
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [ master ]
|
|
9
|
+
paths-ignore:
|
|
10
|
+
- 'docs/**'
|
|
11
|
+
pull_request:
|
|
12
|
+
branches: [ master ]
|
|
13
|
+
paths-ignore:
|
|
14
|
+
- 'docs/**'
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
build_test:
|
|
18
|
+
runs-on: ubuntu-26.04-arm
|
|
19
|
+
|
|
20
|
+
strategy:
|
|
21
|
+
matrix:
|
|
22
|
+
python-version: ["3.13", "3.14", "3.15"]
|
|
23
|
+
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
26
|
+
|
|
27
|
+
- name: Install uv and set the Python version
|
|
28
|
+
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
|
|
29
|
+
with:
|
|
30
|
+
python-version: ${{ matrix.python-version }}
|
|
31
|
+
|
|
32
|
+
- name: Install the project
|
|
33
|
+
run: uv sync --locked --all-extras --dev
|
|
34
|
+
|
|
35
|
+
- name: Lint with ruff
|
|
36
|
+
run: uv run ruff check
|
|
37
|
+
- name: Test with pytest
|
|
38
|
+
run: uv run pytest --cov-report xml --cov=cchdo
|
|
39
|
+
- name: Test typing
|
|
40
|
+
run: uv run ty check
|
|
41
|
+
- name: Upload coverage to Coveralls
|
|
42
|
+
uses: coverallsapp/github-action@v2.3.8
|
|
43
|
+
continue-on-error: true
|
|
44
|
+
with:
|
|
45
|
+
file: ./coverage.xml
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# See https://pre-commit.com for more information
|
|
2
|
+
# See https://pre-commit.com/hooks.html for more hooks
|
|
3
|
+
repos:
|
|
4
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
5
|
+
rev: v0.17.5
|
|
6
|
+
hooks:
|
|
7
|
+
- id: ruff
|
|
8
|
+
- id: ruff-format
|
|
9
|
+
- repo: https://github.com/astral-sh/ty-pre-commit
|
|
10
|
+
# ty version.
|
|
11
|
+
rev: v0.0.105
|
|
12
|
+
hooks:
|
|
13
|
+
- id: ty
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.13
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cchdo.auth
|
|
3
|
+
Version: 1.2.0
|
|
4
|
+
Author-email: cchdo <cchdo@ucsd.edu>
|
|
5
|
+
License-Expression: BSD-3-Clause
|
|
6
|
+
Project-URL: Homepage, https://cchdo.ucsd.edu/
|
|
7
|
+
Project-URL: Documentation, https://cchdo.github.io/auth
|
|
8
|
+
Project-URL: Repository, https://github.com/cchdo/auth.git
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering
|
|
18
|
+
Requires-Python: >=3.13
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE.md
|
|
21
|
+
Requires-Dist: requests>=2.23.0
|
|
22
|
+
Requires-Dist: click>=7.0.0
|
|
23
|
+
Requires-Dist: appdirs>=1.4.0
|
|
24
|
+
Provides-Extra: selftest
|
|
25
|
+
Requires-Dist: pytest; extra == "selftest"
|
|
26
|
+
Requires-Dist: pyfakefs; extra == "selftest"
|
|
27
|
+
Provides-Extra: docs
|
|
28
|
+
Requires-Dist: Sphinx; extra == "docs"
|
|
29
|
+
Requires-Dist: furo; extra == "docs"
|
|
30
|
+
Provides-Extra: complete
|
|
31
|
+
Requires-Dist: cchdo.auth[docs,selftest]; extra == "complete"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
cchdo.auth
|
|
35
|
+
============
|
|
@@ -1,21 +1,27 @@
|
|
|
1
|
+
import logging
|
|
1
2
|
import os
|
|
2
3
|
from configparser import ConfigParser, NoSectionError
|
|
3
|
-
import
|
|
4
|
-
from typing import Optional
|
|
4
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
5
5
|
|
|
6
|
+
from appdirs import AppDirs
|
|
6
7
|
from requests import PreparedRequest
|
|
7
8
|
from requests.auth import AuthBase
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
from cchdo.auth import config
|
|
9
11
|
|
|
10
12
|
try:
|
|
11
|
-
|
|
13
|
+
from google.colab import userdata # noqa # ty: ignore[import-not-found]
|
|
12
14
|
|
|
13
15
|
COLAB = True
|
|
14
16
|
except ImportError:
|
|
15
17
|
COLAB = False
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
__version__: str = "999"
|
|
20
|
+
|
|
21
|
+
try:
|
|
22
|
+
__version__ = version(__name__)
|
|
23
|
+
except PackageNotFoundError:
|
|
24
|
+
pass
|
|
19
25
|
|
|
20
26
|
logger = logging.getLogger(__name__)
|
|
21
27
|
|
|
@@ -141,11 +147,32 @@ def get_apikey() -> str:
|
|
|
141
147
|
|
|
142
148
|
Checks the following in order:
|
|
143
149
|
|
|
150
|
+
* Google colab userdata object (colab secrets)
|
|
151
|
+
* A variable named "CCHDO_AUTH_API_KEY" in the ipython user namespace (jupyter notebook cell)
|
|
144
152
|
* The environment variable ``CCHDO_AUTH_API_KEY``
|
|
145
153
|
* The local config file, which has a platform dependent location
|
|
146
154
|
"""
|
|
147
155
|
_migrate_uow_config()
|
|
148
156
|
|
|
157
|
+
if COLAB:
|
|
158
|
+
try:
|
|
159
|
+
return userdata.get("CCHDO_AUTH_API_KEY")
|
|
160
|
+
except userdata.SecretNotFoundError:
|
|
161
|
+
logger.warning("Could not find google colab secret 'CCHDO_AUTH_API_KEY'")
|
|
162
|
+
except userdata.NotebookAccessError:
|
|
163
|
+
logger.warning("Could access google colab secret 'CCHDO_AUTH_API_KEY'")
|
|
164
|
+
|
|
165
|
+
try:
|
|
166
|
+
from IPython import get_ipython
|
|
167
|
+
|
|
168
|
+
return get_ipython().user_ns["CCHDO_AUTH_API_KEY"]
|
|
169
|
+
except (
|
|
170
|
+
ModuleNotFoundError, # IPython is not installed
|
|
171
|
+
AttributeError, # this is not an IPython instance (get_ipython returned None)
|
|
172
|
+
KeyError, # The user doesn't have CCHDO_AUTH_API_KEY defined in a cell that has been run
|
|
173
|
+
):
|
|
174
|
+
pass
|
|
175
|
+
|
|
149
176
|
try:
|
|
150
177
|
return os.environ["CCHDO_AUTH_API_KEY"]
|
|
151
178
|
except KeyError:
|
|
@@ -156,7 +183,7 @@ def get_apikey() -> str:
|
|
|
156
183
|
except NoSectionError:
|
|
157
184
|
pass
|
|
158
185
|
|
|
159
|
-
logger.
|
|
186
|
+
logger.warning(
|
|
160
187
|
"An API Key could not be loaded from any source, many (not all) CCHDO API calls will fail"
|
|
161
188
|
)
|
|
162
189
|
return ""
|
|
@@ -177,13 +204,13 @@ class CCHDOAuth(AuthBase):
|
|
|
177
204
|
It is highly recomended that the :obj:`cchdo.auth.session.session` object be used instead of manually including this auth class
|
|
178
205
|
"""
|
|
179
206
|
|
|
180
|
-
def __init__(self, apikey:
|
|
207
|
+
def __init__(self, apikey: str | None = None):
|
|
181
208
|
if apikey is None:
|
|
182
209
|
apikey = get_apikey()
|
|
183
210
|
self._apikey = apikey
|
|
184
211
|
|
|
185
212
|
def __call__(self, r: PreparedRequest) -> PreparedRequest:
|
|
186
|
-
if r.url is not None and r.url.startswith(
|
|
213
|
+
if r.url is not None and r.url.startswith(tuple(config.PREFIXES)):
|
|
187
214
|
r.headers["X-Authentication-Token"] = self._apikey
|
|
188
215
|
|
|
189
216
|
return r
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
|
|
5
|
+
from .session import session as s
|
|
6
|
+
|
|
7
|
+
CCHDO_API = "https://cchdo.ucsd.edu/api/v1"
|
|
8
|
+
CRUISE_API = f"{CCHDO_API}/cruise"
|
|
9
|
+
FILE_API = f"{CCHDO_API}/file"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def json_edit_loop(metadata):
|
|
13
|
+
human_json = json.dumps(metadata, indent=2, sort_keys=True)
|
|
14
|
+
|
|
15
|
+
try_again = True
|
|
16
|
+
while try_again:
|
|
17
|
+
edited = click.edit(text=human_json, extension=".json")
|
|
18
|
+
|
|
19
|
+
if edited is None:
|
|
20
|
+
raise click.Abort()
|
|
21
|
+
|
|
22
|
+
try:
|
|
23
|
+
json.loads(edited)
|
|
24
|
+
try_again = False
|
|
25
|
+
except ValueError:
|
|
26
|
+
click.confirm(
|
|
27
|
+
"Edited cruise was not valid json, would you like try fixing?",
|
|
28
|
+
abort=True,
|
|
29
|
+
)
|
|
30
|
+
human_json = edited
|
|
31
|
+
|
|
32
|
+
return json.loads(edited)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@click.group()
|
|
36
|
+
def cli(): ...
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@cli.command()
|
|
40
|
+
@click.argument("apikey")
|
|
41
|
+
def apikey(apikey):
|
|
42
|
+
"""Write the API key to the config file, creating if needed"""
|
|
43
|
+
from . import CONFIG_FILE, _check_apikey, write_apikey
|
|
44
|
+
|
|
45
|
+
try:
|
|
46
|
+
_check_apikey(apikey)
|
|
47
|
+
except ValueError:
|
|
48
|
+
click.echo("The API key provided doesn't look valid")
|
|
49
|
+
raise click.Abort
|
|
50
|
+
write_apikey(apikey)
|
|
51
|
+
click.echo(f"API Key written to {CONFIG_FILE}")
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@cli.command()
|
|
55
|
+
@click.argument("expocode")
|
|
56
|
+
def edit_cruise(expocode):
|
|
57
|
+
"""Edit a cruise json in your $EDITOR"""
|
|
58
|
+
|
|
59
|
+
cruises = {c["expocode"]: c["id"] for c in s.get(CRUISE_API).json()["cruises"]}
|
|
60
|
+
try:
|
|
61
|
+
cruise_id = cruises[expocode]
|
|
62
|
+
except KeyError:
|
|
63
|
+
raise click.ClickException(f"Cruise not found: {expocode}")
|
|
64
|
+
|
|
65
|
+
click.echo(f"Loading cruise {cruise_id}")
|
|
66
|
+
|
|
67
|
+
cruise_json = s.get(f"{CRUISE_API}/{cruise_id}").json()
|
|
68
|
+
|
|
69
|
+
click.echo("Opening editor")
|
|
70
|
+
|
|
71
|
+
edited_metadata = json_edit_loop(cruise_json)
|
|
72
|
+
|
|
73
|
+
click.echo(f"PUTting to cruise: {cruise_id}")
|
|
74
|
+
|
|
75
|
+
while True:
|
|
76
|
+
r = s.put(f"{CRUISE_API}/{cruise_id}", json=edited_metadata)
|
|
77
|
+
|
|
78
|
+
if r.status_code != 201:
|
|
79
|
+
click.echo(f"Error message: {r.text}")
|
|
80
|
+
click.confirm(
|
|
81
|
+
"Edited cruise was rejected by the API, would you like try fixing?",
|
|
82
|
+
abort=True,
|
|
83
|
+
)
|
|
84
|
+
edited_metadata = json_edit_loop(edited_metadata)
|
|
85
|
+
continue
|
|
86
|
+
|
|
87
|
+
break
|
|
88
|
+
|
|
89
|
+
click.echo("Cruise Edit done!")
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
@cli.command()
|
|
93
|
+
@click.argument("file_id")
|
|
94
|
+
def edit_file(file_id):
|
|
95
|
+
"""Edit a file json in your $EDITOR
|
|
96
|
+
|
|
97
|
+
file_id is the internal id of the file to edit
|
|
98
|
+
"""
|
|
99
|
+
click.echo(f"Loading file {file_id}")
|
|
100
|
+
|
|
101
|
+
file_json = s.get(f"{FILE_API}/{file_id}").json()
|
|
102
|
+
|
|
103
|
+
click.echo("Opening editor")
|
|
104
|
+
|
|
105
|
+
edited_metadata = json_edit_loop(file_json)
|
|
106
|
+
|
|
107
|
+
click.echo(f"PUTting to file: {file_id}")
|
|
108
|
+
|
|
109
|
+
while True:
|
|
110
|
+
r = s.put(f"{FILE_API}/{file_id}", json=edited_metadata)
|
|
111
|
+
|
|
112
|
+
if r.status_code != 201:
|
|
113
|
+
click.echo(f"Error message: {r.text}")
|
|
114
|
+
click.confirm(
|
|
115
|
+
"Edited file was rejected by the API, would you like try fixing?",
|
|
116
|
+
abort=True,
|
|
117
|
+
)
|
|
118
|
+
edited_metadata = json_edit_loop(edited_metadata)
|
|
119
|
+
continue
|
|
120
|
+
|
|
121
|
+
break
|
|
122
|
+
|
|
123
|
+
click.echo("File Edit done!")
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
if __name__ == "__main__":
|
|
127
|
+
cli()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
PREFIXES: set[str] = {"https://cchdo.ucsd.edu/"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cchdo.auth
|
|
3
|
+
Version: 1.2.0
|
|
4
|
+
Author-email: cchdo <cchdo@ucsd.edu>
|
|
5
|
+
License-Expression: BSD-3-Clause
|
|
6
|
+
Project-URL: Homepage, https://cchdo.ucsd.edu/
|
|
7
|
+
Project-URL: Documentation, https://cchdo.github.io/auth
|
|
8
|
+
Project-URL: Repository, https://github.com/cchdo/auth.git
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering
|
|
18
|
+
Requires-Python: >=3.13
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE.md
|
|
21
|
+
Requires-Dist: requests>=2.23.0
|
|
22
|
+
Requires-Dist: click>=7.0.0
|
|
23
|
+
Requires-Dist: appdirs>=1.4.0
|
|
24
|
+
Provides-Extra: selftest
|
|
25
|
+
Requires-Dist: pytest; extra == "selftest"
|
|
26
|
+
Requires-Dist: pyfakefs; extra == "selftest"
|
|
27
|
+
Provides-Extra: docs
|
|
28
|
+
Requires-Dist: Sphinx; extra == "docs"
|
|
29
|
+
Requires-Dist: furo; extra == "docs"
|
|
30
|
+
Provides-Extra: complete
|
|
31
|
+
Requires-Dist: cchdo.auth[docs,selftest]; extra == "complete"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
cchdo.auth
|
|
35
|
+
============
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
.gitignore
|
|
2
2
|
.pre-commit-config.yaml
|
|
3
|
+
.python-version
|
|
3
4
|
LICENSE.md
|
|
4
5
|
README.md
|
|
5
6
|
pyproject.toml
|
|
6
|
-
|
|
7
|
-
setup.py
|
|
8
|
-
.devcontainer/Dockerfile
|
|
7
|
+
uv.lock
|
|
9
8
|
.devcontainer/devcontainer.json
|
|
9
|
+
.github/dependabot.yml
|
|
10
10
|
.github/workflows/build-docs.yml
|
|
11
11
|
.github/workflows/do-release.yml
|
|
12
12
|
.github/workflows/python-app.yml
|
|
13
13
|
cchdo.auth.egg-info/PKG-INFO
|
|
14
14
|
cchdo.auth.egg-info/SOURCES.txt
|
|
15
15
|
cchdo.auth.egg-info/dependency_links.txt
|
|
16
|
-
cchdo.auth.egg-info/namespace_packages.txt
|
|
17
|
-
cchdo.auth.egg-info/not-zip-safe
|
|
18
16
|
cchdo.auth.egg-info/requires.txt
|
|
17
|
+
cchdo.auth.egg-info/scm_file_list.json
|
|
18
|
+
cchdo.auth.egg-info/scm_version.json
|
|
19
19
|
cchdo.auth.egg-info/top_level.txt
|
|
20
20
|
cchdo/auth/__init__.py
|
|
21
21
|
cchdo/auth/__main__.py
|
|
22
|
-
cchdo/auth/
|
|
22
|
+
cchdo/auth/config.py
|
|
23
23
|
cchdo/auth/py.typed
|
|
24
24
|
cchdo/auth/session.py
|
|
25
25
|
cchdo/auth/test/__init__.py
|
|
@@ -31,4 +31,5 @@ docs/config.rst
|
|
|
31
31
|
docs/index.rst
|
|
32
32
|
docs/installation.rst
|
|
33
33
|
docs/make.bat
|
|
34
|
+
docs/secrets.svg
|
|
34
35
|
docs/usage.rst
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"files": [
|
|
3
|
+
".devcontainer/devcontainer.json",
|
|
4
|
+
".github/dependabot.yml",
|
|
5
|
+
".github/workflows/build-docs.yml",
|
|
6
|
+
".github/workflows/do-release.yml",
|
|
7
|
+
".github/workflows/python-app.yml",
|
|
8
|
+
".gitignore",
|
|
9
|
+
".pre-commit-config.yaml",
|
|
10
|
+
".python-version",
|
|
11
|
+
"LICENSE.md",
|
|
12
|
+
"README.md",
|
|
13
|
+
"cchdo/auth/__init__.py",
|
|
14
|
+
"cchdo/auth/__main__.py",
|
|
15
|
+
"cchdo/auth/config.py",
|
|
16
|
+
"cchdo/auth/py.typed",
|
|
17
|
+
"cchdo/auth/session.py",
|
|
18
|
+
"cchdo/auth/test/__init__.py",
|
|
19
|
+
"cchdo/auth/test/test_Auth.py",
|
|
20
|
+
"docs/Makefile",
|
|
21
|
+
"docs/api.rst",
|
|
22
|
+
"docs/conf.py",
|
|
23
|
+
"docs/config.rst",
|
|
24
|
+
"docs/index.rst",
|
|
25
|
+
"docs/installation.rst",
|
|
26
|
+
"docs/make.bat",
|
|
27
|
+
"docs/secrets.svg",
|
|
28
|
+
"docs/usage.rst",
|
|
29
|
+
"pyproject.toml",
|
|
30
|
+
"uv.lock"
|
|
31
|
+
]
|
|
32
|
+
}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
# -- Project information -----------------------------------------------------
|
|
19
19
|
|
|
20
20
|
project = "cchdo.auth"
|
|
21
|
-
copyright = "2020-
|
|
21
|
+
copyright = "2020-2022, Regents of the University of California"
|
|
22
22
|
author = "Andrew Barna"
|
|
23
23
|
|
|
24
24
|
|