Mercurial > traipse_dev
changeset 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 | c97c641a76fd |
children | 292e064396e4 |
files | orpg/mapper/background_handler.py orpg/mapper/miniatures_handler.py orpg/orpgCore.py plugins/xxcherrypy.py |
diffstat | 4 files changed, 26 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/orpg/mapper/background_handler.py Fri Jul 17 01:27:26 2009 -0500 +++ b/orpg/mapper/background_handler.py Fri Jul 17 08:13:50 2009 -0500 @@ -79,9 +79,10 @@ if self.settings.get_setting('LocalorRemote') == 'Remote': thread.start_new_thread(self.canvas.layers['bg'].upload, (postdata, dlg.GetPath(), self.bg_type.GetStringSelection())) else: - url = self.settings.get_setting('LocalImageBaseURL') - print dlg.GetDirectory() - print orpg.dirpath.dir_struct["user"] + try: + min_url = open_rpg.get_component("cherrypy") + filename + except: + return if dlg.GetDirectory() == orpg.dirpath.dir_struct["user"]+'webfiles/Textures' or dlg.GetDirectory() == orpg.dirpath.dir_struct["user"]+'webfiles\Textures': url = self.settings.get_setting('LocalImageBaseURL') + 'Textures/' if dlg.GetDirectory() == orpg.dirpath.dir_struct["user"]+'webfiles/Maps' or dlg.GetDirectory() == orpg.dirpath.dir_struct["user"]+'webfiles\Maps': url = self.settings.get_setting('LocalImageBaseURL') + 'Maps/' if dlg.GetDirectory() == orpg.dirpath.dir_struct["user"]+'webfiles/Miniatures' or dlg.GetDirectory() == orpg.dirpath.dir_struct["user"]+'webfiles\Miniatures': url = self.settings.get_setting('LocalImageBaseURL') + 'Miniatures/'
--- a/orpg/mapper/miniatures_handler.py Fri Jul 17 01:27:26 2009 -0500 +++ b/orpg/mapper/miniatures_handler.py Fri Jul 17 08:13:50 2009 -0500 @@ -38,6 +38,7 @@ from grid import GRID_RECTANGLE from grid import GRID_HEXAGON from grid import GRID_ISOMETRIC + LABEL_TOOL = wx.NewId() LAYER_TOOL = wx.NewId() MIN_LIST_TOOL = wx.NewId() @@ -159,7 +160,10 @@ y = dc.DeviceToLogicalY(0) thread.start_new_thread(self.canvas.layers['miniatures'].upload, (postdata, dlg.GetPath()), {'pos':cmpPoint(x,y)}) else: - min_url = self.settings.get_setting('LocalImageBaseURL') + filename + try: + min_url = open_rpg.get_component("cherrypy") + filename + except: + return if dlg.GetDirectory() == orpg.dirpath.dir_struct["user"]+'webfiles/Textures' or dlg.GetDirectory() == orpg.dirpath.dir_struct["user"]+'webfiles\Textures': min_url = self.settings.get_setting('LocalImageBaseURL') + 'Textures/' + filename if dlg.GetDirectory() == orpg.dirpath.dir_struct["user"]+'webfiles/Maps' or dlg.GetDirectory() == orpg.dirpath.dir_struct["user"]+'webfiles\Maps': min_url = self.settings.get_setting('ImageServerBaseURL') + 'Maps/' + filename if dlg.GetDirectory() == orpg.dirpath.dir_struct["user"]+'webfiles/Miniatures' or dlg.GetDirectory() == orpg.dirpath.dir_struct["user"]+'webfiles\Miniatures': min_url = self.settings.get_setting('LocalImageBaseURL') + 'Miniatures/' + filename
--- a/orpg/orpgCore.py Fri Jul 17 01:27:26 2009 -0500 +++ b/orpg/orpgCore.py Fri Jul 17 08:13:50 2009 -0500 @@ -69,6 +69,12 @@ else: return None + def del_component(self, key): + if self.__components.has_key(key): + del self.__components[key] + else: + return + def singleton(cls): instances = {} def getinstance():
--- 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: