Author: oracle
Date: Thu Jul 24 18:09:52 2008
New Revision: 28175
URL: http://svn.gna.org/viewcvs/wesnoth?rev=28175&view=rev
Log:
Added new script used by new embedded python implementation.
This makes it easier to control restricted/unrestricted python
environments without requiring a client recompilation. Future
enhancements are now more likely to be strictly python code
changes.
Added:
trunk/data/ais/ai_launcher.py
Modified:
trunk/changelog
Modified: trunk/changelog
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=28175&r1=28174&r2=28175&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Thu Jul 24 18:09:52 2008
@@ -16,6 +16,9 @@
areas and their schedules during scenario events. Removal requires to
associate an id. to [time_area]s, or it won't work.
* Python AI
+ * Added ai_init.py and ai_launcher.py to make it easier to customize
+ AI environment and startup. Both are used by the new embedded python
+ implementation.
* reversed builtin is now allowed. This allows for random.shuffle to be
called.
Added: trunk/data/ais/ai_launcher.py
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/ais/ai_launcher.py?rev=28175&view=auto
==============================================================================
--- trunk/data/ais/ai_launcher.py (added)
+++ trunk/data/ais/ai_launcher.py Thu Jul 24 18:09:52 2008
@@ -1,0 +1,47 @@
+#!/bin/env python
+# Copyright Greg Copeland, 2008
+# Released under GPL license for Wesnoth. See Wesnoth's
+# licensing terms for this module's specific license.
+#
+
+import os
+import sys
+import traceback
+
+print "launch has been imported!"
+
+def launch( script, restrict ):
+ # Launch one of two possible environments
+ # If restrict arg is True, run inside the available
+ # restrictied python environment (safe.py). If restrict
+ # is False, then run without any type of restrictions.
+ if restrict:
+ print "restricted environment detected - running parse/safe"
+ try:
+ import safe
+ import parse
+
+ parse.paths = ""
+ code, context = parse.parse( script )
+ safe.safe_exec( code, context, restrict )
+
+ except:
+ err = str( traceback.format_exc() )
+ raise
+
+ else:
+ print "unrestricted environment detected...running directly."
+ __import__( script )
+ scrpt = sys.modules[ script ]
+
+ # Call our entry points
+ scrpt.start()
+ scrpt.turn()
+ scrpt.end()
+
+ print "launch has completed."
+
+
+
+
+
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits