Beispiel #1
0
   def execute_connect(self, result):
      import cdms2
      #	self.transfer_toggle is either: "Python" or "RM"
      #	self.replica_toggle is either:  0 or 1: default is 1 for User Replica Catalog
      # self.rqmeny1.get() returns the "Replica DN" string
      #	self.rqmeny2.get() returns the "User ID" string
      if result == 'Connect':
         if self.cbn1.anonymous_flag:
            gui_control.directory_or_database = 'database'
            uri = 'ldap://'+self.eny1.get()+':'+self.eny2.get()+self.cbx2.get()
#            self.parent.panelSV.textv_lab3.set("  Dataset:  " )
            gui_control.db=cdms2.connect( uri )
         else:    # Must have "User Dn" and "Password"
            try:
               gui_control.db=cdms2.connect( user=self.parent.eny3.get(),
                                            password=self.parent.eny4.get() )
            except:
               gui_message.error(
                    "Invalid 'User DN' and 'Password' combination.\nTry again." )
               return
            uri = gui_control.db.uri
         # Set the transfer method (Python FTP or ESG Request Manager)
         if self.transfer_toggle=='Python':
            import cdms2.cache
            cdms2.cache.usePythonTransfer()
         elif self.transfer_toggle=='RM':
            gui_control.db.useRequestManager(self.rqmeny1.get(), self.replica_toggle, self.rqmeny2.get())
         
         # Display the URI in the "Database" entry window
         self.parent.panelSV.tin2.delete( 0, 'end' )
         self.parent.panelSV.tin2.insert( 0, uri  )
         self.parent.panelSV.tin3.delete( 0, 'end' )
         self.parent.panelSV.tin4.delete( 0, 'end' )

         # Display the URIs in the "Databases" window
         match_found = None
         for x in gui_control.db_connections:
             match_found = re.match( uri, x )
             if match_found: break
         if not match_found:
            gui_control.db_connections.append( uri )
         self.parent.panelSV.tin2.clear( )        # clear "directory" combo box entry and list
         self.parent.panelSV.tin2.setentry( gui_control.db_connections )
         self.parent.panelSV.tin2.insert(  0, gui_control.db_connections )
         self.parent.balloon.bind(self.parent.panelSV.tin2._arrowBtn, 'View and Select Databases')
         self.parent.balloon.bind(self.parent.panelSV.tin3._arrowBtn, 'View and Select Datasets in Database')
         self.parent.balloon.bind(self.parent.panelSV.tin4._arrowBtn, 'View and Select Variables in Dataset')

         # Display the datasets in the "Datasets" window
         ds_list = gui_control.db.listDatasets()
         ds_list.sort()
         self.parent.panelSV.tin3.ds_list = ds_list
         #
         self.parent.panelSV.tin3.clear( )   # clear "directory" combo box entry and list
         self.parent.panelSV.tin4.clear( )   # clear "directory" combo box entry and list
         self.parent.panelSV.tin3.component('scrolledlist').setlist( ds_list )
         self.parent.panelSV.textv_lab3.set("Datasets:" )
      else:
         self.parent.panelSV.opt9.invoke(0)
      #
      self.dialog.destroy()
Beispiel #2
0
def evt_enter_directory( parent, event, who_called=0 ):
   # change backgound color to white
   parent.panelSV.tin2.configure( entry_background = 'white' )
   #
   Match_found = None
   if gui_control.directory_or_database == 'directory':
      if type(event) == types.StringType:
            if event[0] == '/':
               a = event
            elif event[0:5] == '=====':
               a = os.getcwd()
            else:
               a = os.getcwd() + '/' + event
      else:
         a = parent.panelSV.tin2.get()
         # Add tilde function to entry window
         if a == '~':
           a = os.environ['HOME']
         elif a[0:2] == '~/':
           a = os.environ['HOME'] + '/' + a[2:]
         elif a[0] == '~':
           a = os.environ['HOME'] + '/' + a[1:]
         a = a + '/'
      try:
         os.chdir( a )
      except:
         gui_message.error(('Cannot access directory [ %s ].' % a))
      a=a[0:-1]

      if parent.startusertask == 1: gui_control.track_user( parent, "Directory: %s" % a)

      parent.panelSV.tin2.clear( )		# clear "directory" combo box entry and list
      if parent.panelSV.tin3.first_time == 1:
         parent.panelSV.tin3.delete(0, 'end')	# clear only the "file" combo box list
      else:
         parent.panelSV.tin3.clear( )	        # clear "file" combo box entry and list
      if parent.panelSV.tin4.first_time == 1:
         parent.panelSV.tin4.delete(0, 'end')	# clear only the "variable" combo box list
      else:
         parent.panelSV.tin4.clear( )	        # clear "variable" combo box entry and list
      #
      if who_called != 1:
         t = os.getcwd()
      else:
         t = os.getcwd() + ' '
      parent.panelSV.tin2._entryfield.setentry( t )
      #
      d,f = gui_functions._scn_a_dir( parent )        # re-write the new directory information and save directory list
      gui_functions._scn_dir_history( parent, t )      # store access directory information to the history directory list
      for j in range(len( parent.dir_history )): parent.panelSV.tin2.insert( j, parent.dir_history[j] )
      for i in range(len(d)): parent.panelSV.tin2.insert( j+i+1, d[i] )
      #
      for i in range(len(f)): parent.panelSV.tin3.insert( i, f[i] )
      #
      parent.panelDM.fid2 = None
      parent.panelDM.var3 = parent.panelDM.remember_var3 = None
      #
      gui_functions._blank_dim1_to_ndim( parent )
      #
      if (parent.panelSV.tin3.first_time != 1) and (len(f) > 0):
         parent.panelSV.tin3.setentry( f[0] )
         evt_enter_file( parent, None )
      #
      # record the event: select a directory
      command = "os.chdir( '%s' )" % os.getcwd()
      gui_control.record_command( parent, command )
   elif gui_control.directory_or_database == 'database':
      if event.keysym == 'Return':
         try:
            parent.parent.update()
            g_wait = gui_message.wait(parent.parent,'Please wait while the connection\n to the database is made.')
            gui_control.db=cdms2.connect( parent.parent.tin2.get() )
            parent.parent.update()
            g_wait.progress()
            for x in gui_control.db_connections:
               Match_found = re.match( parent.parent.tin2.get(), x )
               if Match_found: break
            if not Match_found:
               gui_control.db_connections.append( parent.parent.tin2.get() )
            parent.parent.panelC.scl1.setlist( gui_control.db_connections )
            db_list = gui_control.db.listDatasets()
            db_list.sort()
            parent.parent.panelC.scl2.setlist( db_list )
            parent.parent.panelC.scl3.setlist( '' )
            gui_functions._blank_dim1_to_ndim( parent )
            g_wait.execute()
         except:
            g_wait.execute()
            gui_message.error("Invalid database string.\nCould not connect to specified database.")
Beispiel #3
0
    def execute_connect(self, result):
        import cdms2
        #	self.transfer_toggle is either: "Python" or "RM"
        #	self.replica_toggle is either:  0 or 1: default is 1 for User Replica Catalog
        # self.rqmeny1.get() returns the "Replica DN" string
        #	self.rqmeny2.get() returns the "User ID" string
        if result == 'Connect':
            if self.cbn1.anonymous_flag:
                gui_control.directory_or_database = 'database'
                uri = 'ldap://' + self.eny1.get() + ':' + self.eny2.get(
                ) + self.cbx2.get()
                #            self.parent.panelSV.textv_lab3.set("  Dataset:  " )
                gui_control.db = cdms2.connect(uri)
            else:  # Must have "User Dn" and "Password"
                try:
                    gui_control.db = cdms2.connect(
                        user=self.parent.eny3.get(),
                        password=self.parent.eny4.get())
                except:
                    gui_message.error(
                        "Invalid 'User DN' and 'Password' combination.\nTry again."
                    )
                    return
                uri = gui_control.db.uri
            # Set the transfer method (Python FTP or ESG Request Manager)
            if self.transfer_toggle == 'Python':
                import cdms2.cache
                cdms2.cache.usePythonTransfer()
            elif self.transfer_toggle == 'RM':
                gui_control.db.useRequestManager(self.rqmeny1.get(),
                                                 self.replica_toggle,
                                                 self.rqmeny2.get())

            # Display the URI in the "Database" entry window
            self.parent.panelSV.tin2.delete(0, 'end')
            self.parent.panelSV.tin2.insert(0, uri)
            self.parent.panelSV.tin3.delete(0, 'end')
            self.parent.panelSV.tin4.delete(0, 'end')

            # Display the URIs in the "Databases" window
            match_found = None
            for x in gui_control.db_connections:
                match_found = re.match(uri, x)
                if match_found: break
            if not match_found:
                gui_control.db_connections.append(uri)
            self.parent.panelSV.tin2.clear(
            )  # clear "directory" combo box entry and list
            self.parent.panelSV.tin2.setentry(gui_control.db_connections)
            self.parent.panelSV.tin2.insert(0, gui_control.db_connections)
            self.parent.balloon.bind(self.parent.panelSV.tin2._arrowBtn,
                                     'View and Select Databases')
            self.parent.balloon.bind(self.parent.panelSV.tin3._arrowBtn,
                                     'View and Select Datasets in Database')
            self.parent.balloon.bind(self.parent.panelSV.tin4._arrowBtn,
                                     'View and Select Variables in Dataset')

            # Display the datasets in the "Datasets" window
            ds_list = gui_control.db.listDatasets()
            ds_list.sort()
            self.parent.panelSV.tin3.ds_list = ds_list
            #
            self.parent.panelSV.tin3.clear(
            )  # clear "directory" combo box entry and list
            self.parent.panelSV.tin4.clear(
            )  # clear "directory" combo box entry and list
            self.parent.panelSV.tin3.component('scrolledlist').setlist(ds_list)
            self.parent.panelSV.textv_lab3.set("Datasets:")
        else:
            self.parent.panelSV.opt9.invoke(0)
        #
        self.dialog.destroy()
