Skip to content

Commit

Permalink
Merge branch 'master' of github.com:SergeyPirogov/webdriver_manager i…
Browse files Browse the repository at this point in the history
…nto gh_330_brave
  • Loading branch information
aleksandr-kotlyar committed Mar 1, 2022
2 parents 51048e4 + 0e525b7 commit c351d1e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions webdriver_manager/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import datetime
import base64
import os
import platform
import re
Expand Down Expand Up @@ -145,11 +144,11 @@ def windows_browser_apps_to_cmd(*apps: str) -> str:

script = (
"$ErrorActionPreference='silentlycontinue' ; "
f'{apps[0]}{ignore_errors_cmd_part} ;'
''.join(f" if (-not $? -or $? -match $error) {{ {i}{ignore_errors_cmd_part} }}" for i in apps[1:])
+ f'{apps[0]}{ignore_errors_cmd_part} ;'
+ ''.join(f" if (-not $? -or $? -match $error) {{ {i}{ignore_errors_cmd_part} }}" for i in apps[1:])
)

return f"{powershell}{script}"
return script if powershell else f'powershell "{script}"'


def get_browser_version_from_os(browser_type=None):
Expand Down Expand Up @@ -265,7 +264,7 @@ def read_version_from_cmd(cmd, pattern):


def determine_powershell():
"""Returns "powershell" if process runs in CMD console."""
"""Returns "True" if runs in Powershell and "False" if another console."""
cmd = '(dir 2>&1 *`|echo CMD);&<# rem #>echo powershell'
with subprocess.Popen(
cmd,
Expand All @@ -275,4 +274,4 @@ def determine_powershell():
shell=True,
) as stream:
stdout = stream.communicate()[0].decode()
return '' if stdout == 'powershell' else 'powershell '
return True if stdout == 'powershell' else False

0 comments on commit c351d1e

Please sign in to comment.