downloading files works now
This commit is contained in:
@@ -56,7 +56,6 @@ class PathHandle:
|
|||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def json_from_server(path):
|
|
||||||
def request_url(req_path):
|
def request_url(req_path):
|
||||||
# TODO, get from config
|
# TODO, get from config
|
||||||
BAM_SERVER = "http://localhost:5000"
|
BAM_SERVER = "http://localhost:5000"
|
||||||
@@ -64,12 +63,27 @@ class PathHandle:
|
|||||||
print(result)
|
print(result)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def json_from_server(path):
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
payload = {"path": "/".join(path)}
|
payload = {"path": "/".join(path)}
|
||||||
r = requests.get(request_url("files"), params=payload, auth=("bam", "bam"))
|
r = requests.get(PathHandle.request_url("files"), params=payload, auth=("bam", "bam"))
|
||||||
print(r.text)
|
print(r.text)
|
||||||
return r.json()
|
return r.json()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def download_from_server(path, idname):
|
||||||
|
import requests
|
||||||
|
payload = {"filepath": "/".join(path) + "/" + idname}
|
||||||
|
r = requests.get(PathHandle.request_url("file"), params=payload, auth=("bam", "bam"), stream=True)
|
||||||
|
local_filename = payload['filepath'].split('/')[-1]
|
||||||
|
with open(local_filename, 'wb') as f:
|
||||||
|
for chunk in r.iter_content(chunk_size=1024):
|
||||||
|
if chunk: # filter out keep-alive new chunks
|
||||||
|
f.write(chunk)
|
||||||
|
f.flush()
|
||||||
|
print(local_filename)
|
||||||
|
|
||||||
|
|
||||||
class Application(tk.Frame):
|
class Application(tk.Frame):
|
||||||
@@ -126,8 +140,10 @@ class Application(tk.Frame):
|
|||||||
|
|
||||||
self.repopulate()
|
self.repopulate()
|
||||||
|
|
||||||
|
|
||||||
def exec_path_file(idname):
|
def exec_path_file(idname):
|
||||||
|
self.path_handle.download_from_server(self.path_handle.path, idname)
|
||||||
|
print(self.path_handle.path)
|
||||||
|
|
||||||
self.repopulate()
|
self.repopulate()
|
||||||
|
|
||||||
|
|
||||||
@@ -142,8 +158,10 @@ class Application(tk.Frame):
|
|||||||
self.grid_members.append(but_path)
|
self.grid_members.append(but_path)
|
||||||
|
|
||||||
row = 1
|
row = 1
|
||||||
import random
|
|
||||||
random.shuffle(items)
|
# import random
|
||||||
|
# random.shuffle(items)
|
||||||
|
|
||||||
for name_short, name_full, item_type in [("..", "", "folder")] + items:
|
for name_short, name_full, item_type in [("..", "", "folder")] + items:
|
||||||
print(name_short, name_full, item_type)
|
print(name_short, name_full, item_type)
|
||||||
if item_type == "folder":
|
if item_type == "folder":
|
||||||
|
Reference in New Issue
Block a user