def evt_enter_directory(parent, event, who_called=0):
    # change backgound color to white
    parent.panelSV.tin2.configure(entry_background='white')
    #
    Match_found = None
    if gui_control.directory_or_database == 'directory':
        if type(event) == types.StringType:
            if event[0] == '/':
                a = event
            elif event[0:5] == '=====':
                a = os.getcwd()
            else:
                a = os.getcwd() + '/' + event
        else:
            a = parent.panelSV.tin2.get()
            # Add tilde function to entry window
            if a == '~':
                a = os.environ['HOME']
            elif a[0:2] == '~/':
                a = os.environ['HOME'] + '/' + a[2:]
            elif a[0] == '~':
                a = os.environ['HOME'] + '/' + a[1:]
            a = a + '/'
        try:
            os.chdir(a)
        except:
            gui_message.error(('Cannot access directory [ %s ].' % a))
        a = a[0:-1]

        if parent.startusertask == 1:
            gui_control.track_user(parent, "Directory: %s" % a)

        parent.panelSV.tin2.clear(
        )  # clear "directory" combo box entry and list
        if parent.panelSV.tin3.first_time == 1:
            parent.panelSV.tin3.delete(
                0, 'end')  # clear only the "file" combo box list
        else:
            parent.panelSV.tin3.clear(
            )  # clear "file" combo box entry and list
        if parent.panelSV.tin4.first_time == 1:
            parent.panelSV.tin4.delete(
                0, 'end')  # clear only the "variable" combo box list
        else:
            parent.panelSV.tin4.clear(
            )  # clear "variable" combo box entry and list
        #
        if who_called != 1:
            t = os.getcwd()
        else:
            t = os.getcwd() + ' '
        parent.panelSV.tin2._entryfield.setentry(t)
        #
        d, f = gui_functions._scn_a_dir(
            parent
        )  # re-write the new directory information and save directory list
        gui_functions._scn_dir_history(
            parent, t
        )  # store access directory information to the history directory list
        for j in range(len(parent.dir_history)):
            parent.panelSV.tin2.insert(j, parent.dir_history[j])
        for i in range(len(d)):
            parent.panelSV.tin2.insert(j + i + 1, d[i])
        #
        for i in range(len(f)):
            parent.panelSV.tin3.insert(i, f[i])
        #
        parent.panelDM.fid2 = None
        parent.panelDM.var3 = parent.panelDM.remember_var3 = None
        #
        gui_functions._blank_dim1_to_ndim(parent)
        #
        if (parent.panelSV.tin3.first_time != 1) and (len(f) > 0):
            parent.panelSV.tin3.setentry(f[0])
            evt_enter_file(parent, None)
        #
        # record the event: select a directory
        command = "os.chdir( '%s' )" % os.getcwd()
        gui_control.record_command(parent, command)
    elif gui_control.directory_or_database == 'database':
        if event.keysym == 'Return':
            try:
                parent.parent.update()
                g_wait = gui_message.wait(
                    parent.parent,
                    'Please wait while the connection\n to the database is made.'
                )
                gui_control.db = cdms2.connect(parent.parent.tin2.get())
                parent.parent.update()
                g_wait.progress()
                for x in gui_control.db_connections:
                    Match_found = re.match(parent.parent.tin2.get(), x)
                    if Match_found: break
                if not Match_found:
                    gui_control.db_connections.append(parent.parent.tin2.get())
                parent.parent.panelC.scl1.setlist(gui_control.db_connections)
                db_list = gui_control.db.listDatasets()
                db_list.sort()
                parent.parent.panelC.scl2.setlist(db_list)
                parent.parent.panelC.scl3.setlist('')
                gui_functions._blank_dim1_to_ndim(parent)
                g_wait.execute()
            except:
                g_wait.execute()
                gui_message.error(
                    "Invalid database string.\nCould not connect to specified database."
                )