Skip to content

Commit

Permalink
fixed missing pyyaml dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
nimcon committed Aug 23, 2023
1 parent d201540 commit 52481d0
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 19 deletions.
1 change: 0 additions & 1 deletion chianode/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
from .rpcclient import RpcClient
from .mojoclient import MojoClient

19 changes: 10 additions & 9 deletions chianode/rpcclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
8 changes: 4 additions & 4 deletions example_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")

Expand All @@ -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__":
Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <info@circuitdao.com>"]
license = "MIT"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 52481d0

Please sign in to comment.