[Linux] autoexec.py startup script
#1
Guys,
I'm not sure what I'm doing wrong - but it's not working.
I've a [general-purpose] script to convert a iTunes created playlist file (.m3u) into a general purpose playlist, which XBMC can read/understand and I wanted to run that script every times XBMC starts. The script simple reads the file from a given location (i.e. where I import the playlist from iTunes), converts and then put that in the /home/xbmc/.xbmc/userdata/playlists/music location - very simple, nothing fancy. If I run the script by hand, it works perfectly well but if I try to run though autoexec.py (in /home/xbmc/.xbmc/scripts) nothing happens. This is what I have for my autoexec.py file:
Code:
## auto execute scripts when xbmc starts
## note:- use only one script at a time which asks for user input!

import os, xbmc

# create playlists from iTunes playlist file
xbmc.executescript(os.environ['HOME'] + '/automate/mk_plst.py')
Is there anything wrong with that? Does anyone know why it's not working? I checked the log, there is no ERROR that. Any help/tip greatly appreciated. Cheers!!
MINIX NEO U22-XJ | Denon AVC-X3800H | KEF Q750 | KEF Q250c | KEF Q150 | KEF Q50a | KEF Kube 10 MIE | LG OLED65G16LA | CoreELEC
Reply
#2
No one out here with any such experience with autoexec.py, really? Search the web and all the references (just a couple, though) are seem to be XBOX/Windows specific; it's hard to believe it's not for Linux. Am I barking up the wrong tree? Cheers!!!
MINIX NEO U22-XJ | Denon AVC-X3800H | KEF Q750 | KEF Q250c | KEF Q150 | KEF Q50a | KEF Kube 10 MIE | LG OLED65G16LA | CoreELEC
Reply
#3
just a wild guess, but wouldnt copying mk_plst.py to /home/xbmc/.xbmc/scripts and renaming it to autoexec.py do exactly what you want?
Reply
#4
I think the OS variable doesn't work properly (you could try to printf it)

I'd try this :
Code:
xbmc.executescript('special://home/scripts/automate/mk_plst.py')
It's the way you supposed to do it. If it doesn't work post a debug log on pastebin...
-= Team Kodi developer fueled by heavy metal =-
Reply
#5
Amet Wrote:just a wild guess, but wouldnt copying mk_plst.py to /home/xbmc/.xbmc/scripts and renaming it to autoexec.py do exactly what you want?
I don't know; I didn't think about that. I thought "autoexec.py" is a XBMC-specific-formatted file. I can give a try. Cheers!!!
MINIX NEO U22-XJ | Denon AVC-X3800H | KEF Q750 | KEF Q250c | KEF Q150 | KEF Q50a | KEF Kube 10 MIE | LG OLED65G16LA | CoreELEC
Reply
#6
arnova Wrote:I think the OS variable doesn't work properly (you could try to printf it)
I saw "mk_plst.py" being executed in the log but I don't think I saw anything other than DEBUG in the log related to this. I'm gonna try your suggestion and let you know if it works. Does "special://home/scripts" mean "/home/xbmc/.xbmc/scripts"? cheers!!
MINIX NEO U22-XJ | Denon AVC-X3800H | KEF Q750 | KEF Q250c | KEF Q150 | KEF Q50a | KEF Kube 10 MIE | LG OLED65G16LA | CoreELEC
Reply
#7
MacUsers Wrote:I saw "mk_plst.py" being executed in the log but I don't think I saw anything other than DEBUG in the log related to this. I'm gonna try your suggestion and let you know if it works. Does "special://home/scripts" mean "/home/xbmc/.xbmc/scripts"? cheers!!

Yeah, assuming the user running xbmc, is "xbmc" ofc....
-= Team Kodi developer fueled by heavy metal =-
Reply
#8
Thanks arnova, it seems to be working now!! Big Grin
At work now, so didn't able to do that on my real system but I tested this on a small system at work and it worked. I can't think of any reason why it shouldn't work at home but I'll let you know in the evening. Just one question: Is it essential to put the custom scripts in the "~/.xbmc/scripts" directory?
Thanks, once again, for your help. Cheers!!
MINIX NEO U22-XJ | Denon AVC-X3800H | KEF Q750 | KEF Q250c | KEF Q150 | KEF Q50a | KEF Kube 10 MIE | LG OLED65G16LA | CoreELEC
Reply
#9
MacUsers Wrote:Just one question: Is it essential to put the custom scripts in the "~/.xbmc/scripts" directory?

Nope, not essential, but the different dirs are made for reasons: just to group stuff for clarity. You can put them in /tmp/ or /dev/null, if you like :p
-= Team Kodi developer fueled by heavy metal =-
Reply
#10
arnova Wrote:You can put them in /tmp/ or /dev/null, if you like :p
haaahhh....... it's a good one!!! but not willing to do so ....
MINIX NEO U22-XJ | Denon AVC-X3800H | KEF Q750 | KEF Q250c | KEF Q150 | KEF Q50a | KEF Kube 10 MIE | LG OLED65G16LA | CoreELEC
Reply
#11
hi arnova,
I'm completely lost here; I'm utterly surprised that the very same thing didn't work at home. The last 20 mins I was scratching my head, trying to figure out the reason why it worked at work but home. I did exactly the same, I did in the morning - the only difference is I changed the file name from mk_plst.py to xbmc_plist.py and changed the autoexec.py accordingly but that shouldn't be the problem.

