Skip to content

Commit

Permalink
Trying to avoid having Command Prompt windows pop up when
Browse files Browse the repository at this point in the history
we run cscript.exe on Windows.
  • Loading branch information
wettenhj committed Sep 23, 2015
1 parent 90824db commit 0a56874
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions mydata/models/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
from mydata.utils.exceptions import Unauthorized
from mydata.utils.exceptions import IncompatibleMyTardisVersion

defaultStartupInfo = None
defaultCreationFlags = 0
if sys.platform.startswith("win"):
defaultStartupInfo = subprocess.STARTUPINFO()
defaultStartupInfo.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW
defaultStartupInfo.wShowWindow = subprocess.SW_HIDE
import win32process
defaultCreationFlags = win32process.CREATE_NO_WINDOW


class LastSettingsUpdateTrigger:
READ_FROM_DISK = 0
Expand Down Expand Up @@ -948,7 +957,9 @@ def invalid_user():
logger.info("Checking for MyData shortcut in user "
"startup items.")
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, shell=False)
stderr=subprocess.STDOUT, shell=False,
startupinfo=defaultStartupInfo,
creationflags=defaultCreationFlags)
output, _ = proc.communicate()
shortcutInStartupItems = (proc.returncode == 0)
if shortcutInStartupItems:
Expand All @@ -968,7 +979,9 @@ def invalid_user():
logger.info("Checking for MyData shortcut in common "
"startup items.")
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT, shell=False)
stderr=subprocess.STDOUT, shell=False,
startupinfo=defaultStartupInfo,
creationflags=defaultCreationFlags)
output, _ = proc.communicate()
shortcutInCommonStartupItems = (proc.returncode == 0)
if shortcutInCommonStartupItems:
Expand Down Expand Up @@ -1009,7 +1022,9 @@ def invalid_user():
"startup items.")
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
shell=False)
shell=False,
startupinfo=defaultStartupInfo,
creationflags=defaultCreationFlags)
output, _ = proc.communicate()
success = (proc.returncode == 0)
if not success:
Expand All @@ -1035,7 +1050,9 @@ def invalid_user():
cmd = ['cscript', '//Nologo', vbScript.name]
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
shell=False)
shell=False,
startupinfo=defaultStartupInfo,
creationflags=defaultCreationFlags)
output, _ = proc.communicate()
success = (proc.returncode == 0)
if not success:
Expand Down

0 comments on commit 0a56874

Please sign in to comment.