Mercurial > traipse_dev
comparison plugins/xxcherrypy.py @ 13:3add6bbc3a56 traipse_dev
CherryPy is set with auto start. THIS IS A TEST!
author | sirebral |
---|---|
date | Sat, 18 Jul 2009 11:08:53 -0500 |
parents | 73d9286c22cf |
children | 0b8b7e3ed78d |
comparison
equal
deleted
inserted
replaced
12:c056e967907a | 13:3add6bbc3a56 |
---|---|
36 def cherrypy_toggle(self, evt): | 36 def cherrypy_toggle(self, evt): |
37 if self.toggle.IsChecked() == True: self.on_cherrypy("on") | 37 if self.toggle.IsChecked() == True: self.on_cherrypy("on") |
38 if self.toggle.IsChecked() == False: self.on_cherrypy("off") | 38 if self.toggle.IsChecked() == False: self.on_cherrypy("off") |
39 | 39 |
40 def plugin_enabled(self): | 40 def plugin_enabled(self): |
41 self.port = 6775 | 41 cpport = 0 # Container object so we can call port instead of an assigned ## |
42 self.port = 6775 if not int(self.plugindb.GetString("xxcherrypy", "port", cpport)) else int(self.plugindb.GetString("xxcherrypy", "port", cpport)); del cpport #Deletes port container. | |
42 self.plugin_addcommand('/cherrypy', self.on_cherrypy, '[on | off | port | status] - This controls the CherryPy Web Server') | 43 self.plugin_addcommand('/cherrypy', self.on_cherrypy, '[on | off | port | status] - This controls the CherryPy Web Server') |
43 import urllib | 44 import urllib |
44 url = urllib.URLopener() | 45 url = urllib.URLopener() |
45 resp = url.open('http://www.knowledgearcana.com/vgt/ip_scrape.php') | 46 resp = url.open('http://www.knowledgearcana.com/vgt/ip_scrape.php') |
46 html = resp.read(19+19) | 47 html = resp.read(19+19) |
47 ip = html[19:]; self.host = ip[1:len(ip)-1] | 48 ip = html[19:]; self.host = ip[1:len(ip)-1] |
48 #if str(self.plugindb.GetString("xxcherrypy", "auto_start", "off")) == "on": # VEG | 49 cpobj = 0 |
49 # self.on_cherrypy("on") # VEG | 50 if str(self.plugindb.GetString("xxcherrypy", "auto_start", cpobj)) == "on": # VEG |
51 self.on_cherrypy("on") # VEG | |
52 del cpobj | |
50 self.cherryhost = 'http://' + self.host + ':' + str(self.port) + '/webfiles/' | 53 self.cherryhost = 'http://' + self.host + ':' + str(self.port) + '/webfiles/' |
51 open_rpg.add_component("cherrypy", self.cherryhost) | 54 open_rpg.add_component("cherrypy", self.cherryhost) |
52 | 55 |
53 def plugin_disabled(self): | 56 def plugin_disabled(self): |
54 #Here you need to remove any commands you added, and anything else you want to happen when you disable the plugin | 57 #Here you need to remove any commands you added, and anything else you want to happen when you disable the plugin |
81 self.chat.InfoPost("CherryPy Web Server is now disabled") | 84 self.chat.InfoPost("CherryPy Web Server is now disabled") |
82 self.plugindb.SetString("xxcherrypy", "auto_start", "off") # VEG | 85 self.plugindb.SetString("xxcherrypy", "auto_start", "off") # VEG |
83 | 86 |
84 elif args[0] == 'port': | 87 elif args[0] == 'port': |
85 if self.isServerRunning == 'on': | 88 if self.isServerRunning == 'on': |
86 self.port = int(args[1]) | 89 self.chat.InfoPost('Please turn CherryPy off first!') |
87 server.stop() | 90 return |
88 self.webserver = thread.start_new_thread(self.startServer, (self.port,)) | |
89 self.port = int(args[1]) | 91 self.port = int(args[1]) |
90 self.plugindb.SetString("xxcherrypy", "port", str(self.port)) # VEG | 92 self.plugindb.SetString("xxcherrypy", "port", str(self.port)) # TAS |
91 self.chat.InfoPost("CherryPy Web Server is currently: " + self.isServerRunning) | 93 self.chat.InfoPost("CherryPy Web Server is currently: " + self.isServerRunning) |
92 self.chat.InfoPost("CherryPy Web Server address is: http://" + str(self.host) + ':' + str(self.port) + '/webfiles/') | 94 self.cherryhost = 'http://' + self.host + ':' + str(self.port) + '/webfiles/' |
95 open_rpg.del_component("cherrypy"); open_rpg.add_component("cherrypy", self.cherryhost) | |
96 self.chat.InfoPost('CherryPy Web Server address is: ' + self.cherryhost) | |
93 | 97 |
94 | 98 |
95 def startServer(self, port): | 99 def startServer(self, port): |
96 try: | 100 try: |
97 if self.host == 0: | 101 if self.host == 0: |