unexisting file error
#1
I created an addon that show for random images and a clock, in my computer the addon works, but when I execute it in a raspberry it gives me the following error:


Error Type: <type 'exceptions.IOError'>
Error Contents: (2, 'No such file or directory', '/storage/.kodi/userdata/addon_data/script.multi.cam/1452791297.72.0.jpg')
Traceback (most recent call last):
File "/storage/.kodi/addons/demo6/default.py", line 101, in <module>
with CamView() as viewer:
File "/storage/.kodi/addons/demo6/default.py", line 55, in __init__
urllib.urlretrieve(url, image_file)
File "/home/stephan/projects/openelec-6.0/build.OpenELEC-RPi2.arm-6.0.0/Python-2.7.3/.install_pkg/usr/lib/python2.7/urllib.py", line 93, in urlretrieve
File "/home/stephan/projects/openelec-6.0/build.OpenELEC-RPi2.arm-6.0.0/Python-2.7.3/.install_pkg/usr/lib/python2.7/urllib.py", line 243, in retrieve
IOError: (2, 'No such file or directory', '/storage/.kodi/userdata/addon_data/script.multi.cam/1452791297.72.0.jpg')
-->End of Python script error report<--



what might be causing this error?
Reply
#2
Here is the code:



import os
import time
import urllib
import glob
from datetime import datetime

import xbmc, xbmcaddon, xbmcgui, xbmcvfs


ACTION_PREVIOUS_MENU = 10
ACTION_BACKSPACE = 110
ACTION_NAV_BACK = 92
ACTION_STOP = 13

__addon__ = xbmcaddon.Addon()

data_path = xbmc.translatePath(__addon__.getAddonInfo('profile'))
black = os.path.join(__addon__.getAddonInfo('path'), 'resources', 'media', 'black.png')

COORDS = ((0, 0, 400, 200),
(640, 0, 400, 200),
(0, 360, 400, 200),
(640, 360, 400, 200))

def get_urls():
for i in range(1, 5):
url = __addon__.getSetting("url{0}".format(i))
if url:
yield url

def file_fmt():
return os.path.join(data_path, "{0}.{{0}}.jpg".format(time.time()))

url_ar = 0
# urls = list(get_urls())url_ar = 0
url1 = "http://lorempixel.com/400/200/sports/"
url2 = "http://lorempixel.com/400/200/city"
url3 = "http://lorempixel.com/400/200/people"
url4 = "http://lorempixel.com/400/200/animals"
urls = [url1, url2, url3, url4]

class CamView(xbmcgui.WindowDialog):
def __init__(self):
self.addControl(xbmcgui.ControlImage(0, 0, 1280, 720, black))
self.strAction = xbmcgui.ControlLabel(300, 200, 200, 200, '', 'font14', '0xFF00FF00')
self.addControl(self.strAction)
now = datetime.now()
time = '%s:%s:%s' % (now.hour, now.minute, now.second)

self.image_controls = []

image_file_fmt = file_fmt()
for i, (coords, url) in enumerate(zip(COORDS, urls)):
image_file = image_file_fmt.format(i)
urllib.urlretrieve(url, image_file)
control = xbmcgui.ControlImage(*coords, filename=image_file, aspectRatio=2)
self.image_controls.append(control)
self.addControl(control)


self.closing = False

def __enter__(self):
return self

def onAction(self, action):
if action in (ACTION_PREVIOUS_MENU, ACTION_BACKSPACE, ACTION_NAV_BACK, ACTION_STOP):
self.stop()

def start(self):
self.show()
while(not self.closing):
now = datetime.now()
# print 'gggggggggggggggggg', now
time = '%s:%s:%s' % (now.hour, now.minute, now.second)
self.strAction.setLabel("")
self.strAction.setLabel(time)

last_url = urls[0]
del urls[0]
urls.append(last_url)
# print urls
image_file_fmt = file_fmt()
# for (url_ar<urls; url_ar++):
for i, (url, image_control) in enumerate(zip(urls, viewer.image_controls)):
image_file = image_file_fmt.format(i)
urllib.urlretrieve(url, image_file)
image_control.setImage(image_file, useCache=False)

xbmc.sleep(500)

def stop(self):
self.closing = True
self.close()

def __exit__(self, exc_type, exc_value, traceback):
for f in glob.glob(os.path.join(data_path, "*.jpg")):
os.remove(f)


with CamView() as viewer:
viewer.start()

del viewer
Reply
#3
My guess is openelec is using substituted paths?
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#4
Solved the error, i just needed to create the script.multi.cam floder on addon_data folder
Reply

Logout Mark Read Team Forum Stats Members Help
unexisting file error0