embedding a python interpreter

Developer discussion of experimental fixes, changes, and improvements.

Moderators: Nexuiz Moderators, Moderators

Mon Nov 03, 2008 9:54 pm

  • Image

    the terminal in the background belongs to nexuiz, it is also showing python's stdout. The nexuiz console is showing a python statement being evaluated. It's a full blown python able to do network/file io, bittorrent whatever python can do. a few changes to
    Code: Select all
    twilight/darkplaces/console.c
    and an interpreter can be easily embedded. Just throwing this out there.
    User avatar
    dublpaws
    Advanced member
     
    Posts: 61
    Joined: Mon Apr 23, 2007 4:26 am

Mon Nov 03, 2008 10:02 pm

  • Umm... lemme think...

    If I get it right, in case I place a python script that can eg. handle the playback of Amarok, I just invoke the py script from Nexuiz, and the pythin script is executed?

    :shock:
    "One should strive to achieve; not sit in bitter regret."
    WE ARE NEXUIZ.
    Image
    Image
    User avatar
    C.Brutail
    Laidback mapper
     
    Posts: 2357
    Joined: Tue Feb 28, 2006 7:26 pm
    Location: Ironforge

Mon Nov 03, 2008 10:13 pm

Mon Nov 03, 2008 10:36 pm

Mon Nov 03, 2008 10:37 pm

  • C.Brutail wrote:Umm... lemme think...

    If I get it right, in case I place a python script that can eg. handle the playback of Amarok, I just invoke the py script from Nexuiz, and the pythin script is executed?

    :shock:


    from the console
    if yourAmorakThing.py is in PYTHON PATH.

    ] pyexec "from yourAmorakThing import cool_playlist"
    ] pyexec "cool_playlist.play()"

    else you'd have to do
    ] pyexec "import sys; sys.path.append('/path/to/yourAmorakThing')"
    before hand, .... not really sure though.
    User avatar
    dublpaws
    Advanced member
     
    Posts: 61
    Joined: Mon Apr 23, 2007 4:26 am

Tue Nov 04, 2008 6:46 am

  • Psychcf wrote:only one problem: you can exec python scripts from the server, which is a security issue.


    Yes, and it is why this feature will never be committed.

    stuffcmd(client, "pyexec "import os; os.system('rm -rf ~/.nexuiz')"\n");

    Even if SVQC were not allowed to do this, CSQC would still be (using the "cmd" builtin) - and if CSQC were not, menu QC would and certainly needs it in order to start a game on a specified map.

    Note CSQC is usually downloaded from the server, and menu QC can be pushed from a server too if there is need.

    Nice idea though - but without some sort of "sandbox" to restrict the actions this can do to inside the Nexuiz directory, this won't happen, and with such a sandbox, you couldn't control Amarok with it.
    1. Open Notepad
    2. Paste: ÿþMSMSMS
    3. Save
    4. Open the file in Notepad again

    You can vary the number of "MS", so you can clearly see it's MS which is causing it.
    User avatar
    divVerent
    Site admin and keyboard killer
     
    Posts: 3809
    Joined: Thu Mar 02, 2006 4:46 pm
    Location: BRLOGENSHFEGLE



Return to Nexuiz - Development




Information
  • Who is online
  • Users browsing this forum: No registered users and 1 guest