Skip to content

Add path conversion for addAUT() #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions squape/squishserver.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
import os
from pathlib import Path
from pathlib import PureWindowsPath

try:
import squish
Expand Down Expand Up @@ -76,7 +77,7 @@ def _config_squishserver(self, config_option: str, params=None, cwd=None):
config_option (str): the config option to be used during configuration.
params (list, optional): the configuration parameters. Defaults to [].
cwd (str): the path to the current working directory.
Defaults to the "SQUISH_PREFIX" environment vairable.
Defaults to the squishserver location.
"""
if params is None:
params = []
Expand All @@ -89,7 +90,15 @@ def _config_squishserver(self, config_option: str, params=None, cwd=None):
f"Executing command: {' '.join(cmd)}",
f"cwd: {cwd}",
)
(exitcode, stdout, stderr) = self.remotesys.execute(cmd, cwd)

if self.remotesys.getOSName() == "Windows":
(exitcode, stdout, stderr) = self.remotesys.execute(cmd, cwd)
else:
cmd_str = self.location + "/bin/" + " ".join(cmd)
(exitcode, stdout, stderr) = self.remotesys.execute(
["sh", "-c", cmd_str], cwd
)

if exitcode != "0":
raise SquishserverError(
f"[Squishserver {self.host}:{self.port}] "
Expand All @@ -108,11 +117,12 @@ def addAUT(self, aut: str, path: str) -> None:
aut (str): the name of the executable
path (str): path to the executable folder
"""
path_resolved = PureWindowsPath(path).as_posix().strip()
log(
f"[Squishserver {self.host}:{self.port}] "
f"Registering {Path(path)/aut} AUT"
f"Registering {path_resolved}/{aut} AUT"
)
self._config_squishserver("addAUT", [aut, path])
self._config_squishserver("addAUT", [aut, path_resolved])

def removeAUT(self, aut: str, path: str) -> None:
"""Remove registered AUT
Expand All @@ -133,20 +143,25 @@ def addAppPath(self, path: str) -> None:
Args:
path (str): the AUT path to register
"""
log(f"[Squishserver {self.host}:{self.port}] " f"Registering AUT path: {path}")
self._config_squishserver("addAppPath", [path])
path_resolved = PureWindowsPath(path).as_posix().strip()
log(
f"[Squishserver {self.host}:{self.port}] "
f"Registering AUT path: {path_resolved}"
)
self._config_squishserver("addAppPath", [path_resolved])

def removeAppPath(self, path: str) -> None:
"""Remove a registered AUT path

Args:
path (str): the path to the AUT
"""
path_resolved = PureWindowsPath(path).as_posix().strip()
log(
f"[Squishserver {self.host}:{self.port}] "
f"Removing registered AUT path: {path}"
f"Removing registered AUT path: {path_resolved}"
)
self._config_squishserver("removeAppPath", [path])
self._config_squishserver("removeAppPath", [path_resolved])

def addAttachableAut(self, aut: str, port: int, host: str = "127.0.0.1") -> None:
"""Register an attachable AUT
Expand Down