annotate plugins/xxcherrypy.py @ 189:7c1a8b36b729 beta

Traipse Beta 'OpenRPG' {100125-00} 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 (Beta) New Features: Added Bookmarks Added 'boot' command to remote admin Added confirmation window for sent nodes Minor changes to allow for portability to an OpenSUSE linux OS Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Zoom Mouse plugin added Images added to Plugin UI Switching to Element Tree Map efficiency, from FlexiRPG Added Status Bar to Update Manager New TrueDebug Class in orpg_log (See documentation for usage) Portable Mercurial Tip of the Day added, from Core and community New Reference Syntax added for custom PC sheets New Child Reference for gametree New Parent Reference for gametree New Gametree Recursion method, mapping, context sensitivity, and effeciency.. New Features node with bonus nodes and Node Referencing help added Dieroller structure from Core New DieRoller portability for odd Dice Added 7th Sea die roller; ie [7k3] = [7d10.takeHighest(3).open(10)] New 'Mythos' System die roller added Added new vs. die roller method for WoD; ie [3v3] = [3d10.vs(3)]. Included for Mythos roller also New Warhammer FRPG Die Roller (Special thanks to Puu-san for the support) New EZ_Tree Reference system. Push a button, Traipse the tree, get a reference (Beta!) Fixes: Fix to Text based Server Fix to Remote Admin Commands Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Fix to Map from gametree not showing to all clients Fix to gametree about menus Fix to Password Manager check on startup Fix to PC Sheets from tool nodes. They now use the tabber_panel Fix to Whiteboard ID to prevent random line or text deleting. Fixes to Server, Remote Server, and Server GUI Fix to Update Manager; cleaner clode for saved repositories Fixes made to Settings Panel and now reactive settings when Ok is pressed Fixes to Alternity roller's attack roll. Uses a simple Tuple instead of a Splice Fix to Use panel of Forms and Tabbers. Now longer enters design mode Fix made Image Fetching. New fetching image and new failed image Modified ID's to prevent non updated clients from ruining the fix. default_manifest.xml renamed to default_upmana.xml
author sirebral
date Mon, 25 Jan 2010 10:03:16 -0600
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)