Commit b4c6e23d authored by Franziska Koehn's avatar Franziska Koehn
Browse files

chooseable download-destination added

parent 6cb79b91
......@@ -95,13 +95,13 @@ def download_all(results, host=None):
for r in results:
download(r, host)
def download_async(result, host=None, cb=(lambda *_: None), cb_args=()):
def download_async(result, dest_folder='', host=None, cb=(lambda *_: None), cb_args=()):
from threading import Thread
download_thread = Thread(target=download, args=(result, host, cb, cb_args))
download_thread = Thread(target=download, args=(result, dest_folder, host, cb, cb_args))
download_thread.start()
return download_thread
def download(result, host=None, cb=(lambda *_: None), cb_args=()):
def download(result, dest_folder='', host=None, cb=(lambda *_: None), cb_args=()):
if not host:
host = HOST
requests_lock.acquire()
......@@ -110,7 +110,7 @@ def download(result, host=None, cb=(lambda *_: None), cb_args=()):
experiment = result['xnat_mrsessiondata_session_id']
project = result['xnat_mrsessiondata_project']
scan = result['id']
file_name = "%s_%s_%s" % (subject, result['type'], scan)
file_name = "%s/%s_%s_%s" % (dest_folder, subject, result['type'], scan)
download_file(host, project, subject, experiment, scan, file_name)
requests_lock.release()
cb(*cb_args)
......
......@@ -22,7 +22,7 @@ class ResultsDownloadView(gtk.VBox):
results_tree_view_store = self.treeViewResults.store
def event_clicked_download(*_):
def event_clicked_download(button, *_):
import gobject
import xnat_search
enabled = (d for d in results_tree_view_store if d[0])
......@@ -32,12 +32,36 @@ class ResultsDownloadView(gtk.VBox):
_row[0] = False # Checkbox to false
d[8] = 0
d[7] = True # Show Spinner
xnat_search.download_async(d[6], cb=stop_spinner, cb_args=(d,))
xnat_search.download_async(d[6], button.destination, cb=stop_spinner, cb_args=(d,))
def event_file_set(filechooserbutton, *_):
self.button_download.destination = filechooserbutton.get_filename()
button_folder = gtk.FileChooserButton("Select Folder")
button_folder.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
button_folder.connect("selection-changed", event_file_set)
buttonBox_download.add(button_folder)
self.button_download = ButtonDownloadResults(label="Download Selected Items")
self.button_download.connect("clicked", event_clicked_download)
buttonBox_download.add(self.button_download)
class ButtonDownloadResults(gtk.Button):
count = 0
_destination = ""
@property
def destination(self):
return self._destination
@destination.setter
def destination(self, value):
self._destination = value
def __init__(self, *args, **kwargs):
super(ButtonDownloadResults, self).__init__(*args, **kwargs)
button_download = gtk.Button(label="Download Selected Items")
button_download.connect("clicked", event_clicked_download)
buttonBox_download.add(button_download)
class TreeViewResults(gtk.TreeView):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment