From 269de7c5f7ec9d2da74790a35bc218d3f6634565 Mon Sep 17 00:00:00 2001 From: Leon Lee Date: Fri, 29 Mar 2019 16:58:08 +0800 Subject: [PATCH] test python scripts test python scripts put and get file form ipfs --- py-ipfs-api.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 py-ipfs-api.py diff --git a/py-ipfs-api.py b/py-ipfs-api.py new file mode 100644 index 0000000..01eb563 --- /dev/null +++ b/py-ipfs-api.py @@ -0,0 +1,26 @@ +#!/bin/env python +# python2.7.16 + +import ipfsapi +import sys + + +def main(): + if len(sys.argv) < 3 : + print "args error\nUsage: ./py-ipfs-api.py ${ipaddress} add gettestfile.py" + sys.exit(1) + + if sys.argv[2] == "get" : + api = ipfsapi.connect(sys.argv[1], 5001) + for file in sys.argv[3:] : + res = api.get(file) + print res + + if sys.argv[2] == "add" : + api = ipfsapi.connect(sys.argv[1], 5001) + for file in sys.argv[3:] : + res = api.add(file) + print res + +if __name__ == "__main__": + main()