added update_pics.py
This commit is contained in:
parent
dbe8f2ae00
commit
a52333c2d5
|
@ -1,3 +1,5 @@
|
||||||
backend/randpic/__pycache__
|
backend/randpic/__pycache__
|
||||||
backend/tianyi/__pycache__
|
backend/tianyi/__pycache__
|
||||||
backend/db.sqlite3
|
backend/db.sqlite3
|
||||||
|
backend/secret.txt
|
||||||
|
backend/jsons/pics.json
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,19 @@
|
||||||
|
# Description: This script is used to update the list of pictures in the Azure Blob Storage container.
|
||||||
|
from azure.storage.blob import BlobServiceClient
|
||||||
|
import argparse
|
||||||
|
import json
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('--container', type=str, default="tianyi-random")
|
||||||
|
parser.add_argument('--remotedir', type=str, default="")
|
||||||
|
args=parser.parse_args()
|
||||||
|
try:
|
||||||
|
with open('secret.txt', 'r') as f:
|
||||||
|
connect_str = f.read()
|
||||||
|
blob_service_client = BlobServiceClient.from_connection_string(connect_str)
|
||||||
|
container_client = blob_service_client.get_container_client(args.container)
|
||||||
|
existing_files=[blob.name.split("/")[-1] for blob in container_client.list_blobs(name_starts_with=args.remotedir)]
|
||||||
|
with open('jsons/pics.json', 'w') as f:
|
||||||
|
json.dump(existing_files, f, indent=4, sort_keys=True)
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
exit(1)
|
Loading…
Reference in New Issue