Help for enigma2 calls

  • Hello,


    How can I get help on how to use enigma2 calls? for example I have made a plugin that has a list, and I want my code to return the filename the cursor is standing on so that I can use it in an os.system call. I tried to use self.getSelection but it is causing my box to crash :P, here is the piece of code I have (based on FileManger plugin):

    Code
    def ok(self):
    		selection = self["list"].getSelection()
    		if selection[1] == True:
    			self["list"].changeDir(selection[0])
    		else:
                            if isinstance(selection, eServiceReference):
                                    selection = selection.getPath()
                            cmd = "/usr/bin/ctorrent -E 0 " + selection
    			res = os.system(cmd)
    			return (res >> 8)


    Thanks in advanced.

  • Code
    selection = self["list"].getCurrent()


    is what you are searching about ... but please ... DONT use os.system because it will break and interrupt enigma2 and you will run into problems inside enigma !
    Please use an eConsoleAppContainer instead:


    init

    Code
    self.container=eConsoleAppContainer()
    self.container.appClosed.get().append(self.finished)


    execute

    Code
    self.container.execute(self.val)


    after the binary has ended, the function "finished" will be called (you can connect it with append, see above). In that way your binary will not stop and break enigma2 .. you can take a look into the tuxtxt starter plugin, it uses the eConsoleAppContainer as well and you will find it on your Box.

    Einmal editiert, zuletzt von Seddi ()

  • m8, I tried that, but I'm still getting a restart in enigma2


    I'm doing the following:


    enigma2 crash log is telling me:

    Code
    Traceback (most recent call last):
    Traceback (most recent call last):
      File "/usr/lib/enigma2/python/Components/ActionMap.py", line 66, in action
        return ActionMap.action(self, contexts, action)
      File "/usr/lib/enigma2/python/Components/ActionMap.py", line 46, in action
        res = self.actions[action]()
      File "/usr/lib/enigma2/python/Plugins/DemoPlugins/TestPlugin/plugin.py", line 61, in ok
        self.container.execute("/usr/bin/ctorrent -E 0 "+selection+" >/tmp/selection.ctorrent")
    TypeError: cannot concatenate 'str' and 'list' objects


    Note that I reused def finished as is from tuxtux.py


    Any ideas? please.

    Einmal editiert, zuletzt von laith.said ()

  • You should print out selection and considering the python error message you would see what the problem is (at least it would be very obvious then ;))

    Einmal editiert, zuletzt von dcdead ()

  • self.container.execute("/usr/bin/ctorrent -E 0 "+selection+" >/tmp/selection.ctorrent")


    selection is a array.
    selection[0] = contains the text of the selection
    selection[1] = contains its value


    You can not join strings and lists. So change it to

    Code
    if selection is not None: # if the user presses exit 
          self.container.execute("/usr/bin/ctorrent -E 0 "+selection[1]+" >/tmp/selection.ctorrent")

    Einmal editiert, zuletzt von 3c5x9 ()

  • Thanks, but it did not help:


    Code
    Traceback (most recent call last):
      File "/usr/lib/enigma2/python/Components/ActionMap.py", line 66, in action
        return ActionMap.action(self, contexts, action)
      File "/usr/lib/enigma2/python/Components/ActionMap.py", line 46, in action
        res = self.actions[action]()
      File "/usr/lib/enigma2/python/Plugins/DemoPlugins/TestPlugin/plugin.py", line 62, in ok
        self.container.execute("/usr/bin/ctorrent -E 0 "+selection[1]+" >/tmp/selection.ctorrent")
    TypeError: cannot concatenate 'str' and 'tuple' objects


    I also tried the print thing, but where can I see the print result?


    Einmal editiert, zuletzt von laith.said ()

    • Offizieller Beitrag

    TypeError: cannot concatenate 'str' and 'tuple' objects


    you can only concetenate object of the same type (strings with string e.g.).
    I don't know if it will work but just try a print "Selected", str(selection[1])

    mfg ,
    Reichi

  • Can you show me, how do you fill the list, you are working with? Because, if selction[1] is still a tulpel it seems that you fill the menue with tulpels.


    You can get the output of a print-command when you start enigma at the commandline via telnet.


    init 4 (to stop the running enigma)
    killall -9 enigma2; enigma2& (kills left enigma prozesses and starts enigma in the console, i use this to restart enigma with this)


    To start enigma again type
    killall -9 enigma2
    init 4

  • Thanks Guys,


    I made the print and the result is:

    Zitat

    Selected (0, 35, 1, 470, 20, 0, 0, 'myself.ts')


    I changed it to selection[1][7]. Now I do not get the crash, but nothing is happening, i.e. the:

    Zitat

    self.container.execute("/usr/bin/ctorrent -E 0 /hdd/home/ftpuser/"+str(selection[1][7])+" >/tmp/selection.ctorrent &")


    is not executing the Linux command! I can see the full command using print but the process is not started when I check ps afterwards. I tried to execute to command on bash directly and it works fine!


    Any guidance please?


    Also I'd love to know how I can get the path name?


    I'm using the code used in FileManger plugin, here is my code:


    4 Mal editiert, zuletzt von laith.said ()