Changeset 724af06 in sasview for src/sas/sasgui/guiframe/documentation_window.py
- Timestamp:
- Sep 21, 2017 3:12:37 PM (7 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 12d3e0e
- Parents:
- ce81f70 (diff), d76c43a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/guiframe/documentation_window.py
rd66dbcc r724af06 24 24 import wx.html2 as html 25 25 WX_SUPPORTS_HTML2 = True 26 except :26 except ImportError: 27 27 WX_SUPPORTS_HTML2 = False 28 28 29 29 from sas.sasgui import get_app_dir 30 30 31 # Don't use wx html renderer on windows. 32 if os.name == 'nt': 33 WX_SUPPORTS_HTML2 = False 34 31 35 logger = logging.getLogger(__name__) 32 36 33 37 SPHINX_DOC_ENV = "SASVIEW_DOC_PATH" 38 39 THREAD_STARTED = False 40 def start_documentation_server(doc_root, port): 41 import thread 42 global THREAD_STARTED 43 if not THREAD_STARTED: 44 thread.start_new_thread(_documentation_server, (doc_root, port)) 45 THREAD_STARTED = True 46 47 def _documentation_server(doc_root, port): 48 from SimpleHTTPServer import SimpleHTTPRequestHandler 49 from SocketServer import TCPServer 50 51 os.chdir(doc_root) 52 httpd = TCPServer(("127.0.0.1", port), SimpleHTTPRequestHandler, bind_and_activate=False) 53 httpd.allow_reuse_address = True 54 try: 55 httpd.server_bind() 56 httpd.server_activate() 57 httpd.serve_forever() 58 finally: 59 httpd.server_close() 34 60 35 61 class DocumentationWindow(wx.Frame): … … 69 95 #Note added June 21, 2015 PDB 70 96 file_path = os.path.join(docs_path, path) 71 url = "file:///" + urllib.quote(file_path, r'/\:')+ url_instruction 97 if path.startswith('http'): 98 url = path 99 elif not os.path.exists(file_path): 100 url = "index.html" 101 logger.error("Could not find Sphinx documentation at %s -- has it been built?", 102 file_path) 103 elif False: 104 start_documentation_server(docs_path, port=7999) 105 url = "http://127.0.0.1:7999/" + path.replace('\\', '/') + url_instruction 106 else: 107 url = "file:///" + urllib.quote(file_path, r'/\:')+ url_instruction 72 108 73 if not os.path.exists(file_path): 74 logger.error("Could not find Sphinx documentation at %s \ 75 -- has it been built?", file_path) 76 elif WX_SUPPORTS_HTML2: 109 #logger.info("showing url " + url) 110 if WX_SUPPORTS_HTML2: 77 111 # Complete HTML/CSS support! 78 112 self.view = html.WebView.New(self) 79 113 self.view.LoadURL(url) 114 self.Bind(html.EVT_WEBVIEW_ERROR, self.OnError, self.view) 80 115 self.Show() 81 116 else: … … 87 122 webbrowser.open_new_tab(url) 88 123 124 def OnError(self, evt): 125 logger.error("%d: %s", evt.GetInt(), evt.GetString()) 126 89 127 def main(): 90 128 """ 91 129 main loop function if running alone for testing. 92 130 """ 131 url = "index.html" if len(sys.argv) <= 1 else sys.argv[1] 93 132 app = wx.App() 94 DocumentationWindow(None, -1, "index.html", "", "Documentation",)133 DocumentationWindow(None, -1, url, "", "Documentation",) 95 134 app.MainLoop() 96 135
Note: See TracChangeset
for help on using the changeset viewer.