From 52481d0328ea7840c9319d1dbcf614d7b8053955 Mon Sep 17 00:00:00 2001 From: nimcon <32712736+nimcon@users.noreply.github.com> Date: Wed, 23 Aug 2023 13:16:00 +0100 Subject: [PATCH] fixed missing pyyaml dependency --- chianode/__init__.py | 1 - chianode/rpcclient.py | 19 ++++++++++--------- example_events.py | 8 ++++---- poetry.lock | 8 ++++---- pyproject.toml | 6 +++++- 5 files changed, 23 insertions(+), 19 deletions(-) diff --git a/chianode/__init__.py b/chianode/__init__.py index 1c5443c..b30610d 100644 --- a/chianode/__init__.py +++ b/chianode/__init__.py @@ -1,3 +1,2 @@ from .rpcclient import RpcClient from .mojoclient import MojoClient - diff --git a/chianode/rpcclient.py b/chianode/rpcclient.py index b854c24..1d0fb1f 100644 --- a/chianode/rpcclient.py +++ b/chianode/rpcclient.py @@ -40,26 +40,27 @@ def __init__(self, base_url=LOCALHOST, network=MAINNET, timeout=5): # 5 second t """ self.base_url = base_url - if os.getenv('CHIA_ROOT') is None: raise NameError("Environment variable CHIA_ROOT not set") - with open(os.getenv('CHIA_ROOT') + "/config/config.yaml", "r") as file: - config_file = yaml.safe_load(file) - selected_network = config_file["full_node"]["selected_network"] - if selected_network == network: - self.network = network - else: - raise ValueError(f"Please connect the node running on localhost to {network}") + if self.base_url == LOCALHOST: + if os.getenv('CHIA_ROOT') is None: raise NameError("Environment variable CHIA_ROOT not set") + with open(os.getenv('CHIA_ROOT') + "/config/config.yaml", "r") as file: + config_file = yaml.safe_load(file) + selected_network = config_file["full_node"]["selected_network"] + if selected_network == network: + self.network = network + else: + raise ValueError(f"Please connect the node running on localhost to {network}") self.headers = {"Content-Type": "application/json"} chia_root = "/".join(os.getenv('CHIA_ROOT').split("/")[:-1]) self.cert = (f"{chia_root}/{self.network}/config/ssl/full_node/private_full_node.crt", f"{chia_root}/{self.network}/config/ssl/full_node/private_full_node.key") elif self.base_url == MOJONODE: + self.network= network self.headers = {"accept": "application/json", "Content-Type": "application/json"} self.cert = None else: raise ValueError(f"Unknown node provider. Base URL: {base_url}") self.timeout = timeout - self.client = httpx.AsyncClient(base_url=self.base_url, http2=True, timeout=self.timeout, cert=self.cert, verify=False) diff --git a/example_events.py b/example_events.py index 47e24a7..aa0b87b 100644 --- a/example_events.py +++ b/example_events.py @@ -4,11 +4,11 @@ async def main(): - NUM_EVENTS_TO_READ = 0 # Number of events to read. Set to 0 to read events indefinitely + NUM_EVENTS_TO_READ = 10 # Number of events to read. Set to 0 to read events indefinitely - mojonodemojo = MojoClient() + mojonode = MojoClient() - stream = mojonodemojo.events() + stream = mojonode.events() stream_id = await anext(stream) print(f"CONNECTING TO STREAM ID {stream_id}") @@ -19,7 +19,7 @@ async def main(): # Close stream once the specified number of events has been read if c == NUM_EVENTS_TO_READ: - await mojonodemojo.close_stream(stream_id) + await mojonode.close_stream(stream_id) if __name__ == "__main__": diff --git a/poetry.lock b/poetry.lock index 6b1ef50..bf9ed9b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1771,13 +1771,13 @@ watchmedo = ["PyYAML (>=3.10)"] [[package]] name = "wheel" -version = "0.41.1" +version = "0.41.2" description = "A built-package format for Python" optional = false python-versions = ">=3.7" files = [ - {file = "wheel-0.41.1-py3-none-any.whl", hash = "sha256:473219bd4cbedc62cea0cb309089b593e47c15c4a2531015f94e4e3b9a0f6981"}, - {file = "wheel-0.41.1.tar.gz", hash = "sha256:12b911f083e876e10c595779709f8a88a59f45aacc646492a67fe9ef796c1b47"}, + {file = "wheel-0.41.2-py3-none-any.whl", hash = "sha256:75909db2664838d015e3d9139004ee16711748a52c8f336b52882266540215d8"}, + {file = "wheel-0.41.2.tar.gz", hash = "sha256:0c5ac5ff2afb79ac23ab82bab027a0be7b5dbcf2e54dc50efe4bf507de1f7985"}, ] [package.extras] @@ -1985,4 +1985,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.7" -content-hash = "52a0bd2aca74fff69bd934a705b122b2f9ba267269e4d307a89fe905aa55c2c1" +content-hash = "0463fed7742b64152d751ea16e0f173e4e6657d972d096498a4ced033215e2ce" diff --git a/pyproject.toml b/pyproject.toml index ab9bcaa..4530c80 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "python-chianode" -version = "0.1.0" +version = "0.1.1" description = "Python wrapper for Chia blockchain node APIs" authors = ["CircuitDAO "] license = "MIT" @@ -30,6 +30,10 @@ packaging = "23.1" pluggy = "1.2.0" pyproject_hooks = "1.0.0" sniffio = "1.3.0" +pyyaml = "^6.0.0" + +[tool.poetry.group.test] +optional = true [tool.poetry.group.test.dependencies] chia-blockchain = ">=1.8.0, <2.0.0"