-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcd.py
More file actions
58 lines (45 loc) · 1.82 KB
/
cd.py
File metadata and controls
58 lines (45 loc) · 1.82 KB
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
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
import requests
from prettytable import PrettyTable
class DIR:
def __manual(self):
print("*** File info")
print("### USAGE:")
print(" python cd.py <Directory ID>")
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:
ID = int(sys.argv[1])
km = Container.KeyManager()
ns = Container.NodeService()
fs = Container.FilesService()
try:
if ns.joined(km.getCurrentNodeName()):
if km.getDirectory(ID) != False:
km.cd(ID)
else:
print("Directory ID {} not found".format(ID))
except MyNodesFileDoesNotExist as e:
print("MY NODES file not found.")
print("RUN python node.py set node-url")
except NodesFileDoesNotExist as e:
print("NODES LIST file not found.")
print("RUN python nodes-update.py 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")
else:
self.__manual()
upd = DIR()
upd.process()