megfile 3.1.4__py3-none-any.whl → 3.1.5__py3-none-any.whl
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.
- megfile/cli.py +7 -2
- megfile/s3_path.py +12 -3
- megfile/version.py +1 -1
- {megfile-3.1.4.dist-info → megfile-3.1.5.dist-info}/METADATA +2 -1
- {megfile-3.1.4.dist-info → megfile-3.1.5.dist-info}/RECORD +10 -10
- {megfile-3.1.4.dist-info → megfile-3.1.5.dist-info}/LICENSE +0 -0
- {megfile-3.1.4.dist-info → megfile-3.1.5.dist-info}/LICENSE.pyre +0 -0
- {megfile-3.1.4.dist-info → megfile-3.1.5.dist-info}/WHEEL +0 -0
- {megfile-3.1.4.dist-info → megfile-3.1.5.dist-info}/entry_points.txt +0 -0
- {megfile-3.1.4.dist-info → megfile-3.1.5.dist-info}/top_level.txt +0 -0
megfile/cli.py
CHANGED
|
@@ -589,6 +589,7 @@ def _safe_makedirs(path: str):
|
|
|
589
589
|
@click.argument("aws_access_key_id")
|
|
590
590
|
@click.argument("aws_secret_access_key")
|
|
591
591
|
@click.option("-e", "--endpoint-url", help="endpoint-url")
|
|
592
|
+
@click.option("-st", "--session-token", help="session-token")
|
|
592
593
|
@click.option("-as", "--addressing-style", help="addressing-style")
|
|
593
594
|
@click.option("-sv", "--signature-version", help="signature-version")
|
|
594
595
|
@click.option("--no-cover", is_flag=True, help="Not cover the same-name config")
|
|
@@ -598,6 +599,7 @@ def s3(
|
|
|
598
599
|
aws_access_key_id,
|
|
599
600
|
aws_secret_access_key,
|
|
600
601
|
endpoint_url,
|
|
602
|
+
session_token,
|
|
601
603
|
addressing_style,
|
|
602
604
|
signature_version,
|
|
603
605
|
no_cover,
|
|
@@ -608,6 +610,7 @@ def s3(
|
|
|
608
610
|
"name": profile_name,
|
|
609
611
|
"aws_access_key_id": aws_access_key_id,
|
|
610
612
|
"aws_secret_access_key": aws_secret_access_key,
|
|
613
|
+
"aws_session_token": session_token,
|
|
611
614
|
}
|
|
612
615
|
s3_config_dict = {
|
|
613
616
|
"endpoint_url": endpoint_url,
|
|
@@ -615,14 +618,16 @@ def s3(
|
|
|
615
618
|
"signature_version": signature_version,
|
|
616
619
|
}
|
|
617
620
|
|
|
621
|
+
config_dict = {k: v for k, v in config_dict.items() if v}
|
|
618
622
|
s3_config_dict = {k: v for k, v in s3_config_dict.items() if v}
|
|
619
623
|
if s3_config_dict:
|
|
620
624
|
config_dict["s3"] = s3_config_dict
|
|
621
625
|
|
|
622
626
|
def dumps(config_dict: dict) -> str:
|
|
623
627
|
content = "[{}]\n".format(config_dict["name"])
|
|
624
|
-
for key in ("aws_access_key_id", "aws_secret_access_key"):
|
|
625
|
-
|
|
628
|
+
for key in ("aws_access_key_id", "aws_secret_access_key", "session_token"):
|
|
629
|
+
if key in config_dict:
|
|
630
|
+
content += "{} = {}\n".format(key, config_dict[key])
|
|
626
631
|
if "s3" in config_dict.keys():
|
|
627
632
|
content += "\ns3 = \n"
|
|
628
633
|
for key, value in config_dict["s3"].items():
|
megfile/s3_path.py
CHANGED
|
@@ -235,10 +235,16 @@ def get_access_token(profile_name=None):
|
|
|
235
235
|
if profile_name
|
|
236
236
|
else "AWS_SECRET_ACCESS_KEY"
|
|
237
237
|
)
|
|
238
|
+
session_token_env_name = (
|
|
239
|
+
f"{profile_name}__AWS_SESSION_TOKEN".upper()
|
|
240
|
+
if profile_name
|
|
241
|
+
else "AWS_SESSION_TOKEN"
|
|
242
|
+
)
|
|
238
243
|
access_key = os.getenv(access_key_env_name)
|
|
239
244
|
secret_key = os.getenv(secret_key_env_name)
|
|
245
|
+
session_token = os.getenv(session_token_env_name)
|
|
240
246
|
if access_key and secret_key:
|
|
241
|
-
return access_key, secret_key
|
|
247
|
+
return access_key, secret_key, session_token
|
|
242
248
|
|
|
243
249
|
try:
|
|
244
250
|
credentials = get_s3_session(profile_name=profile_name).get_credentials()
|
|
@@ -249,7 +255,9 @@ def get_access_token(profile_name=None):
|
|
|
249
255
|
access_key = credentials.access_key
|
|
250
256
|
if not secret_key:
|
|
251
257
|
secret_key = credentials.secret_key
|
|
252
|
-
|
|
258
|
+
if not session_token:
|
|
259
|
+
session_token = credentials.token
|
|
260
|
+
return access_key, secret_key, session_token
|
|
253
261
|
|
|
254
262
|
|
|
255
263
|
def get_s3_client(
|
|
@@ -290,7 +298,7 @@ def get_s3_client(
|
|
|
290
298
|
botocore.config.Config(s3={"addressing_style": addressing_style})
|
|
291
299
|
)
|
|
292
300
|
|
|
293
|
-
access_key, secret_key = get_access_token(profile_name)
|
|
301
|
+
access_key, secret_key, session_token = get_access_token(profile_name)
|
|
294
302
|
try:
|
|
295
303
|
session = get_s3_session(profile_name=profile_name)
|
|
296
304
|
except botocore.exceptions.ProfileNotFound:
|
|
@@ -301,6 +309,7 @@ def get_s3_client(
|
|
|
301
309
|
config=config,
|
|
302
310
|
aws_access_key_id=access_key,
|
|
303
311
|
aws_secret_access_key=secret_key,
|
|
312
|
+
aws_session_token=session_token,
|
|
304
313
|
)
|
|
305
314
|
client = _patch_make_request(client)
|
|
306
315
|
return client
|
megfile/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
VERSION = "3.1.
|
|
1
|
+
VERSION = "3.1.5"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: megfile
|
|
3
|
-
Version: 3.1.
|
|
3
|
+
Version: 3.1.5
|
|
4
4
|
Summary: Megvii file operation library
|
|
5
5
|
Author-email: megvii <megfile@megvii.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/megvii-research/megfile
|
|
@@ -166,6 +166,7 @@ You can use environments and configuration file for configuration, and priority
|
|
|
166
166
|
You can use environments to setup authentication credentials for your `s3` account:
|
|
167
167
|
- `AWS_ACCESS_KEY_ID`: access key
|
|
168
168
|
- `AWS_SECRET_ACCESS_KEY`: secret key
|
|
169
|
+
- `AWS_SESSION_TOKEN`: session token
|
|
169
170
|
- `OSS_ENDPOINT` / `AWS_ENDPOINT_URL_S3` / `AWS_ENDPOINT_URL`: endpoint url of s3
|
|
170
171
|
- `AWS_S3_ADDRESSING_STYLE`: addressing style
|
|
171
172
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
docs/conf.py,sha256=sfDSly5jO8W_RmuAptOIp4hd8dNcO-9a5XrHTbxFnNo,2448
|
|
2
2
|
megfile/__init__.py,sha256=i2Lbq_VxIgppaqwkxG0_H35dRfcjJ4mCYWjprOf4hHo,7318
|
|
3
|
-
megfile/cli.py,sha256=
|
|
3
|
+
megfile/cli.py,sha256=miI1fEHY3zBxWwwN5F5AHjO14-AI920oPxD4sfi94gY,23465
|
|
4
4
|
megfile/config.py,sha256=_SkJRaVWUdfW1Q9uX0vao-6YVQKJtfej22Z8DykuRps,2331
|
|
5
5
|
megfile/errors.py,sha256=KyHvK3CgiSgiXT_5kqKa7Nb8Bdwh7U6mBh_H7Gj-Z84,14125
|
|
6
6
|
megfile/fs.py,sha256=dgj5fW-EEzQNdjMF2tkB5DjXu3iHQbtLi5PSIMxR8fc,11966
|
|
@@ -12,14 +12,14 @@ megfile/http_path.py,sha256=BhMNjQVB85IaCGGIKzgEfY73mAVdCzJP08W1RuGeMRA,16119
|
|
|
12
12
|
megfile/interfaces.py,sha256=7C53Q2FAVFmOEnplfplvWqHab29HJE5RQnpfdb4loVY,8679
|
|
13
13
|
megfile/pathlike.py,sha256=vKuCMlSAPYNSojp03wEj2i3Cq3E3ROp_-UkkdgBElws,30802
|
|
14
14
|
megfile/s3.py,sha256=7SdfLjAePVh-bpRyuj566VB4Qa7KP86rCJGzYANR7wQ,13008
|
|
15
|
-
megfile/s3_path.py,sha256=
|
|
15
|
+
megfile/s3_path.py,sha256=YvIRVI4d6kd2m2wvcIqiu43nPOYZpaPgG9-BospF81w,93803
|
|
16
16
|
megfile/sftp.py,sha256=vyDnYXX3i1j2fhXMC8YCeX-66MDb9wrBQQjQVhZx0uo,13004
|
|
17
17
|
megfile/sftp_path.py,sha256=4tByWvUJK1KBJoa3t5aoWYnZpaRWN9nQIE6ZyiGHrbk,53519
|
|
18
18
|
megfile/smart.py,sha256=Vr4R7HpjXjt587KOc2-1QGbQ5EsZ48YRzCaK0rz3IS0,36108
|
|
19
19
|
megfile/smart_path.py,sha256=22ZTrA7j9Kd5PJsUJOxBdGg0Uu5FxwdT_XQjQDxUHo4,7637
|
|
20
20
|
megfile/stdio.py,sha256=UYe-h440Wc4f5COOzOTG1svnp5nFzrfpixehJ0_0_NY,653
|
|
21
21
|
megfile/stdio_path.py,sha256=7jzVdreamO18yBWZM7Pp71cO7GmrYb0M0qyQde2Ypq4,2706
|
|
22
|
-
megfile/version.py,sha256=
|
|
22
|
+
megfile/version.py,sha256=kh8D3nOB4xuR3KqckCcukx60UxptlmvEx5kjmgZinIA,19
|
|
23
23
|
megfile/lib/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
24
24
|
megfile/lib/base_prefetch_reader.py,sha256=CaYWuiKmlk4Utr0IFDPwPC58wV2jBAhqpxhwhRHc734,13652
|
|
25
25
|
megfile/lib/combine_reader.py,sha256=uSzo3PmhD5ck6_Vv6dFU5vVx4boeA97VS-puPyhF_BE,4657
|
|
@@ -46,10 +46,10 @@ megfile/utils/__init__.py,sha256=NfO5vNxfeceGvMB3dgZNudyPFTmPY096JbC4iYroX6o,900
|
|
|
46
46
|
megfile/utils/mutex.py,sha256=asb8opGLgK22RiuBJUnfsvB8LnMmodP8KzCVHKmQBWA,2561
|
|
47
47
|
scripts/convert_results_to_sarif.py,sha256=nDiOfsedb22Ps7ZodmYdlXZlxv54fRxCQgOZsB2OkNk,2833
|
|
48
48
|
scripts/generate_file.py,sha256=-mTcBiqiQ1juvqojVfVZ-uZWgpANHJNdhrF7s68zNfc,10903
|
|
49
|
-
megfile-3.1.
|
|
50
|
-
megfile-3.1.
|
|
51
|
-
megfile-3.1.
|
|
52
|
-
megfile-3.1.
|
|
53
|
-
megfile-3.1.
|
|
54
|
-
megfile-3.1.
|
|
55
|
-
megfile-3.1.
|
|
49
|
+
megfile-3.1.5.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
|
50
|
+
megfile-3.1.5.dist-info/LICENSE.pyre,sha256=9lf5nT-5ZH25JijpYAequ0bl8E8z5JmZB1qrjiUMp84,1080
|
|
51
|
+
megfile-3.1.5.dist-info/METADATA,sha256=jPBOY1WWbh-Jxdam48x2RxcXGVV2liPW4kQTw8VtBl0,9178
|
|
52
|
+
megfile-3.1.5.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
|
53
|
+
megfile-3.1.5.dist-info/entry_points.txt,sha256=M6ZWSSv5_5_QtIpZafy3vq7WuOJ_5dSGQQnEZbByt2Q,49
|
|
54
|
+
megfile-3.1.5.dist-info/top_level.txt,sha256=oTnYXo1Z3V61qSWAKtnY9RkDgRSHvfRN38FQae6E0W0,50
|
|
55
|
+
megfile-3.1.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|