Spaces:
Runtime error
Runtime error
import redis | |
import json | |
redis_url = 'redis://default:[email protected]:7369' | |
r = redis.from_url(redis_url) | |
uuids = [] | |
names = [] | |
redis_keys = r.keys('image:*') | |
for i_key in redis_keys: | |
if i_key != b'image:accept': | |
image_data_bytes = r.hgetall(i_key) | |
image_data = {k.decode('utf-8'): v.decode('utf-8') for k, v in image_data_bytes.items()} | |
try: | |
uuids.append(image_data['uuid']) | |
names.append({'id': i_key.decode().split(':')[-1], 'file_name': image_data['name'], 'uuid': image_data['uuid']}) | |
except: | |
print(i_key) | |
# Save the UUIDs to a file | |
with open('uuids.json', 'w') as file: | |
json.dump(uuids, file) | |
with open('names.json', 'w') as file: | |
json.dump(names, file) | |
# print('UUIDs saved to uuids.json') | |
# # Read the JSON file | |
# with open('./uuids.json', 'r') as file: | |
# uuid_list = json.load(file) | |
# # Access the list | |
# print(uuid_list == uuids) |