aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelupus <elupus@xbmc.org>2011-04-10 15:20:33 +0200
committerelupus <elupus@xbmc.org>2011-04-10 15:24:29 +0200
commit959040913ac34b4e701c4d576781e4cdbca3d635 (patch)
tree671f78f93ef975ff5a4219f7dd86dc73a70e4729
parent82e11e958ec30b3ba216fea44f9b4c2beb5bbe75 (diff)
changed: override os.getcwd() and os.chdir() functions to make addons relying on it work
Feel free to revert whenever ALL addons have been corrected to avoid using this.
-rw-r--r--xbmc/interfaces/python/XBPython.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/xbmc/interfaces/python/XBPython.cpp b/xbmc/interfaces/python/XBPython.cpp
index ee34fbcead..487a30d7bb 100644
--- a/xbmc/interfaces/python/XBPython.cpp
+++ b/xbmc/interfaces/python/XBPython.cpp
@@ -250,6 +250,25 @@ void XBPython::InitializeInterpreter()
"import sys\n"
"sys.stdout = xbmcout()\n"
"sys.stderr = xbmcout()\n"
+ ""
+ "import os\n"
+ "def getcwd_xbmc():\n"
+ " import __main__\n"
+ " import warnings\n"
+ " if hasattr(__main__, \"__file__\"):\n"
+ " warnings.warn(\"os.getcwd() is depreciated for getting addon directory use os.path.dirname(__main__.__file__)\", DeprecationWarning, stacklevel=2)\n"
+ " return os.path.dirname(__main__.__file__)\n"
+ " else:\n"
+ " return os.getcwd_original()\n"
+ ""
+ "def chdir_xbmc(dir):\n"
+ " raise RuntimeError(\"os.chdir not supported in xbmc\")\n"
+ ""
+ "os_getcwd_original = os.getcwd\n"
+ "os.getcwd = getcwd_xbmc\n"
+ "os.chdir_orignal = os.chdir\n"
+ "os.chdir = chdir_xbmc\n"
+ ""
"print '-->Python Interpreter Initialized<--'\n"
"") == -1)
{