mirror of
https://github.com/sherlock-project/sherlock
synced 2024-11-22 11:53:03 +00:00
Fix platform differences
This commit is contained in:
parent
906575df3a
commit
4aaf0583c5
2 changed files with 15 additions and 7 deletions
5
.github/workflows/pull_request.yml
vendored
5
.github/workflows/pull_request.yml
vendored
|
@ -4,7 +4,7 @@ on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ master ]
|
branches: [ master ]
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches: [ master, feature/tox ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
regression-testing:
|
regression-testing:
|
||||||
|
@ -14,7 +14,8 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
os: [
|
os: [
|
||||||
ubuntu-latest,
|
ubuntu-latest,
|
||||||
#windows-latest, # Need to adapt test_no_usernames_provided, test_versioning
|
windows-latest,
|
||||||
|
macos-latest,
|
||||||
]
|
]
|
||||||
python-version: [
|
python-version: [
|
||||||
'3.8',
|
'3.8',
|
||||||
|
|
|
@ -1,23 +1,30 @@
|
||||||
import os
|
import os
|
||||||
|
import platform
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
class Interactives:
|
class Interactives:
|
||||||
def run_cli(args: str = "") -> str:
|
def run_cli(args:str = "") -> str:
|
||||||
"""Pass arguments to Sherlock as a normal user on the command line"""
|
"""Pass arguments to Sherlock as a normal user on the command line"""
|
||||||
command = [f"sherlock {args}"]
|
# Adapt for platform differences (Windows likes to be special)
|
||||||
proc_out: str = ""
|
if platform.system == "Windows":
|
||||||
|
command:str = f"py -m sherlock {args}"
|
||||||
|
else:
|
||||||
|
command:str = f"sherlock {args}"
|
||||||
|
|
||||||
|
proc_out:str = ""
|
||||||
try:
|
try:
|
||||||
proc_out = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT)
|
proc_out = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT)
|
||||||
return proc_out.decode()
|
return proc_out.decode()
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
raise InteractivesSubprocessError(e.output.decode())
|
raise InteractivesSubprocessError(e.output.decode())
|
||||||
|
|
||||||
|
|
||||||
# -> list[str] is prefered, but will require deprecation of support for Python 3.8
|
# -> list[str] is prefered, but will require deprecation of support for Python 3.8
|
||||||
def walk_sherlock_for_files_with(pattern: str) -> list:
|
def walk_sherlock_for_files_with(pattern: str) -> list:
|
||||||
"""Check all files within the Sherlock package for matching patterns"""
|
"""Check all files within the Sherlock package for matching patterns"""
|
||||||
pattern: re.Pattern = re.compile(pattern)
|
pattern:re.Pattern = re.compile(pattern)
|
||||||
matching_files: list[str] = []
|
matching_files:list[str] = []
|
||||||
for root, dirs, files in os.walk("sherlock"):
|
for root, dirs, files in os.walk("sherlock"):
|
||||||
for file in files:
|
for file in files:
|
||||||
file_path = os.path.join(root,file)
|
file_path = os.path.join(root,file)
|
||||||
|
|
Loading…
Reference in a new issue