예제 #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)
예제 #2
0
파일: gui_opendap.py 프로젝트: AZed/uvcdat
    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)
예제 #3
0
파일: gui_opendap.py 프로젝트: AZed/uvcdat
 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)
예제 #4
0
파일: gui_opendap.py 프로젝트: AZed/uvcdat
 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)
예제 #5
0
파일: gui_opendap.py 프로젝트: AZed/uvcdat
 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)
예제 #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)
예제 #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)
예제 #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)