Skip to content
This repository was archived by the owner on May 24, 2022. It is now read-only.

Commit 22927a9

Browse files
committed
Merge branch 'release/0.0.3'
2 parents e9d5250 + 11c86d2 commit 22927a9

File tree

12 files changed

+320
-677
lines changed

12 files changed

+320
-677
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ node/test_data/go_example_image.tar
3939
coverage.out
4040

4141
__pycache__
42+
*.pyc

GNU-AGPL-3.0.txt

Lines changed: 0 additions & 661 deletions
This file was deleted.

LICENSE

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1-
c3-sdk-python is an sdk for developing c3 apps in python.
2-
Copyright (C) 2018 C3 Labs
1+
The MIT License (MIT)
32

4-
This program is free software: you can redistribute it and/or modify
5-
it under the terms of the GNU Affero General Public License as
6-
published by the Free Software Foundation, either version 3 of the
7-
License, or (at your option) any later version.
3+
Copyright (c) 2018 C3 Labs
84

9-
This program is distributed in the hope that it will be useful,
10-
but WITHOUT ANY WARRANTY; without even the implied warranty of
11-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-
GNU Affero General Public License for more details.
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
1311

14-
You should have received a copy of the GNU Affero General Public License
15-
along with this program. If not, see <http://www.gnu.org/licenses/>.
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,21 @@ deps: clean
1010
cp "${GOPATH}/src/github.com/c3systems/c3-go/lib/c/common/stringutil/stringutil.so" ./lib/ && \
1111
cp "${GOPATH}/src/github.com/c3systems/c3-go/lib/c/config/config.so" ./lib/
1212

