-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetFromQueue.py
More file actions
43 lines (33 loc) · 1.02 KB
/
getFromQueue.py
File metadata and controls
43 lines (33 loc) · 1.02 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
import beanstalkc
import json
import requests
import shutil
beanstalk=beanstalkc.Connection(host='localhost',port=11300)
TUBE_NAME='alprd'
print beanstalk.tubes()
print(beanstalk.stats_tube(TUBE_NAME))
beanstalk.watch(TUBE_NAME)
a=3
while True:
job=beanstalk.reserve(timeout=1)
if job is None:
print "no plates"
else:
plates_info=json.loads(job.body)
#print(plates_info)
uuid=""
linkForm=""
if plates_info['data_type']=='alpr_results':
print(plates_info['uuid'])
uuid=plates_info['uuid']
if plates_info['data_type']=='alpr_group':
print(plates_info['best_uuid'])
uuid=plates_info['best_uuid']
if uuid !="":
linkForm="http://localhost:8355/img/"+uuid+".jpg"
print(linkForm)
response=requests.get(linkForm,stream=True)
with open('img.jpg', 'wb') as out_file:
shutil.copyfileobj(response.raw, out_file)
del response
job.delete()