Skip to content

Commit

Permalink
Merge branch 'main' of github.com:pygate/pygate-gRPC into main
Browse files Browse the repository at this point in the history
  • Loading branch information
apogiatzis committed Dec 9, 2020
2 parents bae4cb7 + 33f4954 commit a07213c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 27 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,6 @@ dmypy.json
# Cython debug symbols
cython_debug/

.vscode
.vscode

examples/testfile_copy.txt
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -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
Expand Down
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# 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)
![Tests](https://github.com/pygate/pygate-gRPC/workflows/Tests/badge.svg)
[![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
Expand All @@ -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:
Expand Down Expand Up @@ -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
16 changes: 11 additions & 5 deletions examples/apply_pull_file.py → examples/store_retrieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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'")
1 change: 0 additions & 1 deletion examples/testfile_copy.txt

This file was deleted.

0 comments on commit a07213c

Please sign in to comment.