forked from Alex014/PrivatenessTools
-
Notifications
You must be signed in to change notification settings - Fork 1
/
remove.py
87 lines (70 loc) · 3.06 KB
/
remove.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import os
import sys
from framework.Container import Container
from NessKeys.exceptions.MyNodesFileDoesNotExist import MyNodesFileDoesNotExist
from NessKeys.exceptions.NodesFileDoesNotExist import NodesFileDoesNotExist
from NessKeys.exceptions.NodeNotFound import NodeNotFound
from NessKeys.exceptions.NodeError import NodeError
from NessKeys.exceptions.AuthError import AuthError
from NessKeys.exceptions.FileNotExist import FileNotExist
from NessKeys.exceptions.NodeNotSelected import NodeNotSelected
import requests
from prettytable import PrettyTable
class Noder:
def __manual(self):
print("*** Remove file")
print("### USAGE:")
print(" ./remove <file_shadowname>")
print("##### Remove local copy of file:")
print(" ./remove local <file_shadowname>")
def process(self):
if len(sys.argv) == 2 and (sys.argv[1].lower() == 'help' or sys.argv[1].lower() == '-h'):
self.__manual()
elif len(sys.argv) == 2:
file_shadowname = sys.argv[1]
fm = Container.FileManager()
fm.initKeys()
try:
fm.remove(file_shadowname)
except FileNotExist as e:
print("File {} not found".format(e.filename))
except MyNodesFileDoesNotExist as e:
print("MY NODES file not found.")
print("RUN ./node set node-url")
except NodesFileDoesNotExist as e:
print("NODES LIST file not found.")
print("RUN ./nodes-update node node-url")
except NodeNotFound as e:
print("NODE '{}' is not in nodes list".format(e.node))
except NodeError as e:
print("Error on remote node: " + e.error)
except AuthError as e:
print("Responce verification error")
except NodeNotSelected as e:
print("Current node is not set or not joined, try: ./node sel <node_url>")
elif len(sys.argv) == 3 and sys.argv[1].lower() == 'local':
file_shadowname = sys.argv[2]
fm = Container.FileManager()
fm.initKeys()
try:
fm.removeLocal(file_shadowname)
except FileNotExist as e:
print("File {} not found".format(e.filename))
except MyNodesFileDoesNotExist as e:
print("MY NODES file not found.")
print("RUN ./node set node-url")
except NodesFileDoesNotExist as e:
print("NODES LIST file not found.")
print("RUN ./nodes-update node node-url")
except NodeNotFound as e:
print("NODE '{}' is not in nodes list".format(e.node))
except NodeError as e:
print("Error on remote node: " + e.error)
except AuthError as e:
print("Responce verification error")
except NodeNotSelected as e:
print("Current node is not set or not joined, try: ./node sel <node_url>")
else:
self.__manual()
upd = Noder()
upd.process()