eocube 0.0.1__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.
eocube-0.0.1/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
eocube-0.0.1/NOTICE ADDED
@@ -0,0 +1,98 @@
1
+ Name Version License URL
2
+ Authlib 1.5.1 BSD License https://github.com/lepture/authlib
3
+ CacheControl 0.14.2 Apache Software License https://pypi.org/project/CacheControl/
4
+ Jinja2 3.1.6 BSD License https://github.com/pallets/jinja/
5
+ MarkupSafe 3.0.2 BSD License https://github.com/pallets/markupsafe/
6
+ PyYAML 6.0.2 MIT License https://pyyaml.org/
7
+ Pygments 2.19.1 BSD License https://pygments.org
8
+ affine 2.4.0 BSD License https://github.com/rasterio/affine
9
+ aiobotocore 2.21.1 Apache Software License https://github.com/aio-libs/aiobotocore
10
+ aiohappyeyeballs 2.6.1 Python Software Foundation License https://github.com/aio-libs/aiohappyeyeballs
11
+ aiohttp 3.11.14 Apache Software License https://github.com/aio-libs/aiohttp
12
+ aioitertools 0.12.0 MIT License UNKNOWN
13
+ aiosignal 1.3.2 Apache Software License https://github.com/aio-libs/aiosignal
14
+ annotated-types 0.7.0 MIT License https://github.com/annotated-types/annotated-types
15
+ attrs 25.3.0 UNKNOWN https://www.attrs.org/en/stable/changelog.html
16
+ black 25.1.0 MIT License https://github.com/psf/black
17
+ boolean.py 4.0 BSD-2-Clause https://github.com/bastikr/boolean.py
18
+ botocore 1.37.1 Apache Software License https://github.com/boto/botocore
19
+ build 1.2.2.post1 MIT License https://build.pypa.io
20
+ certifi 2025.1.31 Mozilla Public License 2.0 (MPL 2.0) https://github.com/certifi/python-certifi
21
+ cffi 1.17.1 MIT License http://cffi.readthedocs.org
22
+ charset-normalizer 3.4.1 MIT License https://github.com/jawah/charset_normalizer/blob/master/CHANGELOG.md
23
+ click 8.1.8 BSD License https://github.com/pallets/click/
24
+ click-plugins 1.1.1 BSD License https://github.com/click-contrib/click-plugins
25
+ cligj 0.7.2 BSD https://github.com/mapbox/cligj
26
+ cloudpickle 3.1.1 BSD License https://github.com/cloudpipe/cloudpickle
27
+ cryptography 44.0.2 Apache Software License; BSD License https://github.com/pyca/cryptography
28
+ cyclonedx-python-lib 8.9.0 Apache Software License https://github.com/CycloneDX/cyclonedx-python-lib/#readme
29
+ dask 2025.3.0 BSD License https://github.com/dask/dask/
30
+ defusedxml 0.7.1 Python Software Foundation License https://github.com/tiran/defusedxml
31
+ distributed 2025.3.0 BSD License https://distributed.dask.org
32
+ dparse 0.6.4 MIT License https://github.com/pyupio/dparse
33
+ filelock 3.16.1 The Unlicense (Unlicense) https://github.com/tox-dev/py-filelock
34
+ frozenlist 1.5.0 Apache Software License https://github.com/aio-libs/frozenlist
35
+ fsspec 2025.3.0 BSD License https://github.com/fsspec/filesystem_spec
36
+ idna 3.10 BSD License https://github.com/kjd/idna
37
+ jmespath 1.0.1 MIT License https://github.com/jmespath/jmespath.py
38
+ joblib 1.4.2 BSD License https://joblib.readthedocs.io
39
+ jsonschema 4.23.0 MIT License https://github.com/python-jsonschema/jsonschema
40
+ jsonschema-specifications 2024.10.1 MIT License https://github.com/python-jsonschema/jsonschema-specifications
41
+ license-expression 30.4.1 Apache-2.0 https://github.com/aboutcode-org/license-expression
42
+ locket 1.0.0 BSD License http://github.com/mwilliamson/locket.py
43
+ markdown-it-py 3.0.0 MIT License https://github.com/executablebooks/markdown-it-py
44
+ marshmallow 3.26.1 MIT License https://github.com/marshmallow-code/marshmallow
45
+ mdurl 0.1.2 MIT License https://github.com/executablebooks/mdurl
46
+ msgpack 1.1.0 Apache Software License https://msgpack.org/
47
+ multidict 6.2.0 Apache Software License https://github.com/aio-libs/multidict
48
+ mypy-extensions 1.0.0 MIT License https://github.com/python/mypy_extensions
49
+ nltk 3.9.1 Apache Software License https://www.nltk.org/
50
+ numpy 2.2.4 BSD License https://numpy.org
51
+ packageurl-python 0.16.0 MIT License https://github.com/package-url/packageurl-python
52
+ packaging 24.2 Apache Software License; BSD License https://github.com/pypa/packaging
53
+ pandas 2.2.3 BSD License https://pandas.pydata.org
54
+ partd 1.4.2 BSD http://github.com/dask/partd/
55
+ pathspec 0.12.1 Mozilla Public License 2.0 (MPL 2.0) UNKNOWN
56
+ pip-api 0.0.34 Apache Software License http://github.com/di/pip-api
57
+ pip-requirements-parser 32.0.1 MIT https://github.com/nexB/pip-requirements-parser
58
+ pip-tools 7.4.1 BSD License https://github.com/jazzband/pip-tools/
59
+ pip_audit 2.8.0 Apache Software License https://pypi.org/project/pip-audit/
60
+ platformdirs 4.3.7 MIT License https://github.com/tox-dev/platformdirs
61
+ propcache 0.3.0 Apache Software License https://github.com/aio-libs/propcache
62
+ psutil 6.1.1 BSD License https://github.com/giampaolo/psutil
63
+ py-serializable 1.1.2 Apache Software License https://github.com/madpah/serializable#readme
64
+ pycparser 2.22 BSD License https://github.com/eliben/pycparser
65
+ pydantic 2.9.2 MIT License https://github.com/pydantic/pydantic
66
+ pydantic_core 2.23.4 MIT License https://github.com/pydantic/pydantic-core
67
+ pyparsing 3.2.1 MIT License https://github.com/pyparsing/pyparsing/
68
+ pyproject_hooks 1.2.0 MIT License https://github.com/pypa/pyproject-hooks
69
+ pystac 1.12.2 Apache Software License https://github.com/stac-utils/pystac
70
+ pystac-client 0.8.6 Apache Software License https://github.com/stac-utils/pystac-client
71
+ python-dateutil 2.9.0.post0 Apache Software License; BSD License https://github.com/dateutil/dateutil
72
+ pytz 2025.1 MIT License http://pythonhosted.org/pytz
73
+ rasterio 1.4.3 BSD License https://github.com/rasterio/rasterio
74
+ referencing 0.36.2 UNKNOWN https://github.com/python-jsonschema/referencing
75
+ regex 2024.11.6 Apache Software License https://github.com/mrabarnett/mrab-regex
76
+ requests 2.32.3 Apache Software License https://requests.readthedocs.io
77
+ rich 13.9.4 MIT License https://github.com/Textualize/rich
78
+ rpds-py 0.23.1 MIT https://github.com/crate-py/rpds
79
+ ruamel.yaml 0.18.10 MIT License https://sourceforge.net/p/ruamel-yaml/code/ci/default/tree/
80
+ s3fs 2025.3.0 BSD License http://github.com/fsspec/s3fs/
81
+ safety 3.3.1 MIT License https://safetycli.com
82
+ safety-schemas 0.0.11 MIT License https://github.com/pyupio/safety_schemas
83
+ shellingham 1.5.4 ISC License (ISCL) https://github.com/sarugaku/shellingham
84
+ six 1.17.0 MIT License https://github.com/benjaminp/six
85
+ sortedcontainers 2.4.0 Apache Software License http://www.grantjenks.com/docs/sortedcontainers/
86
+ tblib 3.0.0 BSD License https://github.com/ionelmc/python-tblib
87
+ toml 0.10.2 MIT License https://github.com/uiri/toml
88
+ toolz 1.0.0 BSD License https://github.com/pytoolz/toolz/
89
+ tornado 6.4.2 Apache Software License http://www.tornadoweb.org/
90
+ tqdm 4.67.1 MIT License; Mozilla Public License 2.0 (MPL 2.0) https://tqdm.github.io
91
+ typer 0.15.2 MIT License https://github.com/fastapi/typer
92
+ typing_extensions 4.12.2 Python Software Foundation License https://github.com/python/typing_extensions
93
+ tzdata 2025.1 Apache Software License https://github.com/python/tzdata
94
+ urllib3 2.3.0 MIT License https://github.com/urllib3/urllib3/blob/main/CHANGES.rst
95
+ wrapt 1.17.2 BSD License https://github.com/GrahamDumpleton/wrapt
96
+ xarray 2025.3.0 Apache Software License https://xarray.dev/
97
+ yarl 1.18.3 Apache Software License https://github.com/aio-libs/yarl
98
+ zict 3.0.0 BSD License http://zict.readthedocs.io/en/latest/
eocube-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,28 @@
1
+ Metadata-Version: 2.3
2
+ Name: eocube
3
+ Version: 0.0.1
4
+ Summary: Support tool and library for EOCube.Ro
5
+ License: Apache-2.0
6
+ Author: Marian Neagul
7
+ Author-email: marian.neagul@e-uvt.ro
8
+ Requires-Python: >=3.10,<4.0
9
+ Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Provides-Extra: auth
16
+ Provides-Extra: cli
17
+ Provides-Extra: cube
18
+ Provides-Extra: dev
19
+ Provides-Extra: raster
20
+ Provides-Extra: services
21
+ Requires-Dist: click
22
+ Requires-Dist: fsspec
23
+ Requires-Dist: pystac
24
+ Requires-Dist: pystac-client
25
+ Requires-Dist: python-dateutil
26
+ Requires-Dist: python-i18n
27
+ Requires-Dist: requests
28
+ Requires-Dist: s3fs
@@ -0,0 +1,108 @@
1
+ [tool.poetry]
2
+ name = "eocube"
3
+ version = "0.0.1"
4
+ description = "Support tool and library for EOCube.Ro"
5
+ license = "Apache-2.0"
6
+ authors = [
7
+ "Marian Neagul <marian.neagul@e-uvt.ro>"
8
+ ]
9
+
10
+ [tool.poetry.dependencies]
11
+ python = "^3.10" # Specify the compatible Python version
12
+ click = "*"
13
+ requests = "*"
14
+ python-dateutil = "*"
15
+ s3fs = "*"
16
+ fsspec = "*"
17
+ pystac = "*"
18
+ pystac-client = "*"
19
+ python-i18n = "*"
20
+
21
+ [tool.poetry.extras]
22
+ auth = ["authlib"]
23
+ cli = ["keyring", "authlib", "flask"]
24
+ raster = ["numpy", "rasterio", "xarray"]
25
+ cube = ["numpy", "rasterio", "xarray", "authlib", "dask"]
26
+ services = ["owslib", "geopandas"]
27
+ dev = ["black", "pip-tools", "pip-audit", "safety", "pip-licenses"]
28
+
29
+ [tool.poetry.scripts]
30
+ eocube = "eocube.cli.main:cli"
31
+
32
+ [build-system]
33
+ requires = ["poetry-core>=1.1.0"]
34
+ build-backend = "poetry.core.masonry.api"
35
+
36
+
37
+ #[project]
38
+ #name = "eocube"
39
+ #version = "0.0.1"
40
+ #license = {text = "Apache-2.0"}
41
+ #
42
+ #dependencies = [
43
+ # "click",
44
+ # "requests",
45
+ # "python-dateutil",
46
+ # "s3fs",
47
+ # "fsspec",
48
+ # "pystac",
49
+ # "pystac-client",
50
+ # "python-i18n"
51
+ #]
52
+ #
53
+ #[project.optional-dependencies]
54
+ #auth = [
55
+ # "authlib",
56
+ #]
57
+ #
58
+ #cli = [
59
+ # "keyring",
60
+ # "authlib",
61
+ # "flask"
62
+ #]
63
+ #
64
+ #raster = [
65
+ # "numpy",
66
+ # "rasterio",
67
+ # "xarray"
68
+ #]
69
+ #
70
+ #cube = [
71
+ # "numpy",
72
+ # "rasterio",
73
+ # "xarray",
74
+ # "authlib",
75
+ # "dask[distributed]"
76
+ #]
77
+ #
78
+ #services = [
79
+ # "owslib",
80
+ # "geopandas"
81
+ #]
82
+ #
83
+ #dev = [
84
+ # "black",
85
+ # "pip-tools",
86
+ # "pip-audit",
87
+ # "safety",
88
+ # "pip-licenses"
89
+ #]
90
+ #
91
+ #[project.scripts]
92
+ #eocube = "eocube.cli.main:cli"
93
+ #
94
+ #[tool.black]
95
+ #line-length = 88
96
+ #target-version = ['py310']
97
+ #exclude = '''
98
+ #/(
99
+ # \.git
100
+ # | \.tox
101
+ # | \.venv
102
+ # | _build
103
+ # | dist
104
+ # | venv
105
+ #)/
106
+ #'''
107
+ #
108
+ #
File without changes
File without changes
@@ -0,0 +1,97 @@
1
+ import os
2
+ import threading
3
+ import time
4
+ import logging
5
+ import click
6
+ import requests
7
+ import webbrowser
8
+ import keyring
9
+ import sys
10
+ from flask import Flask, request
11
+ from eocube.integrations.auth.client import ROCS_DISCOVERY_URL
12
+ from authlib.integrations.requests_client import OAuth2Session
13
+
14
+
15
+ EOCUBE_CLI_CLIENT_ID="eocube-cli"
16
+ EOCUBE_CLI_REDIRECT_URI="http://localhost:5123/callback"
17
+
18
+ login_done = threading.Event()
19
+
20
+ authorize_url = None
21
+ token_url = None
22
+ @click.group("auth")
23
+ def auth_cli():
24
+ """Authentication related functionality"""
25
+
26
+
27
+ @auth_cli.command("login")
28
+ def login():
29
+ """Login to EOCube.ro"""
30
+
31
+ logging.getLogger('werkzeug').setLevel(logging.ERROR)
32
+
33
+ app = Flask(__name__)
34
+ server_thread = None
35
+
36
+
37
+ def start_oauth_flow():
38
+ global authorize_url
39
+ global token_url
40
+ oauth = OAuth2Session(EOCUBE_CLI_CLIENT_ID, redirect_uri=EOCUBE_CLI_REDIRECT_URI)
41
+ metadata = requests.get(ROCS_DISCOVERY_URL).json()
42
+ authorize_url = metadata["authorization_endpoint"]
43
+ token_url = metadata["token_endpoint"]
44
+ uri, state = oauth.create_authorization_url(
45
+ authorize_url,
46
+ scope='openid offline_access'
47
+ )
48
+ webbrowser.open(uri)
49
+ return oauth
50
+
51
+ def run_flask():
52
+ app.run(port=5123, use_reloader=False)
53
+
54
+ def shutdown_server():
55
+ func = request.environ.get('werkzeug.server.shutdown')
56
+ if func:
57
+ func()
58
+
59
+ @app.route("/callback")
60
+ def callback():
61
+ global oauth_token
62
+ global token_url
63
+
64
+ code = request.args.get("code")
65
+ if not code:
66
+ return "❌ No code received. Something went wrong."
67
+
68
+ token = app.oauth_session.fetch_token(
69
+ token_url,
70
+ code=code
71
+ )
72
+
73
+ oauth_token = token # salvează tokenul pt codul principal
74
+ login_done.set()
75
+ shutdown_server() # oprește Flask
76
+
77
+
78
+ return """
79
+ ✅ Te-ai autentificat!<br><br>
80
+ Poți închide fereastra.<br>
81
+ Vezi terminalul pentru token-uri.
82
+ """
83
+
84
+ print("🚀 Începem loginul...")
85
+ #global server_thread
86
+ server_thread = threading.Thread(target=run_flask)
87
+ server_thread.start()
88
+ time.sleep(1)
89
+ app.oauth_session = start_oauth_flow()
90
+ login_done.wait()
91
+
92
+ keyring.set_password("eocube-cli", "offline-refresh-token", oauth_token["refresh_token"])
93
+ keyring.set_password("eocube-cli", "access-token",
94
+ oauth_token["access_token"])
95
+ print("🔐 Saved tokens in keyring")
96
+ os._exit(0)
97
+
@@ -0,0 +1,46 @@
1
+ # Copyright 2025 West University of Timisoara
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ import importlib
16
+ import click
17
+
18
+ from eocube.utils.geospatialorg.cli import register as register_geospatialorg
19
+ from .auth import auth_cli
20
+
21
+ def is_installed(package_name):
22
+ try:
23
+ importlib.import_module(package_name)
24
+ return True
25
+ except ImportError:
26
+ return False
27
+
28
+
29
+ @click.group()
30
+ def cli():
31
+ pass
32
+
33
+
34
+ @cli.group()
35
+ def services():
36
+ """Various Services"""
37
+ pass
38
+
39
+
40
+ cli.add_command(services)
41
+ cli.add_command(auth_cli)
42
+
43
+ register_geospatialorg(services)
44
+
45
+ if __name__ == "__main__":
46
+ cli()
File without changes
File without changes