0

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.

kIrk
  • 1
  • 2
  • what kind of server are you posting your videos to? Is it the same server for all shops? If the server is running with php there is a maximum upload file size variable and a request timout variable as well. See: http://stackoverflow.com/questions/2184513/php-change-the-maximum-upload-file-size and http://stackoverflow.com/questions/3829403/how-to-increase-the-execution-timeout-in-php – matyas Dec 02 '16 at 11:11
  • I am uploading them all to different screenly servers, here is an example https://www.screenly.io/ose/ – kIrk Dec 02 '16 at 11:21
  • * edit the servers runs python – kIrk Dec 02 '16 at 11:28
  • Do you have acess to the server? If so could you check and post the server logs? You can probably find them in a location like this: /var/log/supervisor/screenly.log – matyas Dec 02 '16 at 11:37
  • i have acces to the servers but i coudln´t find a specific log file for the upload :/ *edit i posted a screenshot of the log folder – kIrk Dec 02 '16 at 12:03
  • Make sure logging is activated for screenly so that it actually creates a logfile and logs its activity: https://searchcode.com/codesearch/view/76065451/ -> debug_logging = True – matyas Dec 02 '16 at 12:19
  • I dont´t get it, i turned it on, but still no supervisor folder... :( – kIrk Dec 02 '16 at 13:08
  • did you restart your servers or screenly? maybe that needs to be done so that the change can take effect – matyas Dec 02 '16 at 13:18
  • yeah, i restarted the screenly server. :( – kIrk Dec 02 '16 at 13:26

0 Answers0