Changeset 682:08e73d58a9e4
- Timestamp:
- 10/01/15 18:11:10 (9 years ago)
- Branch:
- cef
- Phase:
- public
- Files:
-
- 5 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
makeinst.bat
r653 r682 2 2 set GTKRTDIR=c:\Python27\Lib\site-packages\gtk-2.0\runtime 3 3 set CEFDIR=c:\Python27\Lib\site-packages\cefpython3 4 set CHROMEDRIVER=c:\tmp\chromedriver.exe 4 5 set NSISDIR=C:\Program Files\NSIS 5 6 6 7 python setup.py py2exe 7 8 9 del dist\library\selenium\webdriver\chrome\service.pyc 10 copy patches\library\selenium\webdriver\chrome\service.py dist\library\selenium\webdriver\chrome\service.py 11 python -m compileall dist\library\selenium\webdriver\chrome\service.py 12 del dist\library\selenium\webdriver\chrome\service.py 13 8 14 "%NSISDIR%\makensis" mlx.nsi -
setup.py
r654 r682 20 20 "mlx.mo")])) 21 21 data_files.append(("", ["logo.png", 22 "conn_grey.png", "conn_red.png", "conn_green.png"])) 22 "conn_grey.png", "conn_red.png", "conn_green.png", 23 "mlx_cef_caller.sh", "mlx_cef_caller_secondary.sh", 24 "mlx_cef_caller.bat", "mlx_cef_caller_secondary.bat"])) 25 23 26 if os.name=="nt": 24 27 import py2exe 25 28 26 29 data_files.append(("", ["logo.ico"])) 30 31 chromedriver = os.environ.get("CHROMEDRIVER") 32 if chromedriver: 33 data_files.append(("", [chromedriver])) 27 34 28 35 msvcrDir = os.environ["MSVCRDIR"] if "MSVCRDIR" in os.environ else None … … 61 68 print >>f, '!define MLX_VERSION "%s"' % (mlx.const.VERSION) 62 69 f.close() 70 else: 71 for (dirpath, dirnames, filenames) in os.walk("patches"): 72 if filenames: 73 filenames = [os.path.join(dirpath, filename) 74 for filename in filenames] 75 data_files.append((dirpath, filenames)) 76 77 63 78 64 79 long_description="""MAVA Logger X -
src/mlx/const.py
r681 r682 11 11 12 12 ## The version of the program 13 VERSION="0.35.2 "13 VERSION="0.35.2cef" 14 14 15 15 #------------------------------------------------------------------------------- -
src/mlx/gui/cef.py
r648 r682 1 1 from common import * 2 3 from mlx.util import secondaryInstallation 4 5 from cefpython3 import cefpython 6 from selenium import webdriver 7 from selenium.webdriver.chrome.options import Options 2 8 3 9 import platform 4 10 import json 5 6 from cefpython3 import cefpython 7 11 import time 8 12 import os 9 13 import re 14 import threading 15 import tempfile 16 import traceback 10 17 11 18 #------------------------------------------------------------------------------ … … 20 27 _toQuit = False 21 28 22 #------------------------------------------------------------------------------ 23 24 def initialize(): 29 # The Selenium thread 30 _seleniumHandler = None 31 32 #------------------------------------------------------------------------------ 33 34 def getArgsFilePath(): 35 """Get the path of the argument file.""" 36 if os.name=="nt": 37 return os.path.join(tempfile.gettempdir(), 38 "mlxcef.args" + 39 (".secondary" if secondaryInstallation else "")) 40 else: 41 import pwd 42 return os.path.join(tempfile.gettempdir(), 43 "mlxcef." + pwd.getpwuid(os.getuid())[0] + ".args" + 44 (".secondary" if secondaryInstallation else "")) 45 46 #------------------------------------------------------------------------------ 47 48 class ArgsFileWaiter(threading.Thread): 49 """A thread to wait for the appearance of the arguments file.""" 50 def __init__(self, initializedCallback): 51 """Construct the thread.""" 52 threading.Thread.__init__(self) 53 self.daemon = True 54 55 self._initializedCallback = initializedCallback 56 57 def run(self): 58 """Repeatedly check for the existence of the arguments file. 59 60 If it is found, read it, extract the arguments and insert a job into 61 the GUI loop to perform the actual initialization of CEF.""" 62 argsFilePath = getArgsFilePath() 63 print "Waiting for the arguments file '%s' to appear" % (argsFilePath,) 64 65 while not os.path.exists(argsFilePath): 66 time.sleep(0.1) 67 68 print "Got arguments, reading them.""" 69 70 with open(argsFilePath, "rt") as f: 71 args = f.read().split() 72 73 gobject.idle_add(_initializeCEF, args, self._initializedCallback) 74 75 #------------------------------------------------------------------------------ 76 77 class SeleniumHandler(threading.Thread): 78 """Thread to handle Selenium operations.""" 79 def __init__(self, programDirectory): 80 """Construct the thread.""" 81 threading.Thread.__init__(self) 82 self.daemon = False 83 84 self._programDirectory = programDirectory 85 86 self._commandsCondition = threading.Condition() 87 self._commands = [] 88 89 self._toQuit = False 90 91 def run(self): 92 """Create the Selenium driver and the perform any operations 93 requested.""" 94 scriptName = "mlx_cef_caller" 95 if secondaryInstallation: 96 scriptName += "_secondary" 97 scriptName += ".bat" if os.name=="nt" else ".sh" 98 99 scriptPath = os.path.join(self._programDirectory, scriptName) 100 print "Creating the Selenium driver to call script", scriptPath 101 102 options = Options() 103 options.binary_location = scriptPath 104 driver = webdriver.Chrome(chrome_options = options) 105 # try: 106 # except: 107 # traceback.print_exc() 108 109 print "Created Selenium driver." 110 while not self._toQuit: 111 with self._commandsCondition: 112 while not self._commands: 113 self._commandsCondition.wait() 114 115 command = self._commands[0] 116 del self._commands[0] 117 118 command() 119 120 driver.quit() 121 122 def quit(self): 123 """Instruct the thread to quit and then join it.""" 124 self._enqueue(self._quit) 125 self.join() 126 127 def _enqueue(self, command): 128 """Enqueue the given command. 129 130 command should be a function to be executed in the thread.""" 131 with self._commandsCondition: 132 self._commands.append(command) 133 self._commandsCondition.notify() 134 135 def _quit(self): 136 """Set the _toQuit member variable to indicate that the thread should 137 quit.""" 138 self._toQuit = True 139 140 #------------------------------------------------------------------------------ 141 142 def initialize(programDirectory, initializedCallback): 25 143 """Initialize the Chrome Embedded Framework.""" 26 global _toQuit 144 global _toQuit, _seleniumHandler 27 145 _toQuit = False 28 146 29 147 gobject.threads_init() 148 149 argsFilePath = getArgsFilePath() 150 try: 151 os.unlink(argsFilePath) 152 except: 153 pass 154 155 _seleniumHandler = SeleniumHandler(programDirectory) 156 _seleniumHandler.start() 157 158 ArgsFileWaiter(initializedCallback).start() 159 160 #------------------------------------------------------------------------------ 161 162 def _initializeCEF(args, initializedCallback): 163 """Perform the actual initialization of CEF using the given arguments.""" 164 print "Initializing CEF with args:", args 30 165 31 166 settings = { … … 41 176 } 42 177 43 cefpython.Initialize(settings, {}) 178 switches={} 179 for arg in args: 180 if arg.startswith("--"): 181 if arg != "--enable-logging": 182 assignIndex = arg.find("=") 183 if assignIndex<0: 184 switches[arg[2:]] = "" 185 else: 186 switches[arg[2:assignIndex]] = arg[assignIndex+1:] 187 else: 188 print "Unhandled switch", arg 189 190 cefpython.Initialize(settings, switches) 44 191 45 192 gobject.timeout_add(10, _handleTimeout) 193 194 print "Initialized, executing callback..." 195 initializedCallback() 46 196 47 197 #------------------------------------------------------------------------------ … … 83 233 def finalize(): 84 234 """Finalize the Chrome Embedded Framework.""" 85 global _toQuit 235 global _toQuit, _seleniumHandler 86 236 toQuit = True 237 _seleniumHandler.quit() 87 238 cefpython.Shutdown() 88 239 -
src/mlx/gui/common.py
r604 r682 32 32 pygobject = False 33 33 import pygtk 34 pygtk.require("2.0") 34 35 import gtk.gdk as gdk 35 36 import gtk -
src/mlx/gui/gui.py
r652 r682 443 443 self._updater.start() 444 444 445 cef.initialize() 446 self._acars.start() 445 cef.initialize(self._programDirectory, self._cefInitialized) 447 446 448 447 singleton.raiseCallback = self.raiseCallback … … 1488 1487 summary, description, email) 1489 1488 1489 def _cefInitialized(self): 1490 """Called when CEF has been initialized.""" 1491 self._acars.start() 1492 1490 1493 def _bugReportSentCallback(self, returned, result): 1491 1494 """Callback function for the bug report sending result."""
Note:
See TracChangeset
for help on using the changeset viewer.