Skip to content

Commit 6218448

Browse files
committed
python-ecosys/uminio/uminio: Format uminio code.
This commit remove redundant lines and correct formatting for code in python-ecosys/uminio/uminio/__init__.py. Signed-off-by: Luigi Palumbo <[email protected]>
1 parent afcc021 commit 6218448

File tree

1 file changed

+5
-28
lines changed

1 file changed

+5
-28
lines changed

python-ecosys/uminio/uminio/__init__.py

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,6 @@
1212
import utime
1313
import ntptime
1414

15-
# --- MinIO Configuration ---
16-
# IMPORTANT: Fill in these details for your MinIO server.
17-
MINIO_ENDPOINT = "192.168.1.100:9000" # Your MinIO server IP address and port
18-
MINIO_ACCESS_KEY = "YOUR_ACCESS_KEY" # Your MinIO access key
19-
MINIO_SECRET_KEY = "YOUR_SECRET_KEY" # Your MinIO secret key
20-
MINIO_BUCKET = "micropython-uploads" # The bucket you want to upload to
21-
MINIO_USE_HTTPS = False # Set to True if your MinIO server uses HTTPS
22-
23-
# MinIO is S3-compatible, but the signing process still requires a region.
24-
# 'us-east-1' is a safe default that works for most MinIO setups.
25-
MINIO_REGION = "us-east-1"
26-
2715

2816
class MinioClient:
2917
"""A client for interacting with MinIO object storage.
@@ -87,13 +75,9 @@ def _get_signature_key(self, date_stamp_string, service_name_string="s3"):
8775
Derives the signing key from the secret key.
8876
"""
8977
k_secret_bytes = ("AWS4" + self.secret_key).encode("utf-8")
90-
k_date_bytes = self._hmac_sha256(
91-
k_secret_bytes, date_stamp_string.encode("utf-8")
92-
)
78+
k_date_bytes = self._hmac_sha256(k_secret_bytes, date_stamp_string.encode("utf-8"))
9379
k_region_bytes = self._hmac_sha256(k_date_bytes, self.region.encode("utf-8"))
94-
k_service_bytes = self._hmac_sha256(
95-
k_region_bytes, service_name_string.encode("utf-8")
96-
)
80+
k_service_bytes = self._hmac_sha256(k_region_bytes, service_name_string.encode("utf-8"))
9781
k_signing_bytes = self._hmac_sha256(k_service_bytes, b"aws4_request")
9882
return k_signing_bytes
9983

@@ -192,22 +176,15 @@ def upload_file(
192176
hashed_canonical_request_bytes = uhashlib.sha256(
193177
canonical_request.encode("utf-8")
194178
).digest()
195-
hashed_canonical_request_hex = ubinascii.hexlify(
196-
hashed_canonical_request_bytes
197-
).decode()
179+
hashed_canonical_request_hex = ubinascii.hexlify(hashed_canonical_request_bytes).decode()
198180

199181
string_to_sign = (
200-
f"{algorithm}\n"
201-
f"{amz_date}\n"
202-
f"{credential_scope}\n"
203-
f"{hashed_canonical_request_hex}"
182+
f"{algorithm}\n{amz_date}\n{credential_scope}\n{hashed_canonical_request_hex}"
204183
)
205184

206185
# ---- Task 3: Calculate Signature ----
207186
signing_key_bytes = self._get_signature_key(datestamp, service)
208-
signature_bytes = self._hmac_sha256(
209-
signing_key_bytes, string_to_sign.encode("utf-8")
210-
)
187+
signature_bytes = self._hmac_sha256(signing_key_bytes, string_to_sign.encode("utf-8"))
211188
signature_hex = ubinascii.hexlify(signature_bytes).decode()
212189

213190
# ---- Task 4: Add Signing Information to the Request ----

0 commit comments

Comments
 (0)