i built for my company a digital signage solution with a raspberry and screenly. Right now we have 35 screens in different shops. i decided to use python to upload the videos with one click. I tested my simple code at our headquarters, it worked fine. Yesterday i wanted to distribute the videos to our shops, but i think i am running in a timeout, because the videos are not uploaded correctly. All of them have 0 bytes ( should be, around 10 MB). How can i upload them seriell and not parallel, i mean how can i assure that the script only continues after a finished upload. it seems that the request post goes on and on. If i try the code with only one shop, it works :(.
import requests
import itertools as it
import itertools as it
baseurl = 'http://10.%d.80.%d:8080/api/assets'
dataDict = {'mimetype': 'video', 'asset_id': '1', 'duration': 0, 'name': 'test1', 'start_date': '2016-10-10T08:27:00+00:00', 'end_date': '2017-01-01T09:27:00+00:00', 'is_enabled': '1'}
imgFile = {'file_upload': open('C:/Python27/testvideo.mp4', 'rb')}
for x, y in [(x, y) for x in it.chain(range(1, 8), range(9, 16), range(17, 19), range(20, 23), range(30, 32), range(40, 42), range(50, 54), range(62, 81, 18), range(82, 83)) for y in it.chain(range(1, 3))]:
try:
r = requests.post(baseurl % (x, y), data=dataDict, files=imgFile, timeout=10)
except requests.exceptions.Timeout:
print (baseurl % (x, y))
Here is a screenshot of the logs
*EDIT
It seems like that the first shop in the loop is getting the correct filesize, afterwards the shops getting the 0 bytes.