-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathload.py
More file actions
executable file
·43 lines (31 loc) · 1.22 KB
/
Copy pathload.py
File metadata and controls
executable file
·43 lines (31 loc) · 1.22 KB
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
36
37
38
39
40
41
42
43
"""
Script to set up fake data in the redis database.
"""
import redis
def create(connection, redis_key, **kwargs):
"""
Create a single file entry.
Keyword arguments will override the corresponding key in the database.
"""
default = {
'state': 'unpublished',
'public_uri': "http://gtk-dev2:8080/public.png",
'private_uri': "http://127.0.0.1:9090/private.png",
}
model = {}
model.update(default)
model.update(kwargs)
for key, val in model.iteritems():
connection.hset(redis_key, key, val)
def delete(connection, redis_key):
"""
Delete a single file entry
"""
connection.delete(redis_key)
if __name__ == '__main__':
connection = redis.StrictRedis(host='localhost', port=6379, db=0)
create(connection, '/private')
create(connection, '/published', state="published")
create(connection, '/error_bad_uri', private_uri="http://127.0.0.1:9090/asdfsdfsdfasdfasdfasdfasd")
create(connection, '/error_unreachable_host', private_uri="http://wef3ef124f12rr234fr12f12f3213f123f12f312f3wqefwefwef:3292/")
create(connection, '/private_via_ssl', private_uri="https://127.0.0.1:9090/private.png")