Stop the DOS box from showing when we launch the webdriver.

master
Pacman Ghost 2 years ago
parent 27bb528312
commit b497aa6e0f
  1. 10
      vasl_templates/webapp/static/help/index.html
  2. 13
      vasl_templates/webapp/webdriver.py

@ -69,12 +69,6 @@ pip install .[gui]
<p> Then, just run the <tt>vasl-templates</tt> command.
<div class="hint">
<a name="selenium-fix"></a>
<img src="images/selenium-fix.png" class="preview" style="float:right;width:250px;">
If you're running from source on Windows, you may see a black DOS box appear temporarily when performing certain actions (e.g. updating a VASL scenario). This is because <em>vasl-templates</em> runs a webdriver as part of its processing, which is a CLI program, and so the DOS box appears. Unfortunately, there's no way to control this in the <em>vasl-templates</em> code, but it can be disabled in the webdriver code itself. In your virtualenv, open the file <tt>Lib/site-packages/selenium/webdriver/common/service.py</tt>, and in the call to <tt>subprocess.Popen()</tt>, add a new <tt>creationflags = 0x8000000</tt> parameter.
</div>
<h4> Running just the web server </h4>
<p> The simpler option is to just run the web server:
@ -610,10 +604,6 @@ python freeze.py --output c:\temp\vasl-templates.zip
</div>
The script will compile the program, then package it all up with the necessary support files into a single archive file.
<div class="hint">
If you are creating a Windows release, you should apply the <a href="#selenium-fix" onclick="select_tab('installation');">webdriver fix</a> first.
</div>
</div>
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->

@ -11,7 +11,7 @@ from selenium import webdriver
from PIL import Image
from vasl_templates.webapp import app, globvars
from vasl_templates.webapp.utils import TempFile, SimpleError, trim_image
from vasl_templates.webapp.utils import TempFile, SimpleError, trim_image, is_windows
_logger = logging.getLogger( "webdriver" )
@ -58,13 +58,6 @@ class WebDriver:
if not webdriver_path:
raise SimpleError( "No webdriver has been configured." )
# NOTE: If we are being run on Windows without a console (e.g. the frozen PyQt desktop app),
# Selenium will launch the webdriver in a visible DOS box :-( There's no way to turn this off,
# but it can be disabled by modifying the Selenium source code. Find the subprocess.Popen() call
# in $/site-packages/selenium/webdriver/common/service.py and add the following parameter:
# creationflags = 0x8000000 # win32process.CREATE_NO_WINDOW
# It's pretty icky to have to do this, but since we're in a virtualenv, it's not too bad...
# create the webdriver
_logger.debug( "- Launching webdriver process: %s", webdriver_path )
log_fname = app.config.get( "WEBDRIVER_LOG",
@ -83,6 +76,8 @@ class WebDriver:
service = webdriver.chrome.service.Service(
webdriver_path, log_path=log_fname
)
if is_windows():
service.creationflags = 0x8000000 # win32process.CREATE_NO_WINDOW
self.driver = webdriver.Chrome(
options=options, service=service
)
@ -92,6 +87,8 @@ class WebDriver:
service = webdriver.firefox.service.Service(
webdriver_path, log_path=log_fname
)
if is_windows():
service.creationflags = 0x8000000 # win32process.CREATE_NO_WINDOW
self.driver = webdriver.Firefox(
options=options, proxy=None, service=service
)

Loading…
Cancel
Save