move /pyeval back to main.py, so modules can be accessed
This commit is contained in:
51
main.py
51
main.py
@@ -2,15 +2,30 @@ __plugin_name__ = "RedstonerUtils"
|
|||||||
__plugin_version__ = "3.0"
|
__plugin_version__ = "3.0"
|
||||||
__plugin_mainclass__ = "foobar"
|
__plugin_mainclass__ = "foobar"
|
||||||
|
|
||||||
# damn pythonloader changed the PATH
|
|
||||||
import sys
|
import sys
|
||||||
|
import thread
|
||||||
|
|
||||||
|
# damn pythonloader changed the PATH
|
||||||
sys.path += ['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/pymodules/python2.7', '/usr/lib/pyshared/python2.7']
|
sys.path += ['', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/pymodules/python2.7', '/usr/lib/pyshared/python2.7']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from helpers import log, error
|
from helpers import *
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print("[RedstonerUtils] ERROR: Failed to import helpers: %s" % e)
|
print("[RedstonerUtils] ERROR: Failed to import helpers: %s" % e)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@hook.enable
|
||||||
|
def onEnable():
|
||||||
|
log("RedstonerUtils enabled!")
|
||||||
|
|
||||||
|
|
||||||
|
@hook.disable
|
||||||
|
def onDisable():
|
||||||
|
mod["reports"].stopChecking()
|
||||||
|
log("RedstonerUtils disabled!")
|
||||||
|
|
||||||
|
|
||||||
log("Loading RedstonerUtils...")
|
log("Loading RedstonerUtils...")
|
||||||
|
|
||||||
# Import all modules
|
# Import all modules
|
||||||
@@ -24,11 +39,29 @@ for module in modules:
|
|||||||
error("Failed to import module %s: '%s'" % (module, e))
|
error("Failed to import module %s: '%s'" % (module, e))
|
||||||
|
|
||||||
|
|
||||||
@hook.enable
|
|
||||||
def onEnable():
|
|
||||||
log("RedstonerUtils enabled!")
|
|
||||||
|
|
||||||
@hook.disable
|
#
|
||||||
def onDisable():
|
# /pyeval - run python ingame
|
||||||
mod["reports"].stopChecking()
|
#
|
||||||
log("RedstonerUtils disabled!")
|
# has to be in main.py so we can access the modules
|
||||||
|
|
||||||
|
def evalThread(sender, code):
|
||||||
|
try:
|
||||||
|
msg(sender, "%s" % unicode(eval(code)), False, "a")
|
||||||
|
except Exception, e:
|
||||||
|
msg(sender, "%s: %s" % (e.__class__.__name__, e), False, "c")
|
||||||
|
thread.exit()
|
||||||
|
|
||||||
|
@hook.command("pyeval")
|
||||||
|
def onPyevalCommand(sender, args):
|
||||||
|
if sender.hasPermission("utils.pyeval"):
|
||||||
|
if not checkargs(sender, args, 1, -1):
|
||||||
|
return True
|
||||||
|
msg(sender, "%s" % " ".join(args), False, "e")
|
||||||
|
try:
|
||||||
|
thread.start_new_thread(evalThread, (sender, " ".join(args)))
|
||||||
|
except Exception, e:
|
||||||
|
msg(sender, "&cInternal error: %s" % e)
|
||||||
|
else:
|
||||||
|
noperm(sender)
|
||||||
|
return True
|
||||||
28
misc.py
28
misc.py
@@ -1,5 +1,4 @@
|
|||||||
from helpers import *
|
from helpers import *
|
||||||
import thread
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -34,33 +33,6 @@ def onJoin(event):
|
|||||||
msg(player, " \n ")
|
msg(player, " \n ")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# /pyeval - run python ingame
|
|
||||||
#
|
|
||||||
|
|
||||||
def evalThread(sender, code):
|
|
||||||
try:
|
|
||||||
msg(sender, "%s" % unicode(eval(code)), False, "a")
|
|
||||||
except Exception, e:
|
|
||||||
msg(sender, "%s: %s" % (e.__class__.__name__, e), False, "c")
|
|
||||||
thread.exit()
|
|
||||||
|
|
||||||
@hook.command("pyeval")
|
|
||||||
def onPyevalCommand(sender, args):
|
|
||||||
if sender.hasPermission("utils.pyeval"):
|
|
||||||
if not checkargs(sender, args, 1, -1):
|
|
||||||
return True
|
|
||||||
msg(sender, "%s" % " ".join(args), False, "e")
|
|
||||||
try:
|
|
||||||
thread.start_new_thread(evalThread, (sender, " ".join(args)))
|
|
||||||
except Exception, e:
|
|
||||||
msg(sender, "&cInternal error: %s" % e)
|
|
||||||
else:
|
|
||||||
noperm(sender)
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# /sudo - execute command/chat *as* a player/console
|
# /sudo - execute command/chat *as* a player/console
|
||||||
#
|
#
|
||||||
|
|||||||
Reference in New Issue
Block a user