logger and gtkgui plugins can be launched after the core (if sock plugin is active)
This commit is contained in:
parent
03aee33e25
commit
331056f179
|
@ -40,6 +40,8 @@ class GajimHub:
|
|||
|
||||
def newPlugin(self, name):
|
||||
"""Creates a new Plugin """
|
||||
if name in self.queues.keys():
|
||||
return 0
|
||||
qu = self.newQueue(name, 100)
|
||||
pl = common.plugin.GajimPlugin(name, qu, self.queueIn)
|
||||
return pl
|
||||
|
|
|
@ -20,6 +20,9 @@
|
|||
import threading
|
||||
import socket
|
||||
import time
|
||||
import sys
|
||||
from common import i18n
|
||||
_ = i18n._
|
||||
|
||||
class GajimThread(threading.Thread):
|
||||
def __init__(self, name = None, queueIn = None, queueOut = None):
|
||||
|
@ -33,8 +36,12 @@ class GajimThread(threading.Thread):
|
|||
def run(self):
|
||||
mod = compile("import plugins.%s" % self.getName(), \
|
||||
self.getName(), "exec")
|
||||
res = eval(mod)
|
||||
mod = compile("plugins.%s.%s.plugin(self.queueIn, self.queueOut)" % (self.getName(),self.getName()), self.getName(), "exec")
|
||||
res = eval(mod)
|
||||
try:
|
||||
res = eval(mod)
|
||||
mod = compile("plugins.%s.%s.plugin(self.queueIn, self.queueOut)" % (self.getName(),self.getName()), self.getName(), "exec")
|
||||
res = eval(mod)
|
||||
except:
|
||||
print _("plugin %s cannot be launched : ") % self.getName() + \
|
||||
sys.exc_info()[1][1]
|
||||
# END run
|
||||
# END GajimThread
|
||||
|
|
10
core/core.py
10
core/core.py
|
@ -80,7 +80,13 @@ class GajimCore:
|
|||
mods = string.split (moduleStr, ' ')
|
||||
|
||||
for mod in mods:
|
||||
modObj = self.hub.newPlugin(mod)
|
||||
try:
|
||||
modObj = self.hub.newPlugin(mod)
|
||||
except:
|
||||
print _("The plugin %s cannot be launched")
|
||||
if not modObj:
|
||||
print _("The plugin %s is already launched" % mod)
|
||||
return
|
||||
modObj.load()
|
||||
# END loadPLugins
|
||||
|
||||
|
@ -576,6 +582,8 @@ class GajimCore:
|
|||
elif ev[0] == 'REG_MESSAGE':
|
||||
for msg in ev[2]:
|
||||
self.hub.register(ev[1], msg)
|
||||
elif ev[0] == 'EXEC_PLUGIN':
|
||||
self.loadPlugins(ev[2])
|
||||
else:
|
||||
log.debug(_("Unknown Command %s") % ev[0])
|
||||
if self.mode == 'server':
|
||||
|
|
|
@ -17,6 +17,39 @@
|
|||
## GNU General Public License for more details.
|
||||
##
|
||||
|
||||
def usage():
|
||||
#TODO: use i18n
|
||||
print "usage :", sys.argv[0], ' [OPTION]'
|
||||
print " -p\tport on whitch the sock plugin listen"
|
||||
print " -h, --help\tdisplay this help and exit"
|
||||
|
||||
if __name__ == "__main__":
|
||||
import getopt, pickle, sys, socket
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], "p:h", ["help"])
|
||||
except getopt.GetoptError:
|
||||
# print help information and exit:
|
||||
usage()
|
||||
sys.exit(2)
|
||||
port = 8255
|
||||
for o, a in opts:
|
||||
if o == '-p':
|
||||
port = a
|
||||
if o in ("-h", "--help"):
|
||||
usage()
|
||||
sys.exit()
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
try:
|
||||
sock.connect(('', 8255))
|
||||
except:
|
||||
#TODO: use i18n
|
||||
print "unable to connect to localhost on port "+str(port)
|
||||
else:
|
||||
evp = pickle.dumps(('EXEC_PLUGIN', '', 'gtkgui'))
|
||||
sock.send('<'+evp+'>')
|
||||
sock.close()
|
||||
sys.exit()
|
||||
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk
|
||||
|
@ -1828,7 +1861,4 @@ class plugin:
|
|||
gtk.main()
|
||||
gtk.threads_leave()
|
||||
|
||||
if __name__ == "__main__":
|
||||
plugin(None, None)
|
||||
|
||||
print _("plugin gtkgui loaded")
|
||||
|
|
|
@ -17,6 +17,39 @@
|
|||
## GNU General Public License for more details.
|
||||
##
|
||||
|
||||
def usage():
|
||||
#TODO: use i18n
|
||||
print "usage :", sys.argv[0], ' [OPTION]'
|
||||
print " -p\tport on whitch the sock plugin listen"
|
||||
print " -h, --help\tdisplay this help and exit"
|
||||
|
||||
if __name__ == "__main__":
|
||||
import getopt, sys, pickle, socket
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], "p:h", ["help"])
|
||||
except getopt.GetoptError:
|
||||
# print help information and exit:
|
||||
usage()
|
||||
sys.exit(2)
|
||||
port = 8255
|
||||
for o, a in opts:
|
||||
if o == '-p':
|
||||
port = a
|
||||
if o in ("-h", "--help"):
|
||||
usage()
|
||||
sys.exit()
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
try:
|
||||
sock.connect(('', 8255))
|
||||
except:
|
||||
#TODO: use i18n
|
||||
print "unable to connect to localhost on port "+str(port)
|
||||
else:
|
||||
evp = pickle.dumps(('EXEC_PLUGIN', '', 'logger'))
|
||||
sock.send('<'+evp+'>')
|
||||
sock.close()
|
||||
sys.exit()
|
||||
|
||||
import os
|
||||
import string
|
||||
import time
|
||||
|
@ -104,8 +137,4 @@ class plugin:
|
|||
print _("creating ~/.gajim/logs/")
|
||||
self.read_queue()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
plugin(None, None)
|
||||
|
||||
print _("plugin logger loaded")
|
||||
|
|
Loading…
Reference in New Issue