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))
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
......@@ -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)
......@@ -22,7 +22,7 @@ class ResultsDownloadView(gtk.VBox):
results_tree_view_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.connect("selection-changed", event_file_set)
self.button_download = ButtonDownloadResults(label="Download Selected Items")
self.button_download.connect("clicked", event_clicked_download)
class ButtonDownloadResults(gtk.Button):
count = 0
_destination = ""
def destination(self):
return self._destination
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)
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