File size: 969 Bytes
c62379b
 
 
 
 
 
36c2a56
c62379b
 
36c2a56
c62379b
36c2a56
 
 
 
 
 
 
 
c62379b
 
 
 
 
36c2a56
 
 
 
c62379b
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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)