def downloadSelectedClimateData(self) :
# Override URL and proxy
self.setClimateDataLocation(download=True)
# Get download data parameters and intervals required
data_parameters_selected = []
for data_parameter in self.data_file_helper.getDataParameters() :
if self.climate_data_parameter_int.has_key(data_parameter) and self.climate_data_parameter_int[data_parameter].get() :
data_parameters_selected.append(data_parameter)
download_intervals_selected = []
for download_interval in self.data_file_helper.getClimateDataDownloadIntervals() :
if self.climate_download_interval_int.has_key(download_interval) and self.climate_download_interval_int[download_interval].get() :
download_intervals_selected.append(download_interval)
# Download and unpack NetCDF files
if self.data_file_helper.getClimateDataUrl() and self.data_file_helper.getClimateDataDirectoryPath() and data_parameters_selected and download_intervals_selected :
for data_parameter in data_parameters_selected :
for download_interval in download_intervals_selected :
overwrite_ok = True
if self.data_file_helper.climateDataDownloadIntervalPresent(data_parameter, download_interval) :
overwrite_ok = askyesno('Data already present: overwrite?',
'The data for '+data_parameter.replace('_',' ').title()+' interval '+download_interval+' is already present in the directory selected.\n\n'+
'Do you wish to download again and overwrite the existing file?', parent=self.download_climate_data_window)
if overwrite_ok :
self.climate_data_download_button.configure(state=tk.DISABLED)
self.climate_data_download_status_text.set('Downloading ' + data_parameter.replace('_',' ').title() + ' ' + download_interval + ' ...')
self.climate_data_download_status_bar['maximum'] = 1
self.climate_data_download_status_bar['value'] = 0
self.climate_data_download_status_bar.grid()
self.update() # .update_idletasks()
try :
self.data_file_helper.downloadClimateDataInterval(data_parameter, download_interval, delimiter='')
except Exception, e :
if hasattr(self, 'download_climate_data_window') and self.download_climate_data_window.children :
showerror('Data download error', str(e), parent=self.download_climate_data_window)
print >> sys.stderr, 'Data download error:', e
if self.download_climate_data_window.children :
self.climate_data_download_status_text.set('')
self.climate_data_download_status_bar.grid_remove()
self.climate_data_download_button.configure(state=tk.NORMAL)
self.update() # .update_idletasks()
else :
if not self.data_file_helper.getClimateDataUrl() :
showinfo('Download from URL not defined', 'Please enter the URL location of the climate data download(s).', parent=self.download_climate_data_window)
elif not self.data_file_helper.getClimateDataDirectoryPath() :
showinfo('Download to Directory not defined', 'Please select the directory destination for the climate data download(s).', parent=self.download_climate_data_window)
elif not (data_parameters_selected and download_intervals_selected) :
showinfo('Download Selection not fully defined', 'Please select the climate data parameters and intervals to download.', parent=self.download_climate_data_window)
## Step 1: Data Type Methods ################################################################################################################################################
# Step 1 Method: Select data type: the user selects an option
评论列表
文章目录