13+
.PHONY: freeze
14+
freeze:
15+
@python -m pip freeze > requirements.txt
16+
17+
.PHONY: clean
1318
clean:
1419
@-find . -type f -name *.so -delete
20+
21+
.PHONY: test
22+
test: test/hexutil test/hashutil
23+
24+
.PHONY: test/hexutil
25+
test/hexutil:
26+
@python util/hexutil_test.py
27+
28+
.PHONY: test/hashutil
29+
test/hashutil:
30+
@python util/hashutil_test.py

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
55
[![License](http://img.shields.io/badge/license-GNU%20AGPL%203.0-blue.svg)](https://raw.githubusercontent.com/c3systems/c3-sdk-python/master/LICENSE) [![Build Status](https://travis-ci.org/c3systems/c3-sdk-python.svg?branch=master)](https://travis-ci.org/c3systems/c3-sdk-python) [![Coverage Status](https://coveralls.io/repos/github/c3systems/c3-sdk-python/badge.svg?branch=master)](https://coveralls.io/github/c3systems/c3-sdk-python?branch=master) [![Automated Release Notes by gren](https://img.shields.io/badge/%F0%9F%A4%96-release%20notes-00B2EE.svg)](https://github-tools.github.io/github-release-notes/) [![stability-experimental](https://img.shields.io/badge/stability-experimental-orange.svg)](https://github.com/emersion/stability-badges#experimental)
66

7+
## Dependencies
8+
1. Go
9+
2. Python 3
710

811
## Usage
912
1. [Install Go](https://golang.org/doc/install)
@@ -12,4 +15,4 @@
1215

1316
## License
1417

15-
[GNU AGPL 3.0](LICENSE)
18+
[MIT](LICENSE)

requirements.txt

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
acme==0.9.3
2+
altgraph==0.10.2
3+
appnope==0.1.0
4+
backports.shutil-get-terminal-size==1.0.0
5+
base58==1.0.0
6+
bdist-mpkg==0.5.0
7+
beautifulsoup4==4.5.1
8+
bitcoin==1.1.42
9+
bonjour-py==0.3
10+
boto3==1.4.1
11+
botocore==1.4.67
12+
certbot==0.9.3
13+
certifi==2016.9.26
14+
cffi==1.8.3
15+
click==6.6
16+
ConfigArgParse==0.11.0
17+
configobj==5.0.6
18+
configparser==3.5.0
19+
contextlib2==0.5.4
20+
cryptography==1.5.3
21+
decorator==4.1.2
22+
dnspython==1.15.0
23+
docutils==0.12
24+
dpkt==1.8.6
25+
enum34==1.1.6
26+
eth-testrpc==0.8.7
27+
ethereum==1.6.0
28+
ethereum-abi-utils==0.2.2
29+
ethereum-tester-client==1.2.5
30+
funcsigs==1.0.2
31+
futures==3.0.5
32+
gevent==1.1.2
33+
geventhttpclient==1.3.1
34+
greenlet==0.4.10
35+
idna==2.1
36+
image2ipfs==0.0.5
37+
ipaddress==1.0.17
38+
ipython==5.5.0
39+
ipython-genutils==0.2.0
40+
ISStreamer==0.2.2
41+
jmespath==0.9.0
42+
json-rpc==1.10.3
43+
knockpy==4.0
44+
letsencrypt==0.7.0
45+
letsencrypt-s3front==0.1.3
46+
macholib==1.5.1
47+
matplotlib==1.3.1
48+
mock==2.0.0
49+
modulegraph==0.10.4
50+
ndg-httpsclient==0.4.2
51+
numpy==1.8.0rc1
52+
parsedatetime==2.1
53+
pathlib2==2.3.0
54+
pbkdf2==1.3
55+
pbr==1.10.0
56+
pexpect==4.2.1
57+
pickleshare==0.7.4
58+
populus==1.4.1
59+
prompt-toolkit==1.0.15
60+
ptyprocess==0.5.2
61+
py==1.4.31
62+
py-geth==1.4.1
63+
py-solc==0.6.0
64+
py2app==0.7.3
65+
pyasn1==0.1.9
66+
pycparser==2.17
67+
pycryptodome==3.6.6
68+
pyethash==0.1.27
69+
pyfiglet==0.7.5
70+
Pygments==2.2.0
71+
pylru==1.0.9
72+
pyobjc-core==2.5.1
73+
pyobjc-framework-Accounts==2.5.1
74+
pyobjc-framework-AddressBook==2.5.1
75+
pyobjc-framework-AppleScriptKit==2.5.1
76+
pyobjc-framework-AppleScriptObjC==2.5.1
77+
pyobjc-framework-Automator==2.5.1
78+
pyobjc-framework-CFNetwork==2.5.1
79+
pyobjc-framework-Cocoa==2.5.1
80+
pyobjc-framework-Collaboration==2.5.1
81+
pyobjc-framework-CoreData==2.5.1
82+
pyobjc-framework-CoreLocation==2.5.1
83+
pyobjc-framework-CoreText==2.5.1
84+
pyobjc-framework-DictionaryServices==2.5.1
85+
pyobjc-framework-EventKit==2.5.1
86+
pyobjc-framework-ExceptionHandling==2.5.1
87+
pyobjc-framework-FSEvents==2.5.1
88+
pyobjc-framework-InputMethodKit==2.5.1
89+
pyobjc-framework-InstallerPlugins==2.5.1
90+
pyobjc-framework-InstantMessage==2.5.1
91+
pyobjc-framework-LatentSemanticMapping==2.5.1
92+
pyobjc-framework-LaunchServices==2.5.1
93+
pyobjc-framework-Message==2.5.1
94+
pyobjc-framework-OpenDirectory==2.5.1
95+
pyobjc-framework-PreferencePanes==2.5.1
96+
pyobjc-framework-PubSub==2.5.1
97+
pyobjc-framework-QTKit==2.5.1
98+
pyobjc-framework-Quartz==2.5.1
99+
pyobjc-framework-ScreenSaver==2.5.1
100+
pyobjc-framework-ScriptingBridge==2.5.1
101+
pyobjc-framework-SearchKit==2.5.1
102+
pyobjc-framework-ServiceManagement==2.5.1
103+
pyobjc-framework-Social==2.5.1
104+
pyobjc-framework-SyncServices==2.5.1
105+
pyobjc-framework-SystemConfiguration==2.5.1
106+
pyobjc-framework-WebKit==2.5.1
107+
pyOpenSSL==0.13.1
108+
pyparsing==2.0.1
109+
pypcap==1.1.1
110+
pyRFC3339==1.0
111+
pysha3==0.3
112+
pytest==3.0.4
113+
python-dateutil==2.5.3
114+
python-firebase==1.2
115+
python2-pythondialog==3.4.0
116+
pytz==2013.7
117+
pyusb==1.0.0
118+
PyYAML==3.12
119+
repoze.lru==0.6
120+
requests==2.6.0
121+
rethinkdb==2.0.0.post1
122+
rlp==0.4.7
123+
s3transfer==0.1.9
124+
scandir==1.6
125+
scapy==2.3.3
126+
scipy==0.13.0b1
127+
scrypt==0.8.0
128+
secp256k1==0.13.2
129+
selenium==3.3.1
130+
simplegeneric==0.8.1
131+
six==1.10.0
132+
termcolor==1.1.0
133+
toposort==1.5
134+
traitlets==4.3.2
135+
vboxapi==1.0
136+
wcwidth==0.1.7
137+
web3==3.2.0
138+
websocket-client==0.46.0
139+
Werkzeug==0.11.11
140+
xattr==0.6.4
141+
zope.component==4.3.0
142+
zope.event==4.2.0
143+
zope.interface==4.1.1

sdk.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ def newMethod(*args):
7878
def setInitialState(self):
7979
currState = ""
8080

81-
file = open(self.statefile, "r")
82-
currState = file.read()
81+
with open(self.statefile, "r") as file:
82+
currState = file.read()
8383

8484
if len(currState) == 0:
8585
print("no current state")

sdk_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sdk
44
import json
55

6-
hexutil = CDLL('./lib/hexutil/hexutil.so')
6+
hexutil = CDLL('./lib/hexutil.so')
77

88
c3 = sdk.NewC3(stateFilePath = './lib/state.json')
99

util/hashutil/__init__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import os
2+
from Crypto.Hash import SHA512
3+
import hexutil
4+
5+
def new ():
6+
h = SHA512.new(data=os.urandom(8), truncate='256')
7+
return h.digest()
8+
9+
def hash (data):
10+
h = SHA512.new(data=data.encode(), truncate='256')
11+
return h.digest()
12+
13+
def hashToHexString (data):
14+
return hexutil.encodeToString(hash(data))
15+
16+
def equals (hexHash, data):
17+
return hexHash == hashToHexString(data)

util/hashutil_test.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import unittest
2+
import hashutil
3+
4+
class Test(unittest.TestCase):
5+
def test_new(self):
6+
self.assertEqual(len(hashutil.new().hex()), 64)
7+
8+
def test_hash(self):
9+
self.assertEqual(hashutil.hash('hello world').hex(), '0ac561fac838104e3f2e4ad107b4bee3e938bf15f2b15f009ccccd61a913f017')
10+
11+
def test_hashToHexString(self):
12+
self.assertEqual(hashutil.hashToHexString('hello world'), '0x0ac561fac838104e3f2e4ad107b4bee3e938bf15f2b15f009ccccd61a913f017')
13+
14+
def test_equals(self):
15+
self.assertEqual(hashutil.equals('0x0ac561fac838104e3f2e4ad107b4bee3e938bf15f2b15f009ccccd61a913f017', 'hello world'), True)
16+
17+
if __name__ == '__main__':
18+
unittest.main()

0 commit comments

Comments
 (0)