Example #1
0
    def evt_select_opendap_server(self, result):
        self.trb1.clear()

        self.auth_realm = None
        self.auth_host = None
        self.auth_url = None
        self.auth_callback = None
        self.auth_callback_handler = None

        if (self.gui_parent.auth_realm is not None):
            self.auth_realm = self.gui_parent.auth_realm
        if (self.gui_parent.auth_host is not None):
            self.auth_host = self.gui_parent.auth_host

        try:
            thredds_url = self.servers[result]['thredds_url']
            thredds_xml = http_thredds.get(thredds_url)
            thredds_obj = http_thredds.parse(thredds_xml)

            root_node = self.trb1.root
            root_node.id = thredds_url

            root_node.set_label(thredds_obj.dataset_name)
            self.trb1.move_cursor(self.trb1.root)

        except Exception, e:
            self.trb1.root.set_label('Select a THREDDS Catalog.')
            self.trb1.root.id = 0
            self.trb1.first()
            gui_message.error(e)
Example #2
0
    def evt_click_tree(self, event):
        cur_server = self.ptls.get()
        cur_node = self.trb1.cursor_node()
        
        if not cur_node.expandable():
            if (self.add_password_flg == 0):
               if ((self.gui_parent.username is not None) or (self.gui_parent.password is not None) or
                   (self.gui_parent.auth_realm is not None) or (self.gui_parent.auth_host is not None)): 
                    self.passwordMgr.add_password(self.gui_parent.auth_realm, self.gui_parent.auth_host, 
                                            self.gui_parent.username, self.gui_parent.password)
                    self.add_password_flg = 1

            try:
                # get url base from parent node thredds
                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://'):
                    opendap_url = opendap_url_base + str(cur_node.id)
                    opendap_das = http_opendap.get_das(opendap_url, self.passwordMgr, self)
                    if (opendap_das is not None):
                        self.handle_das(opendap_das)
                else:
                    raise Exception('Unknown protocol for DODS/OPeNDAP access.')
            
            except Exception, e:
                gui_message.error(e)
Example #3
0
 def evt_select_opendap_server(self, result):
     self.trb1.clear()
     
     self.auth_realm = None
     self.auth_host = None
     self.auth_url = None
     self.auth_callback = None
     self.auth_callback_handler = None
     
     if (self.gui_parent.auth_realm is not None):
         self.auth_realm = self.gui_parent.auth_realm
     if (self.gui_parent.auth_host is not None):
         self.auth_host = self.gui_parent.auth_host
     
     try:
         thredds_url = self.servers[result]['thredds_url']
         thredds_xml = http_thredds.get(thredds_url)
         thredds_obj = http_thredds.parse(thredds_xml)
         
         root_node = self.trb1.root
         root_node.id = thredds_url
         
         root_node.set_label(thredds_obj.dataset_name)
         self.trb1.move_cursor(self.trb1.root)
         
     except Exception, e:
         self.trb1.root.set_label('Select a THREDDS Catalog.')
         self.trb1.root.id = 0
         self.trb1.first()
         gui_message.error(e)
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_expand_node(self, node):
     cur_server = self.ptls.get()
     if (cur_server != ''):
         try:
             thredds_url = node.id
             thredds_xml = http_thredds.get(thredds_url)
             thredds_obj = http_thredds.parse(thredds_xml)
             
             for cur_catalog_ref in thredds_obj.catalog_refs:
                 self.trb1.add_node(id=cur_catalog_ref['href'], name=cur_catalog_ref['title'], flag=True)
                 
             for cur_file in thredds_obj.files:
                 self.trb1.add_node(id=cur_file['url_suffix'], name=cur_file['name'], flag=False)
         except AttributeError:
             pass
         except Exception, e:
             gui_message.error(e)
Example #6
0
    def evt_expand_node(self, node):
        cur_server = self.ptls.get()
        if (cur_server != ''):
            try:
                thredds_url = node.id
                thredds_xml = http_thredds.get(thredds_url)
                thredds_obj = http_thredds.parse(thredds_xml)

                for cur_catalog_ref in thredds_obj.catalog_refs:
                    self.trb1.add_node(id=cur_catalog_ref['href'],
                                       name=cur_catalog_ref['title'],
                                       flag=True)

                for cur_file in thredds_obj.files:
                    self.trb1.add_node(id=cur_file['url_suffix'],
                                       name=cur_file['name'],
                                       flag=False)
            except AttributeError:
                pass
            except Exception, e:
                gui_message.error(e)
Example #7
0
    def evt_click_tree(self, event):
        cur_server = self.ptls.get()
        cur_node = self.trb1.cursor_node()

        if not cur_node.expandable():
            if (self.add_password_flg == 0):
                if ((self.gui_parent.username is not None)
                        or (self.gui_parent.password is not None)
                        or (self.gui_parent.auth_realm is not None)
                        or (self.gui_parent.auth_host is not None)):
                    self.passwordMgr.add_password(self.gui_parent.auth_realm,
                                                  self.gui_parent.auth_host,
                                                  self.gui_parent.username,
                                                  self.gui_parent.password)
                    self.add_password_flg = 1

            try:
                # get url base from parent node thredds
                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://'):
                    opendap_url = opendap_url_base + str(cur_node.id)
                    opendap_das = http_opendap.get_das(opendap_url,
                                                       self.passwordMgr, self)
                    if (opendap_das is not None):
                        self.handle_das(opendap_das)
                else:
                    raise Exception(
                        'Unknown protocol for DODS/OPeNDAP access.')

            except Exception, e:
                gui_message.error(e)
Example #8
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)