1
2
3
4
5
6
7
8 """
9 Module implementing classes to provide documentation on the application
10 """
11
12
13
14
15
16
17
18
19 import Tkinter, Pmw,re
20 from mglutil.gui.InputForm.Tk.gui import InputFormDescr
21 from mglutil.gui.BasicWidgets.Tk.customizedWidgets import ListChooser, \
22 kbScrolledListBox
23 from ViewerFramework.VFCommand import Command,CommandGUI
24 from string import join
25 global commandslist
26 import webbrowser,os,sys
27 from Tkinter import *
28 from types import StringType
29
30 try:
31 os.remove('Pmv/BugReport.html')
32 except OSError:
33 pass
34 VarDict = { }
36 """Command to show mailing lists of Pmv and Vision.
37 \nPackage : Pmv
38 \nModule : helpCommands
39 \nClass : mailingListsCommand
40 \nCommand : mailingListsCommand
41 \nSynopsis:\n
42 None <--- mailingListsCommand(module, commands=None, package=None, **kw)
43 \nRequired Arguements\n:
44 module --- name of the module (filename)
45 \nOptional Arguements:\n
46 commands --- list of cammnds in that module
47 \nPackage --- package name to which module belongs
48 """
49
50
53
54 - def doit(self, pack, page):
55
56 if page == None or pack == None:
57 return
58 if pack == "Pmv":
59
60 if page == "Login Page":
61 webbrowser.open_new('http://mgldev.scripps.edu/mailman/listinfo/pmv')
62
63 if page == "Archive Page":
64 webbrowser.open_new('http://mgldev.scripps.edu/pipermail/pmv')
65 if pack == "Vision":
66 if page == "Login Page":
67 webbrowser.open_new('http://mgldev.scripps.edu/mailman/listinfo/vision')
68
69 if page == "Archive Page":
70 webbrowser.open_new('http://mgldev.scripps.edu/pipermail/vision')
71
72
74 """None <--- mailingListsCommand(pack,page)
75 \nRequired Arguements\n:
76 pack --- name of the package(Pmv, or Vision)
77 \npage ---name of the page(Login or Archive)
78
79 """
80 if page == None:
81 return
82 if type(page) is not StringType or type(pack) is not StringType:
83 return "ERROR: pack or page are not string type"
84 if page not in ["Login Page", "Archive Page"]:
85 return "ERROR: Invalid page name"
86 if pack not in ["Pmv","Vision"]:
87 return "ERROR: Invalid pack name"
88 apply(self.doitWrapper,(pack,page,),{})
89
90
91
129
131 val = self.showForm('Show MailingLists',force = 1,modal =0,blocking = 0)
132 ebn = val.descr.entryByName
133
134
136 self.cmdForms['Show MailingLists'].withdraw()
137
139 ebn = self.cmdForms['Show MailingLists'].descr.entryByName
140 c = self.cmdForms['Show MailingLists'].mf.cget('cursor')
141 cmdW1 = ebn['pmvlist']['widget']
142 cmdW2 = ebn['visionlist']['widget']
143
144 CmdName1 = cmdW1.getcurselection()
145 cmdW1.select_clear(0,last=1)
146
147 CmdName2 = cmdW2.getcurselection()
148 cmdW2.select_clear(0,last=1)
149
150 if len(CmdName1) != 0:
151
152 if CmdName1[0] == 'Login Page':
153 page = "Login Page"
154 pack ="Pmv"
155 apply( self.doitWrapper,(pack, page,),{})
156
157 if CmdName1[0] == 'Archive Page':
158
159 page = "Archive Page"
160 pack ="Pmv"
161 apply( self.doitWrapper,(pack, page,),{})
162 CmdName1 =()
163
164 if len(CmdName2) != 0:
165
166 if CmdName2[0] == 'Login Page':
167 page = "Login Page"
168 pack = "Vision"
169 apply( self.doitWrapper,(pack, page,),{})
170
171 if CmdName2[0] == 'Archive Page':
172 page = "Archive Page"
173 pack = "Vision"
174 apply( self.doitWrapper,(pack, page,),{})
175 CmdName2 =()
176 mailingListsCommandGUI = CommandGUI()
177 mailingListsCommandGUI.addMenuCommand('menuRoot', 'Help',
178 'MailingList')
179
180
182
185
189
190
191
192
194
195 apply(self.doitWrapper,(),{})
196
197
322
324 val = self.showForm('BugReport',force = 1,modal =0,blocking = 0)
325 ebn = val.descr.entryByName
326 pdb_group=ebn['PDBFILEGROUP']['widget']
327 pdb_group.expand()
328 pmvlog_group=ebn['PMVLOGGROUP']['widget']
329 pmvlog_group.collapse()
330 shortdesc_tx=ebn['shortdescadd']['widget']
331 shortdesc_tx.configure(text_height=2)
332 desc_tx=ebn['descadd']['widget']
333 desc_tx.configure(text_height=8)
334 pdb_addw=ebn['pdbfileadd']['widget']
335 pdb_addw.configure(listbox_height=1)
336
337
339 self.cmdForms['BugReport'].withdraw()
340
341
343 """for attching files"""
344 ebn = self.cmdForms['BugReport'].descr.entryByName
345 pdb_group=ebn['PDBFILEGROUP']['widget']
346 pdb_addw=ebn['pdbfileadd']['widget']
347 pdb_att=ebn['AttachMore']['widget']
348 pdb_delw=ebn['DeleteSelected']['widget']
349 Filename = self.vf.askFileOpen(parent=pdb_att.winfo_toplevel(), types=[('all files','*')],
350 title="ADDFile")
351 if Filename:
352 inputfilename = os.path.abspath(Filename)
353 files=pdb_addw.get()
354 files=list(files)
355 files.append(inputfilename)
356 pdb_addw.setlist(files)
357 pdb_addw.configure(listbox_height=len(files))
358 pdb_delw.configure(state="active")
359
360 else:
361 if len(pdb_addw.get())==0:
362 pdb_delw.configure(state="disabled")
363 pdb_addw.setlist(pdb_addw.get())
364
365
367 """deletes selected files"""
368 ebn = self.cmdForms['BugReport'].descr.entryByName
369 pdb_group=ebn['PDBFILEGROUP']['widget']
370 pdb_addw=ebn['pdbfileadd']['widget']
371 pdb_delw=ebn['DeleteSelected']['widget']
372 files=pdb_addw.get()
373 lfiles=list(files)
374 selected_files=pdb_addw.getcurselection()
375 for s in list(selected_files):
376 if s in lfiles:
377 lfiles.remove(s)
378 pdb_addw.setlist(lfiles)
379 pdb_addw.configure(listbox_height=len(lfiles))
380 if len(pdb_addw.get())==0:
381 pdb_delw.configure(state="disabled")
382
384
385 ebn = self.cmdForms['BugReport'].descr.entryByName
386 var=ebn['PMVLOGGROUP']['wcfg']['tag_variable'].get()
387 pmvlog_group=ebn['PMVLOGGROUP']['widget']
388 pmvlog_txtw=ebn['pmvlogtext']['widget']
389 if var==0:
390 pmvlog_group.collapse()
391 message_list = ""
392
393 if var==1 :
394
395 pmvlog_group.expand()
396 tx = self.vf.GUI.MESSAGE_BOX.tx
397 message_list = tx.get().split('\n')[:-2]
398 pmvlog_txtw.configure(text_height=3)
399
400 mes =""
401 for m in message_list:
402 mes=mes+m+"\n"
403 pmvlog_txtw.settext(mes)
404
405
406
408 ebn = self.cmdForms['BugReport'].descr.entryByName
409 desc_w =ebn['descadd']['widget']
410 desc_text = desc_w.get()
411 shortdesc_w = ebn['shortdescadd']['widget']
412
413 shortdesc_text =shortdesc_w.get()
414
415 VarDict['desc_text'] = desc_text
416 VarDict['shortdesc_text'] = shortdesc_text
417 email_ent = ebn['emailentry']['widget'].get()
418 VarDict['email_recipient'] = email_ent
419 pmvlog_txtw=ebn['pmvlogtext']['widget']
420 VarDict['pmvlog'] = pmvlog_txtw.get()
421 pdb_addw=ebn['pdbfileadd']['widget']
422 VarDict['attachfile'] = pdb_addw.get()
423
424
426
427 if len(email) > 7:
428 if re.match("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$", email) != None:
429 return 1
430 return 0
432 self.get_description()
433
434 sumcont = VarDict['shortdesc_text']
435
436 if VarDict.has_key('pmvlog') and len(VarDict['pmvlog'])>0:
437
438 fulldesc = VarDict['desc_text']+"\n"+"PMV LOG:"+"\n"+VarDict['pmvlog']
439 else:
440 fulldesc = VarDict['desc_text']
441
442 if len(VarDict['email_recipient'])>1:
443 desccont = fulldesc+"\n"+"-by"+" "+VarDict['email_recipient']
444 else:
445 desccont = fulldesc
446 if len(sumcont)<=1 or len(desccont)<=1:
447 import tkMessageBox
448 ok = tkMessageBox.askokcancel("Input","Please enter summary and description")
449 return
450 from mglutil.TestUtil import BugReport
451 if VarDict.has_key('attachfile'):
452 upfile = VarDict['attachfile']
453 else:
454 upfile=""
455 BR=BugReport.BugReportCommand("PMV")
456 from Support.version import __version__
457 if self.validateEmail(VarDict['email_recipient']):
458 idnum = BR.showuploadpage_cb(sumcont,desccont,upfile,
459 email_ent=VarDict['email_recipient'],
460 product="MGL Applications",
461 version=__version__)
462 else:
463
464 idnum = BR.showuploadpage_cb(sumcont,desccont,upfile,
465 email_ent="",
466 product="MGL Applications",
467 version=__version__)
468
469
470 self.dismiss_cb()
471
472
473
474
475 root = Tk()
476 t = Text(root)
477 t.pack()
478
479 def openHLink(event):
480 start, end = t.tag_prevrange("hlink",
481 t.index("@%s,%s" % (event.x, event.y)))
482 webbrowser.open_new('%s' %t.get(start, end))
483
484
485 t.tag_configure("hlink", foreground='blue', underline=1)
486 t.tag_bind("hlink", "<Control-Button-1>", openHLink)
487 t.insert(END, "BugReport has been Submitted Successfully\n")
488 t.insert(END, "BugId is %s" %idnum)
489 t.insert(END,"\nYou can visit Bug at\n")
490 t.insert(END,"http://mgldev.scripps.edu/bugs/show_bug.cgi?id=%i" %int(idnum),"hlink")
491 t.insert(END,"\nControl-click on the link to visit this page\n")
492 t.insert(END,"\n")
493
494
495
496 BugReportCommandGUI = CommandGUI()
497 BugReportCommandGUI.addMenuCommand('menuRoot', 'Help',
498 'BugReport')
499
500 commandList = [
501 {'name':'mailingListsCommand','cmd':mailingListsCommand(),'gui':mailingListsCommandGUI},
502 {'name':'BugReportCommand','cmd':BugReportCommand(),'gui':BugReportCommandGUI},
503 ]
504
505
506
508 for dict in commandList:
509 viewer.addCommand(dict['cmd'], dict['name'], dict['gui'])
510