Skip to content
This repository was archived by the owner on Jul 7, 2021. It is now read-only.

Commit fc5bcd0

Browse files
committed
Rename module to siaskynet
1 parent e5bfac3 commit fc5bcd0

File tree

6 files changed

+54
-5
lines changed

6 files changed

+54
-5
lines changed

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Compiled python modules.
2+
*.pyc
3+
4+
# Setuptools distribution folder.
5+
/dist/
6+
/build/
7+
8+
# Python egg metadata, regenerated from source files by setuptools.
9+
/*.egg-info

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
# Nebulous Namespace
1+
# Skynet SDK
2+
3+
An SDK for integrating Skynet into python applications

nebulous/__init__.py

Whitespace-only changes.

setup.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44
long_description = fh.read()
55

66
setuptools.setup(
7-
name="nebulous",
8-
version="0.0.1",
7+
name="siaskynet",
8+
version="0.0.2",
99
author="Peter-Jan Brone",
1010
author_email="[email protected]",
11-
description="Nebulous SDK",
11+
description="Skynet SDK",
1212
long_description=long_description,
1313
long_description_content_type="text/markdown",
14-
url="https://https://gitlab.com/pjbrone/python-nebulous",
1514
packages=setuptools.find_packages(),
15+
install_requires=[
16+
'requests',
17+
],
1618
classifiers=[
1719
"Programming Language :: Python :: 3",
1820
"License :: OSI Approved :: MIT License",

siaskynet/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .skynet import Skynet

siaskynet/skynet.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import requests
2+
3+
class Skynet:
4+
@staticmethod
5+
def default_upload_options():
6+
return type('obj', (object,), {
7+
'portalUrl': 'https://siasky.net',
8+
'portalUploadPath' : '/api/skyfile',
9+
'portalFileFieldname' : 'file',
10+
'customFilename':''
11+
})
12+
13+
@staticmethod
14+
def default_download_options():
15+
return type('obj', (object,), {
16+
'portalUrl': 'https://siasky.net',
17+
})
18+
19+
@staticmethod
20+
def UploadFile(path, opts=None):
21+
if opts is None:
22+
opts = Skynet.default_upload_options()
23+
24+
with open(path, 'rb') as f:
25+
r = requests.post("%s%s" % (opts.portalUrl, opts.portalUploadPath), files={opts.portalFileFieldname: f})
26+
response = r.json()
27+
return response["skylink"]
28+
29+
@staticmethod
30+
def DownloadFile(path, skylink, opts=None):
31+
if opts is None:
32+
opts = Skynet.default_download_options()
33+
34+
r = requests.get("%s/%s" % (opts.portalUrl, skylink),allow_redirects=True)
35+
open(path, 'wb').write(r.content)

0 commit comments

Comments
 (0)