2007-02-16, 11:08
Hi all,
I just wrote this code for my ResumeX script and thought this might come in handy for people that add functions into their scripts that can enable/disable scripts run on startup.
Of course, it needs to be edited to the your particular script, but apart from that, is should work good. It has a feature so it doesnt add the line twice etc, so this can be run everytime the script is run via autoexec.py and NO double ups will occur. Also, its profile friendly! :-D
Let me know your thoughts.
Cheers
Stanley87
I just wrote this code for my ResumeX script and thought this might come in handy for people that add functions into their scripts that can enable/disable scripts run on startup.
Code:
def editauto(self):
test = xbmc.getInfoLabel("system.profilename")
test = str(test)
print str(test)
if test != "Master user":
if os.access("P:\\scripts\\", os.F_OK)==0:
os.mkdir("P:\\scripts\\")
autoexecfile = "P:\\scripts\\autoexec.py"
else:
if os.access("Q:\\UserData\\scripts\\", os.F_OK)==0:
os.mkdir("Q:\\UserData\\scripts\\")
autoexecfile = "Q:\\UserData\\scripts\\autoexec.py"
if os.path.exists(autoexecfile):
fh = open(autoexecfile)
count = 0
lines = []
for line in fh.readlines():
theLine = line.strip()
if theLine.startswith("xbmc.executescript('Q:\scripts\ResumeX\lib\engine.py')"):
return
lines.append(str(line))
count = count + 1
fh.close()
lines.append("xbmc.executescript('Q:\scripts\ResumeX\lib\engine.py')\n")
count = count + 1
f = open(autoexecfile, "wb")
for i in range (0 , count):
f.write(lines[i])
f.close()
return
else:
f = open(autoexecfile, "wb")
f.write("import xbmc\n")
f.write("xbmc.executescript('Q:\scripts\ResumeX\lib\engine.py')")
f.close()
return
Of course, it needs to be edited to the your particular script, but apart from that, is should work good. It has a feature so it doesnt add the line twice etc, so this can be run everytime the script is run via autoexec.py and NO double ups will occur. Also, its profile friendly! :-D
Let me know your thoughts.
Cheers
Stanley87