Here is the log (it's just couple of lines, so just putting in here) from the machine when it worked:
Code:
12:39:14 T:140206288123664 M:1372545024  NOTICE: -->Python Interpreter Initialized<--
12:39:14 T:140206288123664 M:1372545024   DEBUG: Process - The source file to load is special://home/scripts/automate/mk_plst.py
12:39:14 T:140206288123664 M:1372545024   DEBUG: Process - Setting the Python path to /home/santan/.xbmc/scripts/automate:/usr/share/xbmc/system/python/python24.zip:/usr/share/xbmc/system/python/lib/python24.zip:/usr/share/xbmc/system/python/lib/python2.4/:/usr/share/xbmc/system/python/lib/python2.4/plat-linux2:/usr/share/xbmc/system/python/lib/python2.4/lib-tk:/usr/share/xbmc/system/python/lib/python2.4/lib-dynload
12:39:14 T:140206288123664 M:1372545024   DEBUG: Process - Entering source directory /home/santan/.xbmc/scripts/automate
12:39:14 T:140206288123664 M:1373630464  NOTICE: Rough Rider.m3u created in /home/santan/.xbmc/userdata/playlists/music
12:39:14 T:140206288123664 M:1373630464  NOTICE: Easy Rider.m3u created in /home/santan/.xbmc/userdata/playlists/music
12:39:14 T:140206288123664 M:1373630464  NOTICE: Bollywood Hits.m3u created in /home/santan/.xbmc/userdata/playlists/music
12:39:14 T:140206288123664 M:1373630464    INFO: Scriptresult: Success
And here, when the same thing didn't work:
Code:
19:58:01 T:140320981456656 M:3385335808  NOTICE: -->Python Interpreter Initialized<--
19:58:01 T:140320981456656 M:3385335808   DEBUG: Process - The source file to load is special://home/scripts/automate/xbmc_plist.py
19:58:01 T:140320981456656 M:3385335808   DEBUG: Process - Setting the Python path to /home/xbmc/.xbmc/scripts/automate:/usr/share/xbmc/system/python/python24.zip:/usr/share/xbmc/system/python/lib/python24.zip:/usr/share/xbmc/system/python/lib/python2.4/:/usr/share/xbmc/system/python/lib/python2.4/plat-linux2:/usr/share/xbmc/system/python/lib/python2.4/lib-tk:/usr/share/xbmc/system/python/lib/python2.4/lib-dynload
19:58:01 T:140320981456656 M:3385335808   DEBUG: Process - Entering source directory /home/xbmc/.xbmc/scripts/automate
19:58:01 T:140320981456656 M:3385081856    INFO: Scriptresult: Success
I'm sure it's a very small thing is being overlooked. Can you see what am I missing? cheers!!!
MINIX NEO U22-XJ | Denon AVC-X3800H | KEF Q750 | KEF Q250c | KEF Q150 | KEF Q50a | KEF Kube 10 MIE | LG OLED65G16LA | CoreELEC
Reply
#12
here is the full log at pastebin/L3RrXMih........... if anyone can spot the culprit. cheers!!
MINIX NEO U22-XJ | Denon AVC-X3800H | KEF Q750 | KEF Q250c | KEF Q150 | KEF Q50a | KEF Kube 10 MIE | LG OLED65G16LA | CoreELEC
Reply
#13
I see some differences in the logs. This is the one from the machine when it worked:
Code:
12:39:14 T:140206497531664 M:1380077568  NOTICE: -->Python Interpreter Initialized<--
12:39:14 T:140206497531664 M:1380077568   DEBUG: Process - The source file to load is /home/santan/.xbmc/scripts/autoexec.py
12:39:14 T:140206497531664 M:1380077568   DEBUG: Process - Setting the Python path to /home/santan/.xbmc/scripts:/usr/share/xbmc/system/python/python24.zip:/usr/share/xbmc/system/python/lib/python24.zip:/usr/share/xbmc/system/python/lib/python2.4/:/usr/share/xbmc/system/python/lib/python2.4/plat-linux2:/usr/share/xbmc/system/python/lib/python2.4/lib-tk:/usr/share/xbmc/system/python/lib/python2.4/lib-dynload
12:39:14 T:140206497531664 M:1380077568   DEBUG: Process - Entering source directory /home/santan/.xbmc/scripts
12:39:14 T:140206497531664 M:1380204544    INFO: Scriptresult: Success
12:39:14 T:140206296516368 M:1378291712   DEBUG: thread start, auto delete: 1
and the same from the machine it doesn't work:
Code:
08:35:20 T:139842616633104 M:3391737856  NOTICE: -->Python Interpreter Initialized<--
08:35:20 T:139842616633104 M:3391737856   DEBUG: Process - The source file to load is /home/xbmc/.xbmc/scripts/autoexec.py
08:35:20 T:139842616633104 M:3391737856   DEBUG: Process - Setting the Python path to /home/xbmc/.xbmc/scripts:/usr/share/xbmc/system/python/python24.zip:/usr/share/xbmc/system/python/lib/python24.zip:/usr/share/xbmc/system/python/lib/python2.4/:/usr/share/xbmc/system/python/lib/python2.4/plat-linux2:/usr/share/xbmc/system/python/lib/python2.4/lib-tk:/usr/share/xbmc/system/python/lib/python2.4/lib-dynload
08:35:20 T:139842616633104 M:3391737856   DEBUG: Process - Entering source directory /home/xbmc/.xbmc/scripts
08:35:20 T:139842616633104 M:3391737856    INFO: Scriptresult: Success
08:35:20 T:139842927437888 M:3391864832    INFO: initializing python engine.
08:35:20 T:139842927437888 M:3391864832   DEBUG: new python thread created. id=2
08:35:20 T:139842490971920 M:3391221760   DEBUG: thread start, auto delete: 0
08:35:20 T:139842490971920 M:3391221760   DEBUG: Python thread: start processing
08:35:20 T:139842516150032 M:3388809216   DEBUG: DoWork - took 127 ms to load special://skin/images/backgrounds/default-background.jpg
Does it make any sense to anyone? Cheers!!
MINIX NEO U22-XJ | Denon AVC-X3800H | KEF Q750 | KEF Q250c | KEF Q150 | KEF Q50a | KEF Kube 10 MIE | LG OLED65G16LA | CoreELEC
Reply
#14
It's probably something in the Python script itself or your environment. The log clearly shows it IS executed, so that can't be the problem....
-= Team Kodi developer fueled by heavy metal =-
Reply
#15
As I said before, if I execute the script manually from the "~/.xbmc/scripts/automate" directory, it works. So it cannot be the script, unless XBMC itself do some magic on the fly. This is the script, anyway:
Code:
#!/usr/bin/env python

import os, fnmatch

homeDir = "%s/.xbmc" % os.environ['HOME']
baseDir = "%s/nMedia/mMusic/iTunes" % os.environ['HOME']
src_pls = "%s/PlayList" % baseDir
dst_pls = "%s/userdata/playlists/music" % homeDir
mp3_dir = "%s/iTunes Music" % baseDir

os.chdir(src_pls)
for files in os.listdir('.'):

    ## Read only the the playlist files
    if fnmatch.fnmatch(files, '*.m3u'):
        infile = open(files,'r')
        outfile = open("%s/%s" % (dst_pls,files),'w')

        ## Populate the list-data
        new_line = []
        for line in infile:
            new_line.extend(line.split('\r'))

        infile.close()
        del line
        #print "TEST: %s\n" % new_line

        for item in new_line:
            item = item.strip()
            fields =  item.split('/')

            if len(fields) < 3:
                if item == "": continue
                outfile.write("%s\n" % str(item))
                continue
            else:
                old_part = fields[-3] + "/" + fields[-2] + "/" + fields[-1]
                new_part = mp3_dir + "/" + old_part
                outfile.write("%s\n" % str(new_part))

        outfile.close()
        print "%s created in %s" % (files, dst_pls)
        del item
del files
Do you see anything wrong there?
Here is my environment settings, do you spot anything unusual in there?
Code:
xbmc@htpc:~/.xbmc/scripts/automate$ printenv
TERM=xterm-color
SHELL=/bin/bash
XDG_SESSION_COOKIE=98e4d4b0b1872e5ee026085e4c04ecf4-1277191773.902290-1597907753
SSH_CLIENT=10.0.11.110 54465 22
SSH_TTY=/dev/pts/0
USER=xbmc
LS_COLORS=rs=0:di=01;34:ln=01;36:hl=44;37:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:
MAIL=/var/mail/xbmc
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
PWD=/home/xbmc/.xbmc/scripts/automate
LANG=en_GB.UTF-8
SHLVL=1
HOME=/home/xbmc
LOGNAME=xbmc
SSH_CONNECTION=10.0.11.110 54465 10.0.11.12 22
LESSOPEN=| /usr/bin/lesspipe %s
LESSCLOSE=/usr/bin/lesspipe %s %s
OLDPWD=/home/xbmc/.xbmc/temp/debug_log
_=/usr/bin/printenv
I compared this output with the one where it works, it's pretty much identical. Cheers!!!
MINIX NEO U22-XJ | Denon AVC-X3800H | KEF Q750 | KEF Q250c | KEF Q150 | KEF Q50a | KEF Kube 10 MIE | LG OLED65G16LA | CoreELEC
Reply

Logout Mark Read Team Forum Stats Members Help
[Linux] autoexec.py startup script0