1 |
|
---|
2 |
|
---|
3 |
|
---|
4 |
|
---|
5 |
|
---|
6 |
|
---|
7 |
|
---|
8 |
|
---|
9 |
|
---|
10 |
|
---|
11 |
|
---|
12 |
|
---|
13 |
|
---|
14 |
|
---|
15 |
|
---|
16 |
|
---|
17 |
|
---|
18 |
|
---|
19 |
|
---|
20 |
import Tkinter, Pmw, tkFileDialog, tkFont |
---|
21 |
import os, string |
---|
22 |
import pub_editorviewer |
---|
23 |
import pub_controls |
---|
24 |
import pub_busy |
---|
25 |
import thread |
---|
26 |
import extraction_controls |
---|
27 |
|
---|
28 |
from pub_controls import font_weight |
---|
29 |
from pub_editorviewer import show_field |
---|
30 |
from esgcet.config import splitRecord |
---|
31 |
from esgcet.publish import iterateOverDatasets |
---|
32 |
from esgcet.config import getHandlerFromDataset |
---|
33 |
from esgcet.messaging import debug, info, warning, error, critical, exception |
---|
34 |
|
---|
35 |
from pkg_resources import resource_filename |
---|
36 |
file2_gif = resource_filename('esgcet.ui', 'file2.gif') |
---|
37 |
folder2_gif = resource_filename('esgcet.ui', 'folder2.gif') |
---|
38 |
stop_gif = resource_filename('esgcet.ui', 'stop.gif') |
---|
39 |
|
---|
40 |
|
---|
41 |
|
---|
42 |
|
---|
43 |
def _scn_a_dir( self ): |
---|
44 |
d = [] |
---|
45 |
f = [] |
---|
46 |
search_pattern = None |
---|
47 |
self.file_search_pattern='All Files' |
---|
48 |
if (self.file_search_pattern is not None): |
---|
49 |
sct=string.count( self.file_search_pattern, "*" ) |
---|
50 |
l = string.find( self.file_search_pattern, "*" ) |
---|
51 |
r = string.rfind( self.file_search_pattern, "*" ) |
---|
52 |
if sct == 0: |
---|
53 |
search_pattern = self.file_search_pattern |
---|
54 |
sct = 2 |
---|
55 |
elif sct >= 2: |
---|
56 |
search_pattern = self.file_search_pattern[(l+1):r] |
---|
57 |
elif l == 0: |
---|
58 |
search_pattern = self.file_search_pattern[1:] |
---|
59 |
elif l > 0: |
---|
60 |
search_pattern = self.file_search_pattern[0:-1] |
---|
61 |
sct = 1 |
---|
62 |
else: |
---|
63 |
sct = -1 |
---|
64 |
for x in os.listdir( './' ): |
---|
65 |
if self.file_search_pattern is None: |
---|
66 |
if os.path.isfile( x ): |
---|
67 |
if x.lower()[-5:] in [ ".cdms", "*.cdml"]: |
---|
68 |
f.append( x ) |
---|
69 |
elif x.lower()[-4:] in [".cdf",".dic",".hdf", ".ctl", ".xml"] : |
---|
70 |
f.append( x ) |
---|
71 |
elif x.lower()[-3:] in [".nc","*.pp"] : |
---|
72 |
f.append( x ) |
---|
73 |
elif os.path.isdir(x): |
---|
74 |
d.append( x ) |
---|
75 |
elif( sct == -1 ): |
---|
76 |
if os.path.isfile( x ): |
---|
77 |
f.append( x ) |
---|
78 |
else: |
---|
79 |
d.append( x ) |
---|
80 |
elif sct == 0: |
---|
81 |
if os.path.isfile( x ): |
---|
82 |
if (string.find( x, search_pattern ) != 0) and (string.find( x, search_pattern ) != -1): |
---|
83 |
f.append( x ) |
---|
84 |
else: |
---|
85 |
d.append( x ) |
---|
86 |
elif sct == 1: |
---|
87 |
if os.path.isfile( x ): |
---|
88 |
if (string.find( x, search_pattern ) >= 0): |
---|
89 |
if self.file_search_pattern[0]=='*': |
---|
90 |
n=len(search_pattern) |
---|
91 |
if x[-n:]==search_pattern: |
---|
92 |
f.append( x ) |
---|
93 |
elif self.file_search_pattern[-1]=='*': |
---|
94 |
n=len(search_pattern) |
---|
95 |
if x[:n]==search_pattern: |
---|
96 |
f.append( x ) |
---|
97 |
else: |
---|
98 |
f.append(x) |
---|
99 |
else: |
---|
100 |
d.append( x ) |
---|
101 |
elif sct >= 2: |
---|
102 |
if os.path.isfile( x ): |
---|
103 |
if string.find( x, search_pattern ) != -1 or search_pattern=='All Files': |
---|
104 |
f.append( x ) |
---|
105 |
else: |
---|
106 |
d.append( x ) |
---|
107 |
d.sort() |
---|
108 |
dirp = os.getcwd() |
---|
109 |
i = 0 |
---|
110 |
while dirp != "" and dirp != "/": |
---|
111 |
d.insert(i, dirp) |
---|
112 |
s=string.split( dirp, '/' )[-1] |
---|
113 |
dirp = dirp[0:(len(dirp)-len(s)-1)] |
---|
114 |
i += 1 |
---|
115 |
d.insert(i, "/") |
---|
116 |
d.insert(i+1, "============================================================================") |
---|
117 |
f.sort() |
---|
118 |
return d,f |
---|
119 |
|
---|
120 |
|
---|
121 |
class dataset_widgets: |
---|
122 |
""" |
---|
123 |
Generate the datasets control widgets seen on the left when "Specify Datasets" is selected. |
---|
124 |
""" |
---|
125 |
def __init__(self, parent): |
---|
126 |
self.parent = parent |
---|
127 |
self.Session = parent.parent.Session |
---|
128 |
|
---|
129 |
|
---|
130 |
|
---|
131 |
|
---|
132 |
projectOption = self.parent.parent.config.get('initialize', 'project_options') |
---|
133 |
projectSpecs = splitRecord(projectOption) |
---|
134 |
projectName = projectSpecs[0][0] |
---|
135 |
projectList = [] |
---|
136 |
for x in projectSpecs: |
---|
137 |
projectList.append( x[0] ) |
---|
138 |
projectList.sort() |
---|
139 |
self.project_dataset=show_field( self.parent, self.parent.control_frame1, "Project", projectList , projectName, 1, 1 ) |
---|
140 |
|
---|
141 |
|
---|
142 |
|
---|
143 |
|
---|
144 |
self.parent.parent.offline = False |
---|
145 |
self.parent.parent.offline_directories = None |
---|
146 |
self.parent.parent.offline_datasetName = None |
---|
147 |
bnFont=tkFont.Font(self.parent.parent, family = pub_controls.label_button_font_type, size=pub_controls.label_button_font_size, weight=font_weight) |
---|
148 |
self.on_off = Pmw.RadioSelect(self.parent.control_frame1, |
---|
149 |
buttontype = 'radiobutton', |
---|
150 |
orient = 'horizontal', |
---|
151 |
labelpos = 'w', |
---|
152 |
command = pub_controls.Command( self.evt_work_on_or_off_line, ), |
---|
153 |
label_text = 'Work: ', |
---|
154 |
label_font = bnFont, |
---|
155 |
hull_borderwidth = 2, |
---|
156 |
hull_relief = 'ridge', |
---|
157 |
) |
---|
158 |
self.on_off.pack(side = 'top', expand = 1, padx = 10, pady = 10) |
---|
159 |
|
---|
160 |
|
---|
161 |
for text in ('On-line', 'Off-line'): |
---|
162 |
self.on_off.add(text, font = bnFont) |
---|
163 |
self.on_off.setvalue('On-line') |
---|
164 |
|
---|
165 |
|
---|
166 |
|
---|
167 |
|
---|
168 |
tagFont=tkFont.Font(self.parent.parent, family = pub_controls.button_group_font_type, size=pub_controls.button_group_font_size, weight=font_weight) |
---|
169 |
self.group_file_filter = Pmw.Group(self.parent.control_frame1, |
---|
170 |
tag_text = 'Filter File Search', |
---|
171 |
tag_font = tagFont, |
---|
172 |
|
---|
173 |
tagindent = 25) |
---|
174 |
|
---|
175 |
dfFont=tkFont.Font(self.parent.parent, family = pub_controls.combobox_font_type, size=pub_controls.combobox_font_size, weight=font_weight) |
---|
176 |
self.data_filter = Pmw.ComboBox( self.group_file_filter.interior(), |
---|
177 |
entryfield_value = pub_controls.datatypes[0], |
---|
178 |
entry_font = dfFont, |
---|
179 |
entry_state = 'readonly', |
---|
180 |
entry_readonlybackground="aliceblue", |
---|
181 |
listbox_font = dfFont, |
---|
182 |
listbox_background = "aliceblue", |
---|
183 |
scrolledlist_items = pub_controls.datatypes, |
---|
184 |
) |
---|
185 |
|
---|
186 |
self.data_filter.pack(side = 'top', fill='x', pady = 5) |
---|
187 |
self.group_file_filter.pack(side='top', fill='x', pady=3) |
---|
188 |
|
---|
189 |
|
---|
190 |
|
---|
191 |
|
---|
192 |
|
---|
193 |
|
---|
194 |
|
---|
195 |
glFont=tkFont.Font(self.parent.parent, family = pub_controls.button_group_font_type, size=pub_controls.button_group_font_size, weight=font_weight) |
---|
196 |
self.group_list_generation = Pmw.Group(self.parent.control_frame1, |
---|
197 |
tag_text = 'Generate List', |
---|
198 |
tag_font = glFont, |
---|
199 |
tagindent = 25) |
---|
200 |
self.parent.control_frame2 = self.group_list_generation.interior() |
---|
201 |
|
---|
202 |
self.directory_icon = Tkinter.PhotoImage(file=file2_gif) |
---|
203 |
self.file_icon = Tkinter.PhotoImage(file=folder2_gif) |
---|
204 |
self.stop_icon = Tkinter.PhotoImage(file=stop_gif) |
---|
205 |
|
---|
206 |
|
---|
207 |
bnFont=tkFont.Font(self.parent.parent, family = pub_controls.label_button_font_type, size=pub_controls.label_button_font_size, weight=font_weight) |
---|
208 |
self.generating_file_list_flg = 0 |
---|
209 |
self.lw_dir = Pmw.LabeledWidget(self.parent.control_frame2, |
---|
210 |
labelpos = 'w', |
---|
211 |
label_font = bnFont, |
---|
212 |
label_text = 'Generate list from: ') |
---|
213 |
self.lw_dir.component('hull').configure(relief='sunken', borderwidth=2) |
---|
214 |
self.lw_dir.pack(side='top', expand = 1, fill = 'both', padx=10, pady=10) |
---|
215 |
self.cw_dir = Tkinter.Button(self.lw_dir.interior(), |
---|
216 |
text='Directory', |
---|
217 |
font = bnFont, |
---|
218 |
background = "aliceblue", |
---|
219 |
foreground='black', |
---|
220 |
command = pub_controls.Command(self.evt_popup_directory_window) ) |
---|
221 |
self.cw_dir.pack(padx=10, pady=10, expand='yes', fill='both') |
---|
222 |
self.save_dir_btn_color = self.cw_dir.cget( "background" ) |
---|
223 |
|
---|
224 |
|
---|
225 |
self.lw_file = Pmw.LabeledWidget(self.parent.control_frame2, |
---|
226 |
labelpos = 'w', |
---|
227 |
label_font = bnFont, |
---|
228 |
label_text = 'Generate list from: ') |
---|
229 |
self.lw_file.component('hull').configure(relief='sunken', borderwidth=2) |
---|
230 |
self.lw_file.pack(side='top', expand = 1, fill = 'both', padx=10, pady=10) |
---|
231 |
self.cw_file = Tkinter.Button(self.lw_file.interior(), |
---|
232 |
text='File', |
---|
233 |
font = bnFont, |
---|
234 |
background = "aliceblue", |
---|
235 |
foreground='black', |
---|
236 |
command = pub_controls.Command(self.evt_popup_file_window) ) |
---|
237 |
self.cw_file.pack(padx=10, pady=10, expand='yes', fill='both') |
---|
238 |
self.save_file_btn_color = self.cw_file.cget( "background" ) |
---|
239 |
|
---|
240 |
|
---|
241 |
d,f = _scn_a_dir( self.parent ) |
---|
242 |
self.directory_combo = Pmw.ComboBox( self.parent.control_frame2, |
---|
243 |
scrolledlist_items = d, |
---|
244 |
entryfield_value = os.getcwd(), |
---|
245 |
entry_font = ('Times', 16, 'bold'), |
---|
246 |
entry_background='white', entry_foreground='black', |
---|
247 |
selectioncommand=pub_controls.Command(self.evt_enter_directory) |
---|
248 |
) |
---|
249 |
self.directory_combo.component('entry').bind( "<Key>", pub_controls.Command(self.evt_change_color) ) |
---|
250 |
self.directory_combo.component('entry').bind( "<Return>", pub_controls.Command(self.evt_enter_directory) ) |
---|
251 |
self.directory_combo.component('entry').bind('<Tab>', pub_controls.Command(self.evt_tab) ) |
---|
252 |
self.directory_combo.component('entry').bind( "<BackSpace>", pub_controls.Command(self.evt_backspace) ) |
---|
253 |
|
---|
254 |
self.parent.control_frame2.pack(side="top", fill = 'x', pady=5) |
---|
255 |
self.group_list_generation.pack(side='top', fill='x', pady=3) |
---|
256 |
|
---|
257 |
|
---|
258 |
|
---|
259 |
|
---|
260 |
|
---|
261 |
|
---|
262 |
|
---|
263 |
|
---|
264 |
|
---|
265 |
self.group_list = Pmw.Group(self.parent.control_frame1, |
---|
266 |
tag_text = 'Regular Expressions', |
---|
267 |
tag_font = ('Times', 18, 'bold'), |
---|
268 |
hull_background = 'orange', |
---|
269 |
tagindent = 25) |
---|
270 |
|
---|
271 |
|
---|
272 |
|
---|
273 |
|
---|
274 |
|
---|
275 |
self.scl1 = Pmw.ScrolledText( self.group_list.interior(), |
---|
276 |
text_background='aliceblue', |
---|
277 |
text_foreground='black', |
---|
278 |
text_wrap = 'none', |
---|
279 |
text_padx = 5, |
---|
280 |
text_pady = 5, |
---|
281 |
usehullsize = 1, |
---|
282 |
hull_width = 100, |
---|
283 |
hull_height = 50) |
---|
284 |
|
---|
285 |
|
---|
286 |
self.scl1.pack(side='top', expand=1, fill='both') |
---|
287 |
|
---|
288 |
|
---|
289 |
self.generating_file_list_flg = 0 |
---|
290 |
self.lw_reg = Pmw.LabeledWidget(self.group_list.interior(), |
---|
291 |
labelpos = 'w', |
---|
292 |
label_text = 'Regular expression: ') |
---|
293 |
self.lw_reg.component('hull').configure(relief='sunken', borderwidth=2) |
---|
294 |
self.lw_reg.pack(side='top', expand = 1, fill = 'both', padx=10, pady=10) |
---|
295 |
self.cw_reg = Tkinter.Button(self.lw_reg.interior(), |
---|
296 |
text='Go', |
---|
297 |
command = pub_controls.Command(self.evt_compile_regular_expression) |
---|
298 |
) |
---|
299 |
self.cw_reg.pack(padx=10, pady=10, expand='yes', fill='both') |
---|
300 |
self.save_reg_btn_color = self.cw_reg.cget( "background" ) |
---|
301 |
|
---|
302 |
|
---|
303 |
|
---|
304 |
|
---|
305 |
|
---|
306 |
|
---|
307 |
|
---|
308 |
|
---|
309 |
|
---|
310 |
def evt_compile_regular_expression( self ): |
---|
311 |
from esgcet.publish.utility import fnmatchIterator |
---|
312 |
from tkMessageBox import showerror |
---|
313 |
|
---|
314 |
|
---|
315 |
self.cw_dir.configure( background=self.save_dir_btn_color, foreground='black' ) |
---|
316 |
self.cw_file.configure( background=self.save_file_btn_color, foreground='black' ) |
---|
317 |
self.cw_reg.configure( background=self.save_reg_btn_color, foreground='black' ) |
---|
318 |
|
---|
319 |
regexp = self.scl1.get().strip() |
---|
320 |
|
---|
321 |
|
---|
322 |
self.cw_reg.configure( background='green' ) |
---|
323 |
|
---|
324 |
self.parent.parent.firstFile = fnmatchIterator(regexp).next()[0] |
---|
325 |
self.parent.parent.datasetMapfile = None |
---|
326 |
self.parent.parent.regexp = regexp |
---|
327 |
|
---|
328 |
extraction_controls.load_configuration(self.parent.parent) |
---|
329 |
|
---|
330 |
|
---|
331 |
|
---|
332 |
|
---|
333 |
|
---|
334 |
|
---|
335 |
def myfun3( self, dirp, lock ): |
---|
336 |
import fnmatch, time |
---|
337 |
|
---|
338 |
index_count = 0 |
---|
339 |
lock.acquire() |
---|
340 |
self.parent.parent.file_list = [] |
---|
341 |
self.parent.parent.file_size = [] |
---|
342 |
|
---|
343 |
for root, dirs, files in os.walk(dirp): |
---|
344 |
for filename in files: |
---|
345 |
if fnmatch.fnmatch(filename, self.extension[0]): |
---|
346 |
sfilename = os.path.join(root, filename) |
---|
347 |
filesize = os.path.getsize(sfilename) |
---|
348 |
self.parent.parent.file_list.append( sfilename ) |
---|
349 |
self.parent.parent.file_size.append( filesize ) |
---|
350 |
self.parent.parent.file_line.append(pub_editorviewer.create_publisher_editor_viewer_row(self.parent.parent, index = index_count, size = filesize, status_flg = 1, filename = sfilename)) |
---|
351 |
index_count+=1 |
---|
352 |
|
---|
353 |
time.sleep(0.1) |
---|
354 |
|
---|
355 |
if self.stop_listing_flg == 1 and index_count > 0: |
---|
356 |
pub_busy.busyEnd( self, self.parent.parent ) |
---|
357 |
self.parent.parent.pub_editorviewer.sf.configure(hscrollmode = 'dynamic') |
---|
358 |
self.parent.parent.pub_editorviewer.sf.configure(vscrollmode = 'dynamic') |
---|
359 |
self.parent.parent.file_counter = index_count |
---|
360 |
time.sleep(0.1) |
---|
361 |
self.parent.parent.log_output_window.appendtext("File list creation stopped. %s files in list.\n" % index_count) |
---|
362 |
self.generating_file_list_flg = 0 |
---|
363 |
thread.exit() |
---|
364 |
lock.release() |
---|
365 |
|
---|
366 |
self.parent.parent.file_counter = index_count |
---|
367 |
|
---|
368 |
pub_busy.busyEnd( self, self.parent.parent ) |
---|
369 |
|
---|
370 |
if index_count > 0: |
---|
371 |
self.parent.parent.pub_editorviewer.sf.configure(hscrollmode = 'dynamic') |
---|
372 |
self.parent.parent.pub_editorviewer.sf.configure(vscrollmode = 'dynamic') |
---|
373 |
|
---|
374 |
self.parent.parent.log_output_window.appendtext("Finished creating the file list. %s files in list.\n" % index_count) |
---|
375 |
self.generating_file_list_flg = 0 |
---|
376 |
|
---|
377 |
|
---|
378 |
|
---|
379 |
|
---|
380 |
def open_text_file( self, dirfilename, lock ): |
---|
381 |
import time |
---|
382 |
import gc |
---|
383 |
|
---|
384 |
index_count = 0 |
---|
385 |
lock.acquire() |
---|
386 |
|
---|
387 |
f = open(dirfilename,'r') |
---|
388 |
self.parent.parent.file_list = [] |
---|
389 |
self.parent.parent.file_size = [] |
---|
390 |
for dirfile in f: |
---|
391 |
sfilename = dirfile[:-1] |
---|
392 |
filesize = os.path.getsize(sfilename) |
---|
393 |
self.parent.parent.file_list.append( sfilename ) |
---|
394 |
self.parent.parent.file_size.append( filesize ) |
---|
395 |
self.parent.parent.file_line.append(pub_editorviewer.create_publisher_editor_viewer_row(self.parent.parent, index = index_count, size = filesize, status_flg = 0, filename = sfilename)) |
---|
396 |
index_count+=1 |
---|
397 |
|
---|
398 |
time.sleep(0.1) |
---|
399 |
|
---|
400 |
if self.stop_listing_flg == 1: |
---|
401 |
pub_busy.busyEnd( self, self.parent.parent ) |
---|
402 |
self.parent.parent.pub_editorviewer.sf.configure(hscrollmode = 'dynamic') |
---|
403 |
self.parent.parent.pub_editorviewer.sf.configure(vscrollmode = 'dynamic') |
---|
404 |
self.parent.parent.file_counter = index_count |
---|
405 |
time.sleep(0.1) |
---|
406 |
self.parent.parent.log_output_window.appendtext("File list creation stopped. %s files in list.\n" % index_count) |
---|
407 |
self.generating_file_list_flg = 0 |
---|
408 |
thread.exit() |
---|
409 |
|
---|
410 |
f.close() |
---|
411 |
|
---|
412 |
lock.release() |
---|
413 |
|
---|
414 |
self.parent.parent.file_counter = index_count |
---|
415 |
|
---|
416 |
pub_busy.busyEnd( self, self.parent.parent ) |
---|
417 |
self.parent.parent.pub_editorviewer.sf.configure(hscrollmode = 'dynamic') |
---|
418 |
self.parent.parent.pub_editorviewer.sf.configure(vscrollmode = 'dynamic') |
---|
419 |
|
---|
420 |
self.parent.parent.log_output_window.appendtext("Finished creating the file list. %s files in list.\n" % index_count) |
---|
421 |
self.generating_file_list_flg = 0 |
---|
422 |
|
---|
423 |
def fill_in_data_information_file( self, dirfilename, onoff_line = "online" ): |
---|
424 |
from esgcet.publish import readDatasetMap |
---|
425 |
|
---|
426 |
dmap = readDatasetMap( dirfilename ) |
---|
427 |
datasetNames = dmap.keys() |
---|
428 |
datasetNames.sort() |
---|
429 |
self.parent.parent.dmap = dmap |
---|
430 |
self.parent.parent.datasetNames = datasetNames |
---|
431 |
self.parent.parent.datasetMapfile = dirfilename |
---|
432 |
|
---|
433 |
if onoff_line == "online": |
---|
434 |
tab_name= "Collection %i" % self.parent.parent.top_ct |
---|
435 |
page_type = "collection" |
---|
436 |
tcolor='lightgreen' |
---|
437 |
onoff_flag = False |
---|
438 |
else: |
---|
439 |
tab_name= "Offline %i" % self.parent.parent.top_ct |
---|
440 |
page_type = "offline" |
---|
441 |
tcolor='orange' |
---|
442 |
onoff_flag = True |
---|
443 |
self.parent.parent.ntk.new_page( self.parent.parent, tab_name, tab_color = tcolor, page_type = page_type ) |
---|
444 |
|
---|
445 |
|
---|
446 |
selected_page = self.parent.parent.main_frame.selected_top_page |
---|
447 |
self.parent.parent.main_frame.dmap[selected_page] = dmap |
---|
448 |
self.parent.parent.main_frame.datasetMapfile[selected_page] = dirfilename |
---|
449 |
self.parent.parent.main_frame.dirp_firstfile[selected_page] = None |
---|
450 |
self.parent.parent.offline_file_directory[selected_page] = "file" |
---|
451 |
self.parent.parent.directoryMap[selected_page] = None |
---|
452 |
self.parent.parent.hold_offline[selected_page] = onoff_flag |
---|
453 |
self.parent.parent.main_frame.projectName[selected_page] = self.project_dataset.get() |
---|
454 |
|
---|
455 |
def fill_in_data_information_directory( self, dirp, onoff_line = "online" ): |
---|
456 |
from esgcet.publish import multiDirectoryIterator |
---|
457 |
from esgcet.config import getHandler, getHandlerByName |
---|
458 |
|
---|
459 |
if onoff_line == "online": |
---|
460 |
self.parent.parent.filefilt = ".*\\" + self.parent.parent.extension[0][1:] + "$" |
---|
461 |
|
---|
462 |
lastargs = [dirp] |
---|
463 |
multiIter = multiDirectoryIterator(lastargs, filefilt=self.parent.parent.filefilt) |
---|
464 |
firstFile, size = multiIter.next() |
---|
465 |
handler = getHandler(firstFile, self.Session, validate=True) |
---|
466 |
if handler is None: |
---|
467 |
raise ESGPublishError("No project found in file %s, specify with --project."%firstFile) |
---|
468 |
projectName = handler.name |
---|
469 |
|
---|
470 |
self.parent.parent.multiIter = multiIter |
---|
471 |
self.parent.parent.firstFile = firstFile |
---|
472 |
|
---|
473 |
properties = {} |
---|
474 |
initcontext = {} |
---|
475 |
props = properties.copy() |
---|
476 |
props.update(initcontext) |
---|
477 |
holdDirectoryMap = handler.generateDirectoryMap(lastargs, self.parent.parent.filefilt, initContext=props) |
---|
478 |
self.parent.parent.datasetNames = holdDirectoryMap.keys() |
---|
479 |
self.parent.parent.datasetNames.sort() |
---|
480 |
tab_name= "Collection %i" % self.parent.parent.top_ct |
---|
481 |
page_type = "collection" |
---|
482 |
tcolor='lightgreen' |
---|
483 |
onoff_flag = False |
---|
484 |
else: |
---|
485 |
holdDirectoryMap = None |
---|
486 |
firstFile = None |
---|
487 |
page_type = "offline" |
---|
488 |
tab_name= "Offline %i" % self.parent.parent.top_ct |
---|
489 |
self.parent.parent.datasetNames = [self.parent.parent.offline_datasetName] |
---|
490 |
tcolor='orange' |
---|
491 |
onoff_flag = True |
---|
492 |
|
---|
493 |
self.parent.parent.ntk.new_page( self.parent.parent, tab_name, tab_color = tcolor,page_type = page_type ) |
---|
494 |
|
---|
495 |
|
---|
496 |
selected_page = self.parent.parent.main_frame.selected_top_page |
---|
497 |
self.parent.parent.main_frame.dmap[selected_page] = None |
---|
498 |
self.parent.parent.main_frame.datasetMapfile[selected_page] = None |
---|
499 |
self.parent.parent.main_frame.dirp_firstfile[selected_page] = firstFile |
---|
500 |
self.parent.parent.offline_file_directory[selected_page] = "directory" |
---|
501 |
self.parent.parent.directoryMap[selected_page] = holdDirectoryMap |
---|
502 |
self.parent.parent.hold_offline[selected_page] = onoff_flag |
---|
503 |
self.parent.parent.main_frame.projectName[selected_page] = self.project_dataset.get() |
---|
504 |
|
---|
505 |
|
---|
506 |
|
---|
507 |
|
---|
508 |
def evt_reset_project(self, parent, event): |
---|
509 |
extraction_controls.load_configuration( self.parent.parent ) |
---|
510 |
|
---|
511 |
|
---|
512 |
|
---|
513 |
|
---|
514 |
def evt_work_on_or_off_line( self, tag ): |
---|
515 |
|
---|
516 |
self.cw_dir.configure( background=self.save_dir_btn_color, foreground='black' ) |
---|
517 |
self.cw_file.configure( background=self.save_file_btn_color, foreground='black' ) |
---|
518 |
self.cw_reg.configure( background=self.save_reg_btn_color, foreground='black' ) |
---|
519 |
|
---|
520 |
if tag == "Off-line": |
---|
521 |
self.parent.parent.offline = True |
---|
522 |
|
---|
523 |
|
---|
524 |
|
---|
525 |
|
---|
526 |
|
---|
527 |
|
---|
528 |
|
---|
529 |
|
---|
530 |
|
---|
531 |
|
---|
532 |
|
---|
533 |
|
---|
534 |
|
---|
535 |
|
---|
536 |
|
---|
537 |
|
---|
538 |
|
---|
539 |
if tag == "On-line": |
---|
540 |
self.parent.parent.offline = False |
---|
541 |
|
---|
542 |
self.lw_dir.pack(side='top', before=self.lw_file, expand = 1, fill = 'both', padx=10, pady=10) |
---|
543 |
|
---|
544 |
|
---|
545 |
|
---|
546 |
|
---|
547 |
|
---|
548 |
self.parent.parent.projectName = None |
---|
549 |
|
---|
550 |
|
---|
551 |
|
---|
552 |
|
---|
553 |
|
---|
554 |
|
---|
555 |
|
---|
556 |
def evt_popup_directory_window( self ): |
---|
557 |
|
---|
558 |
self.cw_dir.configure( background=self.save_dir_btn_color, foreground='black' ) |
---|
559 |
self.cw_file.configure( background=self.save_file_btn_color, foreground='black' ) |
---|
560 |
|
---|
561 |
|
---|
562 |
|
---|
563 |
self.parent.parent.busyCursor = 'watch' |
---|
564 |
self.parent.parent.busyWidgets = [self.parent.parent.pane2.pane( 'EditPaneTop' ), self.parent.parent.pane2.pane( 'EditPaneBottom' ), self.parent.parent.pane2.pane( 'EditPaneStatus' ), self.parent.parent.pane.pane( 'ControlPane' )] |
---|
565 |
pub_busy.busyStart( self, self.parent.parent ) |
---|
566 |
|
---|
567 |
|
---|
568 |
if self.parent.parent.offline == True: |
---|
569 |
onoff_line = "offline" |
---|
570 |
dirfilename = None |
---|
571 |
|
---|
572 |
self.dialog = Pmw.Dialog(self.parent.control_frame2, |
---|
573 |
title = 'Working off-line', |
---|
574 |
buttons = ('OK', 'Cancel'), |
---|
575 |
defaultbutton = 'OK', |
---|
576 |
command = pub_controls.Command( self.evt_work_off_line_directory, ), |
---|
577 |
) |
---|
578 |
|
---|
579 |
self.entry1 = Pmw.EntryField(self.dialog.interior(), |
---|
580 |
labelpos = 'w', |
---|
581 |
label_text = 'Directory:', |
---|
582 |
entry_width = 75, |
---|
583 |
entry_background = 'aliceblue', |
---|
584 |
entry_foreground = 'black', |
---|
585 |
) |
---|
586 |
self.entry1.pack(side='top', fill='x', expand=1, padx=10, pady=5) |
---|
587 |
self.entry2 = Pmw.EntryField(self.dialog.interior(), |
---|
588 |
labelpos = 'w', |
---|
589 |
label_text = 'Dataset Name:', |
---|
590 |
entry_width = 75, |
---|
591 |
entry_background = 'aliceblue', |
---|
592 |
entry_foreground = 'black', |
---|
593 |
) |
---|
594 |
self.entry2.pack(side='top', fill='x', expand=1, padx=10, pady=5) |
---|
595 |
|
---|
596 |
Pmw.alignlabels((self.entry1, self.entry2)) |
---|
597 |
|
---|
598 |
parent_geom = self.parent.parent.geometry() |
---|
599 |
geom = string.split(parent_geom, '+') |
---|
600 |
d1 = string.atoi( geom[1] ) |
---|
601 |
d2 = string.atoi( geom[2] ) |
---|
602 |
p1=string.atoi(geom[0].split('x')[0])*0.3 |
---|
603 |
p2=string.atoi(geom[0].split('x')[1])*0.3 |
---|
604 |
self.dialog.activate(geometry= "+%d+%d" % (p1+d1, p2+d2) ) |
---|
605 |
if self.parent.parent.offline_directories != "Cancel": |
---|
606 |
|
---|
607 |
self.fill_in_data_information_directory( dirfilename, onoff_line = onoff_line ) |
---|
608 |
else: |
---|
609 |
onoff_line = "online" |
---|
610 |
if self.generating_file_list_flg == 1: return |
---|
611 |
dialog_icon = tkFileDialog.Directory(master=self.parent.control_frame2, |
---|
612 |
title = 'Directory and File Selection') |
---|
613 |
dirfilename=dialog_icon.show(initialdir=os.getcwd()) |
---|
614 |
if dirfilename in [(), '']: |
---|
615 |
pub_busy.busyEnd( self, self.parent.parent ) |
---|
616 |
return |
---|
617 |
|
---|
618 |
self.stop_listing_flg = 0 |
---|
619 |
|
---|
620 |
self.parent.parent.extension = [] |
---|
621 |
self.parent.parent.extension.append( (self.data_filter._entryfield.get().split()[-1]) ) |
---|
622 |
|
---|
623 |
|
---|
624 |
self.fill_in_data_information_directory( dirfilename, onoff_line = onoff_line ) |
---|
625 |
|
---|
626 |
pub_busy.busyEnd( self, self.parent.parent ) |
---|
627 |
|
---|
628 |
|
---|
629 |
bcolorbg = Pmw.Color.changebrightness(self.parent.parent, 'aliceblue', 0.25 ) |
---|
630 |
bcolorfg = Pmw.Color.changebrightness(self.parent.parent, 'aliceblue', 0.85 ) |
---|
631 |
self.cw_dir.configure( background=bcolorbg, foreground=bcolorfg ) |
---|
632 |
|
---|
633 |
|
---|
634 |
|
---|
635 |
|
---|
636 |
def evt_popup_file_window( self ): |
---|
637 |
|
---|
638 |
self.cw_dir.configure( background=self.save_dir_btn_color, foreground='black' ) |
---|
639 |
self.cw_file.configure( background=self.save_file_btn_color, foreground='black' ) |
---|
640 |
self.cw_reg.configure( background=self.save_reg_btn_color, foreground='black' ) |
---|
641 |
|
---|
642 |
if self.generating_file_list_flg == 1: return |
---|
643 |
dialog_icon = tkFileDialog.Open(master=self.parent.control_frame2, |
---|
644 |
filetypes=pub_controls.filetypes, title = 'File Open Selection') |
---|
645 |
dirfilename=dialog_icon.show(initialdir=os.getcwd()) |
---|
646 |
if dirfilename in [(), '']: return |
---|
647 |
|
---|
648 |
|
---|
649 |
if self.parent.parent.offline == True: |
---|
650 |
onoff_line = "offline" |
---|
651 |
else: |
---|
652 |
onoff_line = "online" |
---|
653 |
|
---|
654 |
|
---|
655 |
self.parent.parent.busyCursor = 'watch' |
---|
656 |
self.parent.parent.busyWidgets = [self.parent.parent.pane2.pane( 'EditPaneTop' ), self.parent.parent.pane2.pane( 'EditPaneBottom' ), self.parent.parent.pane2.pane( 'EditPaneStatus' ), self.parent.parent.pane.pane( 'ControlPane' )] |
---|
657 |
pub_busy.busyStart( self, self.parent.parent ) |
---|
658 |
|
---|
659 |
|
---|
660 |
bcolorbg = Pmw.Color.changebrightness(self.parent.parent, 'aliceblue', 0.25 ) |
---|
661 |
bcolorfg = Pmw.Color.changebrightness(self.parent.parent, 'aliceblue', 0.85 ) |
---|
662 |
self.cw_file.configure( background=bcolorbg, foreground=bcolorfg ) |
---|
663 |
|
---|
664 |
|
---|
665 |
self.fill_in_data_information_file( dirfilename, onoff_line = onoff_line ) |
---|
666 |
pub_busy.busyEnd( self, self.parent.parent ) |
---|
667 |
|
---|
668 |
|
---|
669 |
|
---|
670 |
|
---|
671 |
def evt_work_off_line_directory( self, event ): |
---|
672 |
if event == "OK": |
---|
673 |
self.parent.parent.offline_directories = [ self.entry1.get( ).strip() ] |
---|
674 |
self.parent.parent.offline_datasetName = self.entry2.get( ).strip() |
---|
675 |
if (len(self.entry1.get( ).strip()) == 0) or (len(self.entry2.get( ).strip()) == 0): |
---|
676 |
self.parent.parent.offline_directories = "Cancel" |
---|
677 |
self.parent.parent.offline_datasetName = "Cancel" |
---|
678 |
elif event == "Cancel": |
---|
679 |
self.parent.parent.offline_directories = "Cancel" |
---|
680 |
self.parent.parent.offline_datasetName = "Cancel" |
---|
681 |
|
---|
682 |
self.dialog.destroy() |
---|
683 |
|
---|
684 |
|
---|
685 |
|
---|
686 |
|
---|
687 |
def evt_change_color( self, event ): |
---|
688 |
keycolor = Pmw.Color.changebrightness(self.parent, 'red', 0.85) |
---|
689 |
self.directory_combo.configure( entry_background = keycolor ) |
---|
690 |
|
---|
691 |
|
---|
692 |
|
---|
693 |
|
---|
694 |
def evt_tab( self, event ): |
---|
695 |
s=string.split( self.directory_combo.get(), '/' )[-1] |
---|
696 |
s2=string.split( self.directory_combo.get(), '/' ) |
---|
697 |
d = '' |
---|
698 |
for x in os.listdir( './' ): |
---|
699 |
if os.path.isfile( x ): |
---|
700 |
pass |
---|
701 |
else: |
---|
702 |
if string.find( x, s ) == 0: |
---|
703 |
if len(d): |
---|
704 |
if len(d) > len(x): |
---|
705 |
d = x |
---|
706 |
else: |
---|
707 |
d = x |
---|
708 |
if d == '': d = s2[-1] |
---|
709 |
r = '' |
---|
710 |
for x in s2[1:-1]: r = r + '/' + x |
---|
711 |
r = r + '/' + d |
---|
712 |
self.directory_combo.delete( 0, 'end' ) |
---|
713 |
self.directory_combo.setentry( r ) |
---|
714 |
|
---|
715 |
self.evt_enter_directory( None ) |
---|
716 |
|
---|
717 |
|
---|
718 |
|
---|
719 |
return "break" |
---|
720 |
|
---|
721 |
|
---|
722 |
|
---|
723 |
|
---|
724 |
def evt_backspace( self, event ): |
---|
725 |
keycolor = Pmw.Color.changebrightness(self.parent, 'red', 0.85) |
---|
726 |
self.directory_combo.configure( entry_background = keycolor ) |
---|
727 |
t = self.directory_combo.get() |
---|
728 |
s=string.split( t, '/' )[-1] |
---|
729 |
if s == '': |
---|
730 |
self.evt_enter_directory( None ) |
---|
731 |
|
---|
732 |
|
---|
733 |
|
---|
734 |
|
---|
735 |
def evt_enter_directory( self, event ): |
---|
736 |
|
---|
737 |
self.directory_combo.configure( entry_background = 'white' ) |
---|
738 |
|
---|
739 |
|
---|
740 |
|
---|
741 |
|
---|
742 |
def stop_listing( self ): |
---|
743 |
self.stop_listing_flg = 1 |
---|
744 |
|
---|
745 |
|
---|
746 |
|
---|
747 |
|
---|
748 |
|
---|