-
Notifications
You must be signed in to change notification settings - Fork 0
/
hive_external_actions.py
73 lines (60 loc) · 2.79 KB
/
hive_external_actions.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/python
import subprocess
import sys
import mysql.connector
import hashlib
import os
sys.path.append("..")
import openseed_setup as Settings
settings = Settings.get_settings()
def store_key(account,key):
process = subprocess.Popen(['hivepy', 'addkey'], stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
process.communicate(input=str(key+"\n").encode(),time=15)
process.communicate(input=str(settings["passphrase"]+"\n").encode(),time=15)
def import_account(account,masterpass):
#process = subprocess.Popen(['hivepy', 'importaccount', account], stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE,shell=True)
#stdout, stderr = process.communicate(input=str(masterpass+"\n").encode())
#print(stdout)
#stdout, stderr = process.communicate(input=str(settings["passphrase"]+"\n").encode())
#print(stdout)
process = subprocess.run(['UNLOCK=',settings["passphrase"], 'hivepy', 'importaccount', account], stdout=subprocess.PIPE, input=masterpass+"\n", encoding='ascii')
print(process.returncode)
print(process.stdout)
def flush_keys(account):
keys = find_keys_by_accountname(account)
for key in keys:
process = subprocess.Popen(['hivepy', 'delkey', key], stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
process.stdin.write(str("Y\n").encode("utf8"))
process.stdin.close()
process.wait()
stdout, stderr = process.communicate()
print(stdout)
def allow_app(account,app,allowed):
if allowed == "posting" or allowed == "active":
process = subprocess.Popen(['hivepy', 'allow', '--account', account,'--permission',allowed,app], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
process.wait()
stdout, stderr = process.communicate()
def disallow_app(account,app,remove):
if remove == "posting" or remove == "active":
process = subprocess.Popen(['hivepy', 'disallow','--account', account,'--permission',remove,app], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
process.wait()
stdout, stderr = process.communicate()
def verify_user(account,postingkey):
process = subprocess.Popen(['hivepy', 'pin', 'ls', '--type', 'recursive', thehash], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
process.wait()
stdout, stderr = process.communicate()
def openseed_interconnect(account,postkey):
process = subprocess.Popen(['hivepy', 'pin', 'ls', '--type', 'recursive', thehash], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
process.wait()
stdout, stderr = process.communicate()
def find_keys_by_accountname(account):
process = subprocess.Popen(['hivepy', 'listaccounts'], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
process.wait()
stdout, stderr = process.communicate()
keys = []
for line in stdout.decode().split("\n"):
if line.find("|") != -1:
if line.find(account) != -1:
print(line)
keys.append(line.split("|")[3].strip())
return keys