invalid mode: r
#1
Exclamation 
I am having a strange issue with a script which uses same syntax as other scripts in my plugin but keep getting IOERROR: invalid mode: r

This only happens on the windows based side of the house and it usually means that it can't find the file or the windows based url is incorrect but none of that applies in this case as I have checked it...

Here is a snippet my code where the offending statement resides:
Code:
import time, os, sys, socket, urllib2, select
import xbmc, xbmcgui, xbmcplugin, xbmcaddon

__settings__   = xbmcaddon.Addon("plugin.program.multiroomaudio")
if (sys.platform == 'win32'):
    xbmclog = xbmc.translatePath( os.path.join( "special://home/", "xbmc.log" ) )
else:
    if (sys.platform.startswith('linux')):    
        xbmclog = xbmc.translatePath( os.path.join( "special://home/", "temp", "xbmc.log" ) )

#Set the xbmc.log file and open it
[color=black]file = open(xbmclog,'r')[/color]
Again the debug doesn't give me much but the actual error message and the offending script, line, position. Any help would be appreciatedHuh

EDIT: Ok... after more testing, I have found that the problem is that open() is trying to exclusively open the file and since it is already open by another process it can't and thus fails. (For the record.... windows blows!) ok.. enough of the rant. How do I open to read a file that is already open by another process? I even tried to spoof windows/xbmc python by using the urlib.urlopen() since it supposedly opens with non-exclusive access but when type url is that of file:///, it ultimately iterates to the file() module which is an alias for open()... no joy. Linux doesn't have this issue because the OS handles the subprocess of shared access to an open file.

EDIT2:
After yet more experimentation... I loaded python 2.7 on my windows box and tested the script while also running XBMC, verified that XBMC is writing to the log file and my script works without issue and prints the data that is added by XBMC in realtime to the python shell screen. So what gives? Any ideas anybody?

I have spent time reading tons of postings on the Web but all talk about generic open() use. Someone has to have the info I need... C'mon fellow script'rs, help out a fellow.
Enjoy OpenSource! :nod:
MY SETUP: XBMC 12 Frodo RC3, Multiple Asus EB1501's throughout the Home for XBMC based STB's
Reply
#2
edited, wrong read.
Reply
#3
ppic Wrote:edited, wrong read.

?? what do you mean PPIC?
Enjoy OpenSource! :nod:
MY SETUP: XBMC 12 Frodo RC3, Multiple Asus EB1501's throughout the Home for XBMC based STB's
Reply

Logout Mark Read Team Forum Stats Members Help
invalid mode: r0