diff --git a/.gitignore b/.gitignore index b767664..24de1e8 100644 --- a/.gitignore +++ b/.gitignore @@ -139,4 +139,6 @@ dmypy.json # Cython debug symbols cython_debug/ -.vscode \ No newline at end of file +.vscode + +examples/testfile_copy.txt \ No newline at end of file diff --git a/LICENSE b/LICENSE index 8c41a1e..87ca3f4 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ MIT License -Copyright (c) 2020 Peter Van Garderen, Antreas Pogiatzis, Wang Ge +Copyright (c) 2020 Antreas Pogiatzis, Wang Ge, Peter Van Garderen, Aaron Sutula Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/README.md b/README.md index 0865fae..3562289 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# pygate gRPC client +# Pygate gRPC client [![CodeFactor](https://www.codefactor.io/repository/github/pygate/pygate-grpc/badge)](https://www.codefactor.io/repository/github/pygate/pygate-grpc) [![PyPI version](https://badge.fury.io/py/pygate-grpc.svg)](https://badge.fury.io/py/pygate-grpc) @@ -6,13 +6,13 @@ [![Downloads](https://pepy.tech/badge/pygate-grpc)](https://pepy.tech/project/pygate-grpc) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) -A Python interface to [Textile](https://textile.io/)'s [Powergate](https://docs.textile.io/powergate/) [Filecoin](https://filecoin.io/) API +## Background -Pygate is a [HackFS](https://hackfs.com/) project. See the project [website](http://pygate.tech) for more details. +A Python interface to [Textile](https://textile.io/)'s [Powergate](https://docs.textile.io/powergate/) [Filecoin](https://filecoin.io/) API. See the project [website](http://pygate.tech) for more details. -## Getting Started +## Install -You can get started using `pygate_grpc` by installing it through the test PyPi repository. +You can get started using `pygate_grpc` by installing it through the PyPi repository. ``` pip install pygate_grpc @@ -27,36 +27,43 @@ Here is a basic usage example of the pygate_grpc: ```python from pygate_grpc.client import PowerGateClient -client = PowerGateClient("127.0.0.1:5002", False) +client = PowerGateClient("127.0.0.1:5002", is_secure=False) build_info = client.build_info() ``` Simple as that! -Note: this examples assumes you have a Powergate server running with an API available at `127.0.0.1:5002`. See Textile's Powergate [Localnet](https://docs.textile.io/powergate/localnet/). +Note: this examples assumes you have a Powergate server running with an API available at `127.0.0.1:5002`. See Textile's Powergate [Localnet](https://docs.textile.io/powergate/localnet/). The `is_secure=False` flag indicates that SSL is not enabled on this server. Examples of more elaborated usage can be found in the [examples](./examples/) folder. -## Development +# Contributing Please read contribution [guidelines](CONTRIBUTING.md) before starting development. To setup your development environment make sure you have the following software: +- [Git](https://git-scm.com/) - [Python](https://www.python.org/downloads/release/python-370/) - [pip](https://pip.pypa.io/en/stable/installing/) - [pipenv](https://pypi.org/project/pipenv/) ( or run `pip install pipenv`) +## Clone the repository +``` +git clone https://github.com/pygate/pygate-gRPC.git +``` + ## Install dependencies -Runtime and development dependencies can be installed in a new virtual environment automatically by running: +The runtime and development dependencies can be installed in a new virtual environment automatically by running the following command in the project root directory: -NOTE: The `--dev` flag can be ommited if you only need runtime dependencies ``` pipenv install --dev ``` +NOTE: The `--dev` flag can be ommited if you only need runtime dependencies + ### **Using the virtual environment** To run any command through pipenv's virtual environment you can spawn a new virtual environment shell by running: @@ -106,15 +113,8 @@ Finally, to push the new version to git and trigger a new release action it is n git push origin main --tags ``` -## Authors - -* **Antreas Pogiatzis** -* **Wang Ge** -* **Peter Van Garderen** - +## License -See also the list of [contributors](https://github.com/pygate/pygate-gRPC/graphs/contributors) who participated in this project. +[MIT © Antreas Pogiatzis, Wang Ge, Peter Van Garderen, Aaron Sutula](LICENSE) -## License -This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details diff --git a/examples/apply_pull_file.py b/examples/store_retrieve.py similarity index 75% rename from examples/apply_pull_file.py rename to examples/store_retrieve.py index feef098..68fc032 100644 --- a/examples/apply_pull_file.py +++ b/examples/store_retrieve.py @@ -16,15 +16,21 @@ print(user) # Stage file - print("Staging testfile.txt to IPFS storage") + print("Staging 'testfile.txt' to IPFS storage...") path = Path(os.path.abspath(__file__)) staged_file = c.data.stage_file(path.parent / "testfile.txt", user.token) - print("Applying storage config...") + print("IPFS CID: " + staged_file.cid) # Apply the default storage config to the given file - c.config.apply(staged_file.cid, override=False, token=user.token) + print("Applying Filecoin storage config to CID...") + job = c.config.apply(staged_file.cid, override=False, token=user.token) + + # Report back the Job ID for the successful Filecoin storage job + print("File successfully added to Filecoin storage.") + print("Job ID: " + job.jobId) # Override push with another config + print("Applying new config settings to file...") addresses = c.wallet.addresses(user.token) wallet = addresses[0].address new_config = { @@ -53,10 +59,10 @@ print(check) # Get the data back - print("Retrieving file " + staged_file.cid) + print("Retrieving file " + staged_file.cid + "...") file_bytes = c.data.get(staged_file.cid, user.token) # Write to a file on disk - print("Saving as 'testfile_copy.txt'") with open(path.parent / "testfile_copy.txt", "wb") as f: f.write(file_bytes) + print("Saved as 'testfile_copy.txt'") diff --git a/examples/testfile_copy.txt b/examples/testfile_copy.txt deleted file mode 100644 index 9944a9f..0000000 --- a/examples/testfile_copy.txt +++ /dev/null @@ -1 +0,0 @@ -This is a test file \ No newline at end of file