From 80e1634c00426b1f6fc74bb8d9f0284c2c5c49fa Mon Sep 17 00:00:00 2001 From: Yangyang Li Date: Fri, 1 Sep 2023 15:29:01 -0500 Subject: [PATCH] refactor: Simplify code in client.py and server.py --- src/pxblat/server/client.py | 4 ++-- src/pxblat/server/server.py | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/pxblat/server/client.py b/src/pxblat/server/client.py index 54ac7a0a..efd2ed97 100644 --- a/src/pxblat/server/client.py +++ b/src/pxblat/server/client.py @@ -383,8 +383,8 @@ def __init__( self._basic_option.withGenome(genome) if genome_data_dir is not None: self._basic_option.withGenomeDataDir(genome_data_dir) - if seq_dir is not None: - self._basic_option.withSeqDir(str(seq_dir)) + + self._basic_option.withSeqDir(str(seq_dir)) self._wait_ready = wait_ready self._wait_timeout = wait_timeout diff --git a/src/pxblat/server/server.py b/src/pxblat/server/server.py index dd06d478..2f213d02 100644 --- a/src/pxblat/server/server.py +++ b/src/pxblat/server/server.py @@ -244,6 +244,9 @@ def stop(self): if self._process is not None: self._process.terminate() + self._is_open = False + self._is_ready = False + def status(self, *, instance=False) -> dict[str, str] | Status: """Retrieves the status of the gfServer instance. @@ -347,7 +350,9 @@ def create_option() -> ServerOption: def __str__(self) -> str: """Return server option as a string.""" - return f"Server({self.host}, {self.port}, ready: {self.is_ready()} open: {self.is_open()} {self.option})" + return f"Server({self.host}, {self.port}, ready: {self.is_ready()} open: {self.is_open()}\n {self.option})" + + __repr__ = __str__ def __enter__(self): """Starts the gfServer instance in blocking mode when used as a context manager."""