-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecord.py
More file actions
52 lines (38 loc) · 1.58 KB
/
record.py
File metadata and controls
52 lines (38 loc) · 1.58 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
44
45
46
47
48
49
50
51
#!/usr/bin/env python
import os
import sys
import httplib
import urlparse
import cloudfiles
import urllib
import urllib2
import sys
import pytz
authurl='http://ip/auth'
def application(environ, start_response):
from datetime import datetime
our = pytz.timezone('Asia/Novosibirsk')
i = datetime.now(our)
_data = urlparse.parse_qs(environ["QUERY_STRING"])
username = urlparse.parse_qs(environ["QUERY_STRING"])['ceph_api_user'][0]
api_key = urlparse.parse_qs(environ["QUERY_STRING"])['ceph_api_key'][0]
api_key = urllib.unquote(api_key).decode('utf8')
container_name = "records"
record = urlparse.parse_qs(environ["QUERY_STRING"])['recording'][0]
record = record [1:]
record = i.strftime('%Y%m%d-%H%M%S') +"_" +record
conn = cloudfiles.get_connection(
username=username,
api_key=api_key,
authurl=authurl,
)
length = int(environ["CONTENT_LENGTH"])
body="Hello world"
buf = environ['wsgi.input'].read(length)
testuser = conn.create_container(container_name)
obj = testuser.create_object(record)
obj.write(buf)
start_response("200 Ok",
[("Content-Type", "text/html"),
("Content-Length", str(len(body)))])
return [body]