diff options
author | tmartins <thigm85@gmail.com> | 2020-09-01 12:37:59 +0200 |
---|---|---|
committer | tmartins <thigm85@gmail.com> | 2020-09-01 12:37:59 +0200 |
commit | aff555c1504adc2becf3a384ea1baac9804019ef (patch) | |
tree | 1ae34a2d6eea05c0f32ef6bf3a18a6161420ee14 /python | |
parent | d33cf55e6c8914c066052b45a2e082725723e47c (diff) |
create outfile_file argument with sys.output as default.
Diffstat (limited to 'python')
-rw-r--r-- | python/vespa/vespa/package.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/python/vespa/vespa/package.py b/python/vespa/vespa/package.py index e78a9e3ccd9..301a9df43bd 100644 --- a/python/vespa/vespa/package.py +++ b/python/vespa/vespa/package.py @@ -9,7 +9,7 @@ from datetime import datetime, timedelta from io import BytesIO from pathlib import Path from time import sleep, strftime, gmtime -from typing import List, Mapping, Optional +from typing import List, Mapping, Optional, IO import docker from cryptography import x509 @@ -387,16 +387,21 @@ class ApplicationPackage(ToJson, FromJson["ApplicationPackage"]): class VespaDocker(object): - def __init__(self, application_package: ApplicationPackage) -> None: + def __init__( + self, + application_package: ApplicationPackage, + output_file: IO = sys.stdout, + ) -> None: """ Deploy application to a Vespa container :param application_package: ApplicationPackage to be deployed. + :param output_file: Output file to write output messages. """ self.application_package = application_package self.container = None self.local_port = 8080 - self.output = sys.stdout + self.output = output_file def _run_vespa_engine_container(self, disk_folder: str, container_memory: str): """ @@ -500,6 +505,7 @@ class VespaCloud(object): application: str, key_location: str, application_package: ApplicationPackage, + output_file: IO = sys.stdout, ) -> None: """ Deploy application to the Vespa Cloud (cloud.vespa.ai) @@ -508,6 +514,7 @@ class VespaCloud(object): :param application: Application name registered in the Vespa Cloud. :param key_location: Location of the private key used for signing HTTP requests to the Vespa Cloud. :param application_package: ApplicationPackage to be deployed. + :param output_file: Output file to write output messages. """ self.tenant = tenant self.application = application @@ -524,7 +531,7 @@ class VespaCloud(object): self.connection = http.client.HTTPSConnection( "api.vespa-external.aws.oath.cloud", 4443 ) - self.output = sys.stdout + self.output = output_file @staticmethod def _read_private_key(key_location: str) -> ec.EllipticCurvePrivateKey: |