Writing in textfile
#1
Hi

i just write my first kodi script to control the RPI.GPIO. i want to control LED Stripes which are connected to my GPIOS with my FHEM server.

I want to write some data in a Textfile. which is laying in "/storage/.kodi/script.service.ledstripe/resources/data/textfile.txt". But i always get the error "Error Contents: (2, 'No such file or directory'...." i thought i can just put my path to "resources/data/textfile.txt" but wont work too.

can someone help me?
Same thing is with loading data into a the python script.

thx
Reply
#2
If the file is in the addon folder you use:

__addon__ = xbmcaddon.Addon(id=addonname')
__addonwd__ = xbmc.translatePath(__addon__.getAddonInfo('path').decode("utf-8"))

if it is in the the userdata

__addon__ = xbmcaddon.Addon(id='addonname')
__addondir__ = xbmc.translatePath(__addon__.getAddonInfo('profile').decode('utf-8'))

in "/storage/.kodi/script.service.ledstripe/resources/data/textfile.txt"

you seem to miss /addons/ between .kodi and /script.service....
Reply
#3
I wouldn't suggest writing directly to the addon folder. I've noticed the changes do not always take affect until the addon is relaunched. I am not sure if this is a bug or due to the compile at runtime. This issues does not appear to be present when writing to the addondata folder. Also you need to make sure you make the directory before attempting to write a file as well.
Reply

Logout Mark Read Team Forum Stats Members Help
Writing in textfile0