Mercurial > traipse_dev
diff plugins/xxcherrypy.py @ 10:73d9286c22cf traipse_dev
Adds some superb CherryPy features! Components can be deleted now too!
author | sirebral |
---|---|
date | Fri, 17 Jul 2009 08:13:50 -0500 |
parents | 4385a7d0efd1 |
children | 3add6bbc3a56 |
line wrap: on
line diff
--- a/plugins/xxcherrypy.py Fri Jul 17 01:27:26 2009 -0500 +++ b/plugins/xxcherrypy.py Fri Jul 17 08:13:50 2009 -0500 @@ -5,6 +5,7 @@ import cherrypy._cpserver as server import socket import wx +from orpg.orpgCore import * # VEG (march 21, 2007): Now remembers your last web server on/off setting @@ -32,32 +33,22 @@ self.toggle = self.menu.AppendCheckItem(wx.ID_ANY, 'On') self.topframe.Bind(wx.EVT_MENU, self.cherrypy_toggle, self.toggle) - ports = wx.Menu() - self.portClient = ports.AppendRadioItem(wx.ID_ANY, 'Client:9557') - self.portServer = ports.AppendRadioItem(wx.ID_ANY, 'Server:9558') - self.topframe.Bind(wx.EVT_MENU, self.port_change, self.portClient) - self.topframe.Bind(wx.EVT_MENU, self.port_change, self.portServer) - self.menu.AppendMenu(wx.ID_ANY, 'Port', ports) - - def port_change(self, evt): - if self.portClient.IsChecked() == True: self.on_cherrypy("port 9557") - if self.portServer.IsChecked() == True: self.on_cherrypy("port 9558") - def cherrypy_toggle(self, evt): if self.toggle.IsChecked() == True: self.on_cherrypy("on") if self.toggle.IsChecked() == False: self.on_cherrypy("off") def plugin_enabled(self): - self.port = 9557 + self.port = 6775 self.plugin_addcommand('/cherrypy', self.on_cherrypy, '[on | off | port | status] - This controls the CherryPy Web Server') - tmp = socket.gethostbyname_ex(socket.gethostname()) - for ip in tmp[2]: - self.host = ip - if ip[:7] == '192.168' or ip[:3] == '10.' or ip == '127.0.0.1' or (ip[:3] == '172' and (int(ip[5:6]) >= 16 and int(ip[5:6]) <=32)) : - self.chat.InfoPost("[WARNING] Cherrypy has detected that you may be behind a router. This is your internal IP. For other users to properly connect, you may have to use your external IP, with port forwarding on port 80.<br />This feature is not suported in any way.") - + import urllib + url = urllib.URLopener() + resp = url.open('http://www.knowledgearcana.com/vgt/ip_scrape.php') + html = resp.read(19+19) + ip = html[19:]; self.host = ip[1:len(ip)-1] #if str(self.plugindb.GetString("xxcherrypy", "auto_start", "off")) == "on": # VEG # self.on_cherrypy("on") # VEG + self.cherryhost = 'http://' + self.host + ':' + str(self.port) + '/webfiles/' + open_rpg.add_component("cherrypy", self.cherryhost) def plugin_disabled(self): #Here you need to remove any commands you added, and anything else you want to happen when you disable the plugin @@ -68,7 +59,7 @@ self.isServerRunning = 'off' else: pass - + open_rpg.del_component("cherrypy") def on_cherrypy(self, cmdargs): args = cmdargs.split(None,-1) @@ -96,11 +87,11 @@ server.stop() self.webserver = thread.start_new_thread(self.startServer, (self.port,)) self.port = int(args[1]) + self.plugindb.SetString("xxcherrypy", "port", str(self.port)) # VEG self.chat.InfoPost("CherryPy Web Server is currently: " + self.isServerRunning) self.chat.InfoPost("CherryPy Web Server address is: http://" + str(self.host) + ':' + str(self.port) + '/webfiles/') - def startServer(self, port): try: if self.host == 0: