This repository has been archived by the owner on Apr 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilebrowser.py
61 lines (50 loc) · 2.29 KB
/
filebrowser.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
from helper import *
# import sessionmanager as SessionManager
from apiService import ApiService
import commands as Commands
# sendCmd = 'sendCommand'
# command_REQUEST_FILE_LIST = '/CartaObjects/DataLoader:getData'
# TODO add some method to save data in mongo, not member.
# This is for share screen
class FileManager():
def __init__(self):
self.remote_current_folder = None
# self.session_manager = session
# self.client = client
# def queryServerFileList(self, session, client):
# cmd = '/CartaObjects/ViewManager:registerView'
# const cmd = Commands.REGISTER_IMAGEVIEWER; // '/CartaObjects/ViewManager:registerView';
# // this.BASE_PATH = this.SEP + this.CARTA + this.SEP;
# // return `${this.BASE_PATH + this.VIEW_MANAGER + this.SEP_COMMAND}registerView`;
def print_file_list(self, rootDir, files):
print("\ncurrent folder:{}".format(rootDir))
for file in files:
if "type" in file:
print("{} type:{}".format(file["name"], file["type"]))
elif "dir" in file:
print("{} type:{}".format(file["name"], "folder"))
else:
print("{} type:".format(file["name"]))
#TODO change to self, error, result
def query_file_list_callback(self, result):
# if error:
# dprint(error)
# return
dprint("in query_file_list_callback")
dprint(result)
data = result["data"]
files = data["dir"]
rootDir= data["name"]
self.remote_current_folder = rootDir
self.print_file_list(rootDir, files)
dprint("response:REQUEST_FILE_LIST end")
def request_file_list(self, user_callback = None):
# TODO do not pass session or client directly to this class, later.
# use the way newMeteorCARTA uses, apiService
# self.queryServerFileList(self.session_manager.get(), self.client)
dprint("queryServerFileList")
params = 'path:'
data = ApiService.instance().send_command(Commands.REQUEST_FILE_LIST, params, self.query_file_list_callback, user_callback)
print('after send request file list, return data')
return data
# self.client.call(sendCmd, [Commands.REQUEST_FILE_LIST, params, session.get()], query_file_list_callback)