From f028b18310e46572239f5e04669dc5080da740dd Mon Sep 17 00:00:00 2001 From: foamyguy Date: Fri, 3 Jan 2025 14:56:07 -0600 Subject: [PATCH] remove prints, fix missing port argument. --- circup/backends.py | 7 ------- circup/commands.py | 2 +- circup/wwshell/commands.py | 14 +++++++++----- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/circup/backends.py b/circup/backends.py index 9de6ece..cba33fa 100644 --- a/circup/backends.py +++ b/circup/backends.py @@ -329,7 +329,6 @@ class WebBackend(Backend): file_name = source.split(os.path.sep) file_name = file_name[-2] if file_name[-1] == "" else file_name[-1] - print(f"inside install_file_http location: '{location}'") if location is None: target = self.device_location + "/" + self.LIB_DIR_PATH + file_name else: @@ -338,10 +337,7 @@ class WebBackend(Backend): auth = HTTPBasicAuth("", self.password) with open(source, "rb") as fp: - print(f"upload file PUT URL: {target}") r = self.session.put(target, fp.read(), auth=auth, timeout=self.timeout) - print(f"install_file_http response status: {r.status_code}") - print(r.content) if r.status_code == 409: _writeable_error() r.raise_for_status() @@ -584,7 +580,6 @@ class WebBackend(Backend): :param location_to_paste: Location on the microcontroller to paste it. :return: """ - print(f"inside upload_file location_to_paste: '{location_to_paste}'") if os.path.isdir(target_file): create_directory_url = urljoin( self.device_location, @@ -698,7 +693,6 @@ class WebBackend(Backend): return True if the file exists, otherwise False. """ auth = HTTPBasicAuth("", self.password) - print(f"URL: {self.get_file_path(filepath)}") resp = requests.get( self.get_file_path(filepath), auth=auth, timeout=self.timeout ) @@ -809,7 +803,6 @@ class WebBackend(Backend): headers={"Accept": "application/json"}, timeout=self.timeout, ) as r: - print(r.content) return r.json()["files"] diff --git a/circup/commands.py b/circup/commands.py index b85d16a..db17c15 100644 --- a/circup/commands.py +++ b/circup/commands.py @@ -94,7 +94,7 @@ def main( # pylint: disable=too-many-locals """ A tool to manage and update libraries on a CircuitPython device. """ - # pylint: disable=too-many-arguments,too-many-branches,too-many-statements,too-many-locals + # pylint: disable=too-many-arguments,too-many-branches,too-many-statements,too-many-locals, R0801 ctx.ensure_object(dict) ctx.obj["TIMEOUT"] = timeout diff --git a/circup/wwshell/commands.py b/circup/wwshell/commands.py index 6f6856b..090c9a6 100644 --- a/circup/wwshell/commands.py +++ b/circup/wwshell/commands.py @@ -44,6 +44,11 @@ from circup.command_utils import ( help="Hostname or IP address of a device. Overrides automatic path detection.", default="circuitpython.local", ) +@click.option( + "--port", + help="HTTP port that the web workflow is listening on.", + default=80, +) @click.option( "--password", help="Password to use for authentication when --host is used." @@ -65,24 +70,23 @@ def main( # pylint: disable=too-many-locals verbose, path, host, + port, password, timeout, ): # pragma: no cover """ A tool to manage files CircuitPython device over web workflow. """ - # pylint: disable=too-many-arguments,too-many-branches,too-many-statements,too-many-locals + # pylint: disable=too-many-arguments,too-many-branches,too-many-statements,too-many-locals, R0801 ctx.ensure_object(dict) ctx.obj["TIMEOUT"] = timeout if password is None: password = os.getenv("CIRCUP_WEBWORKFLOW_PASSWORD") - device_path = get_device_path(host, password, path) + device_path = get_device_path(host, port, password, path) using_webworkflow = "host" in ctx.params.keys() and ctx.params["host"] is not None - print(f"host: {ctx.params['host']}") - print(f"using webworkflow: {using_webworkflow}") if using_webworkflow: if host == "circuitpython.local": click.echo("Checking versions.json on circuitpython.local to find hostname") @@ -94,7 +98,7 @@ def main( # pylint: disable=too-many-locals device_path = device_path.replace("circuitpython.local", host) try: ctx.obj["backend"] = WebBackend( - host=host, password=password, logger=logger, timeout=timeout + host=host, port=port, password=password, logger=logger, timeout=timeout ) except ValueError as e: click.secho(e, fg="red")