-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathfileinfo.py
More file actions
73 lines (56 loc) · 2.55 KB
/
fileinfo.py
File metadata and controls
73 lines (56 loc) · 2.55 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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 Noder:
def __manual(self):
print("*** File info")
print("### USAGE:")
print(" python fileinfo.py <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]
km = Container.KeyManager()
ns = Container.NodeService()
fs = Container.FilesService()
try:
if ns.joined(km.getCurrentNodeName()):
fileinfo = fs.fileinfo(file_shadowname)
print(" *** fileinfo *** ")
t = PrettyTable(['Param', 'value'])
t.add_row(["File ID", fileinfo['id']])
t.add_row(["Filename", fileinfo['filename']])
t.add_row(["Shadowname", fileinfo['shadowname']])
t.add_row(["Status", fileinfo['status']])
t.add_row(["Filesize (local)", fileinfo['size_local']])
t.add_row(["Filesize (remote)", fileinfo['size_remote']])
t.add_row(["Filepath (local)", fileinfo['filepath']])
t.add_row(["Cipher", fileinfo['cipher']])
t.add_row(["Encryption key", fileinfo['key']])
t.add_row(["Public link", fileinfo['pub']])
t.align = 'l'
print(t)
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 = Noder()
upd.process()