Example #1
0
 def evt_btn_select_file(self, exit):
     cur_server = self.ptls.get()
     cur_node = self.trb1.cursor_node()
     
     try:
         thredds_url = cur_node.parent_node.id
         thredds_xml = http_thredds.get(thredds_url)
         thredds_obj = http_thredds.parse(thredds_xml)
         opendap_url_base = [cur_service['base'] for cur_service in thredds_obj.services if cur_service['serviceType'] == 'DODS'][0]
         
         if (opendap_url_base[:7] == 'http://'):
         
             url = opendap_url_base + str(cur_node.id)
             
             if (self.auth_realm and self.auth_host):
                 username, password = self.passwordMgr.find_user_password(self.auth_realm, self.auth_host)
                 
                 if (username is not None and password is not None):
                     url = url.replace('http://', 'http://' + str(username) + ':' + str(password) + '@')
             
             if (exit == "exit"): self.dialog.withdraw()
                     
             self.gui_parent.panelSV.tin3.setentry(url)
             gui_select_variable.evt_enter_file(self.gui_parent, None)
             
         else:
             raise Exception('Unknown protocol for DODS/OPeNDAP access.')
     
     except Exception, e:
         gui_message.error(e)
def evt_icon_open_file(parent, dirfilename=None, event=None):
    if gui_control.directory_or_database == 'directory':
        # Show the popup directory dialog
        if dirfilename == None:
            dialog_icon = tkFileDialog.Open(master=parent,
                                            filetypes=gui_control.datatypes,
                                            title='File Select')
            dirfilename = dialog_icon.show(initialdir=os.getcwd())
            if dirfilename in [(), '']: return
            f = string.split(dirfilename, '/')[-1]
            d = dirfilename[0:(len(dirfilename) - len(f) - 1)]
            parent.panelSV.tin2.clear()
            parent.panelSV.tin3.clear()
            parent.panelSV.tin2.setentry(d)
            gui_select_variable.evt_enter_directory(parent, None)
            parent.panelSV.tin3.setentry(f)
            tmp = parent.file_search_pattern
            parent.file_search_pattern = 'All Files'
            gui_select_variable.evt_enter_file(parent, None)
            parent.file_search_pattern = tmp
            parent.panelSV.tin3.component('entry').focus_set()
        else:
            parent.panelSV.tin2.setentry(dirfilename)
            gui_select_variable.evt_enter_directory(parent, None)
            parent.panelSV.tin2.component('entry').focus_set()
Example #3
0
 def open_file( self, parent ):
    try:
       d = self.alias_list.getcurselection()[0]
       if (d[:7]!='http://'):
          sp=os.path.split(d)
          d = os.path.join(sp[:-1])
          parent.panelSV.tin2.setentry( d )
          gui_select_variable.evt_enter_directory( parent, None )
          d=sp[-1]
       elif cdat_info.CDMS_INCLUDE_DODS == 'yes':
          parent.panelSV.tin2.setentry( '' )
          parent.panelSV.tin3.clear( )
       parent.panelSV.tin3.setentry( d )
       gui_select_variable.evt_enter_file(parent, None)
       self.dialog.destroy()
       parent.panelSV.tin3.component( 'entry' ).focus_set()
    except Exception, err:
       pass
Example #4
0
    def evt_btn_select_file(self, exit):
        cur_server = self.ptls.get()
        cur_node = self.trb1.cursor_node()

        try:
            thredds_url = cur_node.parent_node.id
            thredds_xml = http_thredds.get(thredds_url)
            thredds_obj = http_thredds.parse(thredds_xml)
            opendap_url_base = [
                cur_service['base'] for cur_service in thredds_obj.services
                if cur_service['serviceType'] == 'DODS'
            ][0]

            if (opendap_url_base[:7] == 'http://'):

                url = opendap_url_base + str(cur_node.id)

                if (self.auth_realm and self.auth_host):
                    username, password = self.passwordMgr.find_user_password(
                        self.auth_realm, self.auth_host)

                    if (username is not None and password is not None):
                        url = url.replace(
                            'http://', 'http://' + str(username) + ':' +
                            str(password) + '@')

                if (exit == "exit"): self.dialog.withdraw()

                self.gui_parent.panelSV.tin3.setentry(url)
                gui_select_variable.evt_enter_file(self.gui_parent, None)

            else:
                raise Exception('Unknown protocol for DODS/OPeNDAP access.')

        except Exception, e:
            gui_message.error(e)
Example #5
0
def evt_icon_open_file( parent, dirfilename=None, event=None ):
   if gui_control.directory_or_database == 'directory':
      # Show the popup directory dialog
      if dirfilename == None:
         dialog_icon = tkFileDialog.Open(master=parent,
                           filetypes=gui_control.datatypes, title = 'File Select')
         dirfilename=dialog_icon.show(initialdir=os.getcwd())
         if dirfilename in [(), '']: return
         f=string.split( dirfilename, '/' )[-1]
         d=dirfilename[0:(len(dirfilename) - len(f) - 1)]
         parent.panelSV.tin2.clear()
         parent.panelSV.tin3.clear()
         parent.panelSV.tin2.setentry( d )
         gui_select_variable.evt_enter_directory( parent, None )
         parent.panelSV.tin3.setentry( f )
         tmp=parent.file_search_pattern
         parent.file_search_pattern='All Files'
         gui_select_variable.evt_enter_file( parent, None )
         parent.file_search_pattern=tmp
         parent.panelSV.tin3.component( 'entry' ).focus_set()
      else:
         parent.panelSV.tin2.setentry( dirfilename )
         gui_select_variable.evt_enter_directory( parent, None )
         parent.panelSV.tin2.component( 'entry' ).focus_set()
Example #6
0
       root.panelGC.define_btn.forget()
       root.menu.main_menu.forget()
       root.menu2.main_menu2.pack(side='top', before=root.pane, fill='x')
       pos = '%dx%d+%d+%d' % (win_w, win_h*.6, dxwin, dywin)
       root.geometry(pos)

    root.deiconify() 
    root.update()
    root.lift()
    if len(sys.argv)>1:
       pth, f = os.path.split(sys.argv[1])
       if pth == '' : pth='.'
       root.panelSV.tin2.setentry(pth)
       gui_select_variable.evt_enter_directory(root,None)
       root.panelSV.tin3.selectitem(f)
       gui_select_variable.evt_enter_file(root,None)
       if len(sys.argv)>2:
          root.panelSV.tin4.setentry(sys.argv[2])
          gui_select_variable.evt_enter_variable(root,None)

    root.mainloop()
    if root.startusertask == 1:
       gui_control.track_user( root, "#______________________________________________________________________________")
       gui_control.track_user( root, "End Session Time: %s" % time.asctime())
       gui_control.track_user( root, "Total Session Wall-Clock Time in Minutes: %g" % ((int(time.time()-startwalltime))/60.0))
       gui_control.track_user( root, "Total Session Processor Time in Minutes: %g" % ((int(time.clock()-startcputime))/60.0))

if __name__ == "__main__":
    main()

#---------------------------------------------------------------------