embedding a python interpreter

Developer discussion of experimental fixes, changes, and improvements.

Moderators: Nexuiz Moderators, Moderators

embedding a python interpreter

Postby dublpaws » 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.
dublpaws
Advanced member
 
Posts: 61
Joined: Mon Apr 23, 2007 4:26 am

Postby C.Brutail » 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
C.Brutail
Laidback mapper
 
Posts: 2357
Joined: Tue Feb 28, 2006 7:26 pm
Location: Ironforge

Postby [-z-] » Mon Nov 03, 2008 10:13 pm

oh neato!
[-z-]
Site Admin and Nexuiz Ninja
 
Posts: 1794
Joined: Mon Nov 13, 2006 12:20 am
Location: Florida

Postby Psychcf » Mon Nov 03, 2008 10:36 pm

only one problem: you can exec python scripts from the server, which is a security issue.
Psychcf
Forum addon
 
Posts: 1554
Joined: Sun Dec 03, 2006 11:38 pm
Location: NY, USA

Postby dublpaws » 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.
dublpaws
Advanced member
 
Posts: 61
Joined: Mon Apr 23, 2007 4:26 am

Postby divVerent » 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.
divVerent
Site admin and keyboard killer
 
Posts: 3809
Joined: Thu Mar 02, 2006 4:46 pm
Location: BRLOGENSHFEGLE


Return to Nexuiz - Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron