-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathunpin.py
40 lines (27 loc) · 893 Bytes
/
unpin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import sys
import os
from os import path
from common.PinataKeyClass import PinataKey
sys.stdout.reconfigure(encoding='utf-8')
# construct the Pinata key object
keylist=PinataKey('pinataApiKey.csv')
endpoint = keylist.fetchEndpoint('unpin')
headers={}
# Parsing Parameter
if(len(sys.argv) != 3):
print("usage: python unpin.py ipfshash free/paid")
raise SystemExit
ipfshash = sys.argv[1]
mode = sys.argv[2]
if (mode != 'free' and mode != 'paid'):
print("usage: either free or paid header")
raise SystemExit
headers=keylist.fetchKey(mode)
print('header got:')
print(headers)
print('Unpinning hash {} from {} endpoint'.format(ipfshash,mode))
import requests
#resp = requests.delete(endpoint, headers=headers,requestid=ipfshash)
print(endpoint+"/"+ipfshash)
resp = requests.delete(endpoint+"/"+ipfshash, headers=headers)
print("Return code: "+str(resp.status_code))