mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
Bug fixes for .so modules.
This commit is contained in:
parent
ac78a1c2cb
commit
4bda1fc74a
@ -38,6 +38,7 @@ from baseplugin import *
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import imp
|
import imp
|
||||||
|
import crypt
|
||||||
import random
|
import random
|
||||||
|
|
||||||
# Stupid printing on import...
|
# Stupid printing on import...
|
||||||
@ -50,6 +51,7 @@ import utils
|
|||||||
import privmsgs
|
import privmsgs
|
||||||
import callbacks
|
import callbacks
|
||||||
|
|
||||||
|
pythonPath = map(os.path.dirname, [os.__file__, crypt.__file__])
|
||||||
|
|
||||||
def configure(onStart, afterConnect, advanced):
|
def configure(onStart, afterConnect, advanced):
|
||||||
# This will be called by setup.py to configure this module. onStart and
|
# This will be called by setup.py to configure this module. onStart and
|
||||||
@ -77,15 +79,15 @@ class Python(callbacks.Privmsg):
|
|||||||
if '.' in funcname:
|
if '.' in funcname:
|
||||||
parts = funcname.split('.')
|
parts = funcname.split('.')
|
||||||
functionName = parts.pop()
|
functionName = parts.pop()
|
||||||
path = os.path.dirname(os.__file__)
|
path = pythonPath
|
||||||
for name in parts:
|
for name in parts:
|
||||||
try:
|
try:
|
||||||
info = imp.find_module(name, [path])
|
info = imp.find_module(name, path)
|
||||||
newmodule = imp.load_module(name, *info)
|
newmodule = imp.load_module(name, *info)
|
||||||
path = os.path.dirname(newmodule.__file__)
|
path = [os.path.dirname(newmodule.__file__)]
|
||||||
info[0].close()
|
info[0].close()
|
||||||
except ImportError:
|
except ImportError:
|
||||||
irc.error(msg, 'No such module %s exists.' % module)
|
irc.error(msg, 'No such module %s exists.' % name)
|
||||||
return
|
return
|
||||||
if hasattr(newmodule, functionName):
|
if hasattr(newmodule, functionName):
|
||||||
f = getattr(newmodule, functionName)
|
f = getattr(newmodule, functionName)
|
||||||
|
@ -37,6 +37,9 @@ class PythonTestCase(PluginTestCase, PluginDocumentation):
|
|||||||
self.assertError('pydoc foobar')
|
self.assertError('pydoc foobar')
|
||||||
self.assertError('pydoc assert')
|
self.assertError('pydoc assert')
|
||||||
self.assertNotError('pydoc str')
|
self.assertNotError('pydoc str')
|
||||||
|
self.assertNotRegexp('pydoc crypt.crypt', 'NameError')
|
||||||
|
self.assertNotError('pydoc crypt.crypt')
|
||||||
|
self.assertNotError('pydoc math.sin')
|
||||||
self.assertNotError('pydoc string.translate')
|
self.assertNotError('pydoc string.translate')
|
||||||
self.assertNotError('pydoc fnmatch.fnmatch')
|
self.assertNotError('pydoc fnmatch.fnmatch')
|
||||||
self.assertNotError('pydoc socket.socket')
|
self.assertNotError('pydoc socket.socket')
|
||||||
|
Loading…
Reference in New Issue
Block a user