annotate plugins/xxcherrypy.py @ 220:9611ba80cf99 alpha

Traipse Alpha 'OpenRPG' {100501-01} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary (Patch-2) Moving to Beta!! New Features: New Namespace method with two new syntaxes New Namespace Internal is context sensitive, always! New Namespace External is 'as narrow as you make it' New Namespace FutureCheck helps ensure you don't receive an incorrect node New PluginDB access for URL2Link plugin New to Forms, they now show their content in Design Mode New to Update Manager, checks Repo for updates on software start New to Mini Lin node, change title in design mode New to Game Tree, never lose a node, appends a number to the end of corrupted trees New to Server GUI, Traipse Suite's Debug Console Updates: Update to White Board layer, uses a pencil image for color button Update to Grid Layer, uses a grid image for color button Update to Chat Window, size of drop down menus Update to default lobby message Update to template Text node Update to 4e PC Sheet node Fixes: Fix to Server GUI startup errors Fix to Server GUI Rooms tab updating Fix to Chat and Settings if non existant die roller is picked Fix to Dieroller and .open() used with .vs(). Successes are correctly calculated Fix to Alias Lib's Export to Tree, Open, Save features Fix to alias node, now works properly Fix to Splitter node, minor GUI cleanup Fix to Backgrounds not loading through remote loader Fix to Node name errors Fix to rolling dice in chat Whispers Fix to Splitters Sizing issues Fix to URL2Link plugin, modified regex compilation should remove memory leak Fix to mapy.py, a roll back due to zoomed grid issues Fix to whiteboard_handler, Circles work by you clicking the center of the circle Fix to Servers parse_incoming_dom which was outdated and did not respect XML Fix to a broken link in the server welcome message Fix to InterParse and logger requiring traceback Fix to Update Manager Status Bar Fix to failed image and erroneous pop up Fix to Mini Lib node that was preventing use Fix to plugins that parce dice but did not call InterParse Fix to nodes for name changing by double click Fix to Game Tree, node ordering on drag and drop corrected Fix to Game Tree, corrupted error message was not showing Fix to Update Manager, checks for internet connection Fix to Update Manager, Auto Update corrections
author sirebral
date Sat, 01 May 2010 03:21:26 -0500
parents c54768cffbd4
children
rev   line source
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
1 import os
14
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 13
diff changeset
2 import wx
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
3 import orpg.plugindb # VEG
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
4 import orpg.pluginhandler
14
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 13
diff changeset
5 from orpg.orpgCore import *
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 13
diff changeset
6 import urllib
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
7 import thread
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
8 import socket
14
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 13
diff changeset
9 import cherrypy._cpserver as server
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 13
diff changeset
10 from xml.dom.minidom import parseString
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
11
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
12 # VEG (march 21, 2007): Now remembers your last web server on/off setting
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
13
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
14 class Plugin(orpg.pluginhandler.PluginHandler):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
15 # Initialization subroutine.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
16 #
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
17 # !self : instance of self
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
18 # !openrpg : instance of the the base openrpg control
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
19 def __init__(self, plugindb, parent):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
20 orpg.pluginhandler.PluginHandler.__init__(self, plugindb, parent)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
21
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
22 # The Following code should be edited to contain the proper information
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
23 self.name = 'CherryPy Web Server'
14
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 13
diff changeset
24 self.author = 'Dj Gilcrease & Sir. Ebral'
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
25 self.help = 'This plugin turns OpenRPG into a Web server\n'
14
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 13
diff changeset
26 self.help += 'allowing you to host your map and mini files locally.'
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
27
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
28 #You can set variables below here. Always set them to a blank value in this section. Use plugin_enabled
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
29 #to set their proper values.
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
30 self.isServerRunning = 'off'
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
31 self.host = 0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
32
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
33 def plugin_menu(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
34 self.menu = wx.Menu()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
35 self.toggle = self.menu.AppendCheckItem(wx.ID_ANY, 'On')
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
36 self.topframe.Bind(wx.EVT_MENU, self.cherrypy_toggle, self.toggle)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
37
14
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 13
diff changeset
38 def cherrypy_toggle(self, evt): #TAS
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 13
diff changeset
39 if self.toggle.IsChecked() == True: self.on_cherrypy("on")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
40 if self.toggle.IsChecked() == False: self.on_cherrypy("off")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
41
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
42 def plugin_enabled(self):
14
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 13
diff changeset
43 self.host = parseString(
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 13
diff changeset
44 urllib.urlopen("http://orpgmeta.appspot.com/myip").read()
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 13
diff changeset
45 ).documentElement.getAttribute("ip")
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 13
diff changeset
46
18
67b900deb35c One more run before moving to stable.
sirebral
parents: 14
diff changeset
47 self.port = int(self.plugindb.GetString("xxcherrypy", "port", 8080)) or 6775
14
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 13
diff changeset
48
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 13
diff changeset
49 self.plugin_addcommand('/cherrypy', self.on_cherrypy,
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 13
diff changeset
50 '[on | off | port | status] - This controls the CherryPy Web Server')
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 13
diff changeset
51
19
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 18
diff changeset
52 cherry_start = str(self.plugindb.GetString("xxcherrypy", "auto_start", None)) #VEG, DJG, TAS
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 18
diff changeset
53 if cherry_start == "on": self.on_cherrypy("on")
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 18
diff changeset
54 else: pass
78407d627cba Beginning of Code Clean-up. Some code untested, may break!
sirebral
parents: 18
diff changeset
55 del cherry_start
14
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 13
diff changeset
56
10
73d9286c22cf Adds some superb CherryPy features! Components can be deleted now too!
sirebral
parents: 0
diff changeset
57 self.cherryhost = 'http://' + self.host + ':' + str(self.port) + '/webfiles/'
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 19
diff changeset
58 component.add("cherrypy", self.cherryhost)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
59
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
60 def plugin_disabled(self):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
61 #Here you need to remove any commands you added, and anything else you want to happen when you disable the plugin
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
62 #such as closing windows created by the plugin
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
63 self.plugin_removecmd('/cherrypy')
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
64 if self.isServerRunning == 'on':
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
65 server.stop()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
66 self.isServerRunning = 'off'
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
67 else:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
68 pass
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 19
diff changeset
69 component.delete("cherrypy")
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
70
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
71 def on_cherrypy(self, cmdargs):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
72 args = cmdargs.split(None,-1)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
73
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
74 if len(args) == 0 or args[0] == 'status':
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
75 self.chat.InfoPost("CherryPy Web Server is currently: " + self.isServerRunning)
14
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 13
diff changeset
76 self.chat.InfoPost("CherryPy Web Server address is: " + self.cherryhost)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
77
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
78 elif args[0] == 'on' and self.isServerRunning == 'off':
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
79 self.webserver = thread.start_new_thread(self.startServer, (self.port,))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
80 self.isServerRunning = 'on'
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
81 self.toggle.Check(True)
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
82 self.plugindb.SetString("xxcherrypy", "auto_start", "on") # VEG
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
83
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
84 elif args[0] == 'off' and self.isServerRunning == 'on':
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
85 server.stop()
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
86 self.isServerRunning = 'off'
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
87 self.toggle.Check(False)
14
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 13
diff changeset
88 self.chat.InfoPost("CherryPy Web Server is currently: " + self.isServerRunning)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
89 self.plugindb.SetString("xxcherrypy", "auto_start", "off") # VEG
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
90
14
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 13
diff changeset
91 elif args[0] == 'port': #TAS
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
92 if self.isServerRunning == 'on':
13
3add6bbc3a56 CherryPy is set with auto start. THIS IS A TEST!
sirebral
parents: 10
diff changeset
93 self.chat.InfoPost('Please turn CherryPy off first!')
3add6bbc3a56 CherryPy is set with auto start. THIS IS A TEST!
sirebral
parents: 10
diff changeset
94 return
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
95 self.port = int(args[1])
13
3add6bbc3a56 CherryPy is set with auto start. THIS IS A TEST!
sirebral
parents: 10
diff changeset
96 self.plugindb.SetString("xxcherrypy", "port", str(self.port)) # TAS
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
97 self.chat.InfoPost("CherryPy Web Server is currently: " + self.isServerRunning)
13
3add6bbc3a56 CherryPy is set with auto start. THIS IS A TEST!
sirebral
parents: 10
diff changeset
98 self.cherryhost = 'http://' + self.host + ':' + str(self.port) + '/webfiles/'
66
c54768cffbd4 Traipse Dev 'OpenRPG' {090818-00}
sirebral
parents: 19
diff changeset
99 component.delete("cherrypy"); component.add("cherrypy", self.cherryhost)
13
3add6bbc3a56 CherryPy is set with auto start. THIS IS A TEST!
sirebral
parents: 10
diff changeset
100 self.chat.InfoPost('CherryPy Web Server address is: ' + self.cherryhost)
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
101
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
102 def startServer(self, port):
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
103 try:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
104 if self.host == 0:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
105 raise Exception("Invalid IP address.<br />This error means you are behind a router or some other form of network that is giving you a Privet IP only (ie. 192.168.x.x, 10.x.x.x, 172.16 - 32.x.x)")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
106
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
107 self.chat.InfoPost("CherryPy Web Server is now running on http://" + str(self.host) + ':' + str(self.port) + '/webfiles/')
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
108 server.start(configMap =
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
109 {'staticContentList': [['', r''+orpg.dirpath.dir_struct["user"]+'webfiles/'],
14
0b8b7e3ed78d Adding fixes from OpenRPG 1.8.0
sirebral
parents: 13
diff changeset
110 ['webfiles', r''+orpg.dirpath.dir_struct["user"]+'webfiles/']],
0
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
111 'socketPort': port,
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
112 'logToScreen': 0,
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
113 'logFile':orpg.dirpath.dir_struct["user"]+'webfiles/log.txt',
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
114 'sessionStorageType':'ram',
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
115 'threadPool':10,
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
116 'sessionTimeout':30,
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
117 'sessionCleanUpDelay':30})
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
118
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
119 except Exception, e:
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
120 self.chat.InfoPost("FAILED to start server!")
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
121 self.chat.InfoPost(str(e))
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
122 self.isServerRunning = 'off'
4385a7d0efd1 Deleted and repushed it with the 'grumpy-goblin' branch. I forgot a y
sirebral
parents:
diff changeset
123 self.toggle.Check(False)