def evt_popup_file_window(self):
        if self.generating_file_list_flg == 1: return
        dialog_icon = tkFileDialog.Open(master=self.parent.control_frame2,
                                        filetypes=pub_controls.filetypes,
                                        title='File Open Selection')
        dirfilename = dialog_icon.show(initialdir=os.getcwd())
        if dirfilename in [(), '']: return

        # Set up the thread to do asynchronous I/O
        self.stop_listing_flg = 0

        self.parent.parent.busyCursor = 'watch'
        self.parent.parent.busyWidgets = [
            self.parent.parent.pane2.pane('EditPaneTop')
        ]

        # Note: this busy cursor is reset in open_text_file
        pub_busy.busyStart(self.parent.parent)

        # Remove the old list
        if self.parent.parent.file_counter > 0:
            self.parent.parent.pub_editorviewer.sf.destroy()
            self.parent.parent.pub_editorviewer = pub_editorviewer.create_publisher_editor_viewer(
                self.parent.parent)

        self.parent.parent.log_window.appendtext("Creating the file list...\n")
        self.generating_file_list_flg = 1
        lock = thread.allocate_lock()
        thread.start_new_thread(self.open_text_file, (dirfilename, lock))
    def evt_popup_file_window( self ):
       if self.generating_file_list_flg == 1: return
       dialog_icon = tkFileDialog.Open(master=self.parent.control_frame2,
                         filetypes=pub_controls.filetypes, title = 'File Open Selection')
       dirfilename=dialog_icon.show(initialdir=os.getcwd())
       if dirfilename in [(), '']: return

       # Set up the thread to do asynchronous I/O
       self.stop_listing_flg = 0

       self.parent.parent.busyCursor = 'watch'
       self.parent.parent.busyWidgets = [self.parent.parent.pane2.pane( 'EditPaneTop' )]
       
       # Note: this busy cursor is reset in open_text_file
       pub_busy.busyStart(self.parent.parent)

       # Remove the old list
       if self.parent.parent.file_counter > 0:
          self.parent.parent.pub_editorviewer.sf.destroy()
          self.parent.parent.pub_editorviewer = pub_editorviewer.create_publisher_editor_viewer( self.parent.parent )

       self.parent.parent.log_window.appendtext("Creating the file list...\n")
       self.generating_file_list_flg = 1
       lock=thread.allocate_lock()
       thread.start_new_thread( self.open_text_file, (dirfilename,lock) )
    def evt_popup_directory_window(self):
        if self.generating_file_list_flg == 1: return
        dialog_icon = tkFileDialog.Directory(
            master=self.parent.control_frame2,
            title='Directory and File Selection')
        dirfilename = dialog_icon.show(initialdir=os.getcwd())
        if dirfilename in [(), '']: return

        self.stop_listing_flg = 0

        self.extension = []
        self.parent.extension.append(
            (self.data_filter._entryfield.get().split()[-1]))

        # Set up the thread to do asynchronous I/O
        self.stop_listing_flg = 0

        self.parent.parent.busyCursor = 'watch'
        self.parent.parent.busyWidgets = [
            self.parent.parent.pane2.pane('EditPaneTop')
        ]
        # note this busy cursor is reset in the method myfun3
        pub_busy.busyStart(self.parent.parent)

        # Remove the old list
        if self.parent.parent.file_counter > 0:
            self.parent.parent.pub_editorviewer.sf.destroy()
            self.parent.parent.pub_editorviewer = pub_editorviewer.create_publisher_editor_viewer(
                self.parent.parent)

        self.parent.parent.log_window.appendtext("Creating the file list...\n")
        self.generating_file_list_flg = 1
        lock = thread.allocate_lock()
        thread.start_new_thread(self.myfun3, (dirfilename, lock))
    def evt_popup_directory_window( self ):
       if self.generating_file_list_flg == 1: return
       dialog_icon = tkFileDialog.Directory(master=self.parent.control_frame2,
                         title = 'Directory and File Selection')
       dirfilename=dialog_icon.show(initialdir=os.getcwd())
       if dirfilename in [(), '']: return

       self.stop_listing_flg = 0

       self.extension = []
       self.parent.extension.append( (self.data_filter._entryfield.get().split()[-1]) )

       # Set up the thread to do asynchronous I/O
       self.stop_listing_flg = 0

       self.parent.parent.busyCursor = 'watch'
       self.parent.parent.busyWidgets = [self.parent.parent.pane2.pane( 'EditPaneTop' )]
       # note this busy cursor is reset in the method myfun3
       pub_busy.busyStart(self.parent.parent)

       # Remove the old list
       if self.parent.parent.file_counter > 0:
          self.parent.parent.pub_editorviewer.sf.destroy()
          self.parent.parent.pub_editorviewer = pub_editorviewer.create_publisher_editor_viewer( self.parent.parent )

       self.parent.parent.log_window.appendtext("Creating the file list...\n")
       self.generating_file_list_flg = 1
       lock=thread.allocate_lock()
       thread.start_new_thread( self.myfun3, (dirfilename,lock) )
Beispiel #5
0
    def evt_popup_file_window(self):
        # Reset the button colors
        self.cw_dir.configure(background=self.save_dir_btn_color,
                              foreground='black')
        self.cw_file.configure(background=self.save_file_btn_color,
                               foreground='black')
        self.cw_reg.configure(background=self.save_reg_btn_color,
                              foreground='black')

        if self.generating_file_list_flg == 1: return
        dialog_icon = tkFileDialog.Open(master=self.parent.control_frame2,
                                        filetypes=pub_controls.filetypes,
                                        title='File Open Selection')
        dirfilename = dialog_icon.show(initialdir=os.getcwd())
        if dirfilename in [(), '']: return

        # Determine if working online or off-line
        if self.parent.parent.offline == True:
            onoff_line = "offline"
        else:
            onoff_line = "online"

        # Start the busy routine to indicate to the users something is happening
        self.parent.parent.busyCursor = 'watch'
        self.parent.parent.busyWidgets = [
            self.parent.parent.pane2.pane('EditPaneTop'),
            self.parent.parent.pane2.pane('EditPaneBottom'),
            self.parent.parent.pane2.pane('EditPaneStatus'),
            self.parent.parent.pane.pane('ControlPane')
        ]
        pub_busy.busyStart(self.parent.parent)
        try:
            # Change the color of the selected button
            bcolorbg = Pmw.Color.changebrightness(self.parent.parent,
                                                  'aliceblue', 0.25)
            bcolorfg = Pmw.Color.changebrightness(self.parent.parent,
                                                  'aliceblue', 0.85)
            self.cw_file.configure(background=bcolorbg, foreground=bcolorfg)

            # Load up the data information from data extraction. This must be done outside the start of the Thread.
            self.fill_in_data_information_file(dirfilename,
                                               onoff_line=onoff_line)

        except:
            pub_busy.busyEnd(
                self.parent.parent
            )  # catch here in order to turn off the busy cursor ganz
            raise
        finally:
            pub_busy.busyEnd(self.parent.parent)
#       pub_busy.busyEnd( self.parent.parent )

# Disable the "Data Publication" button
        self.parent.parent.pub_buttonexpansion.ControlButton3.configure(
            state='disabled')
Beispiel #6
0
 def evt_unselect_all_dataset(self, parent):
    # Start the busy routine to indicate to the users something is happening
    parent.busyCursor = 'watch'
    parent.busyWidgets = [parent.pane2.pane( 'EditPaneTop' ), parent.pane2.pane( 'EditPaneBottom' ), parent.pane2.pane( 'EditPaneStatus' ), parent.pane.pane( 'ControlPane' )]
    pub_busy.busyStart( parent )
    try:
       selected_page = parent.main_frame.selected_top_page
       if selected_page is not None:
          for x in parent.main_frame.top_page_id[selected_page]:
              parent.main_frame.top_page_id[selected_page][x].configure(relief = 'raised', background = 'salmon', image=self.off)
    except:
          pub_busy.busyEnd( parent )  # catch here in order to turn off the busy cursor ganz
          raise
    finally:
         pub_busy.busyEnd( parent )
    def evt_popup_file_window(self):
        # Reset the button colors
        self.cw_dir.configure(background=self.save_dir_btn_color, foreground="black")
        self.cw_file.configure(background=self.save_file_btn_color, foreground="black")
        self.cw_reg.configure(background=self.save_reg_btn_color, foreground="black")

        if self.generating_file_list_flg == 1:
            return
        dialog_icon = tkFileDialog.Open(
            master=self.parent.control_frame2, filetypes=pub_controls.filetypes, title="File Open Selection"
        )
        dirfilename = dialog_icon.show(initialdir=os.getcwd())
        if dirfilename in [(), ""]:
            return

        # Determine if working online or off-line
        if self.parent.parent.offline == True:
            onoff_line = "offline"
        else:
            onoff_line = "online"

        # Start the busy routine to indicate to the users something is happening
        self.parent.parent.busyCursor = "watch"
        self.parent.parent.busyWidgets = [
            self.parent.parent.pane2.pane("EditPaneTop"),
            self.parent.parent.pane2.pane("EditPaneBottom"),
            self.parent.parent.pane2.pane("EditPaneStatus"),
            self.parent.parent.pane.pane("ControlPane"),
        ]
        pub_busy.busyStart(self.parent.parent)
        try:
            # Change the color of the selected button
            bcolorbg = Pmw.Color.changebrightness(self.parent.parent, "aliceblue", 0.25)
            bcolorfg = Pmw.Color.changebrightness(self.parent.parent, "aliceblue", 0.85)
            self.cw_file.configure(background=bcolorbg, foreground=bcolorfg)

            # Load up the data information from data extraction. This must be done outside the start of the Thread.
            self.fill_in_data_information_file(dirfilename, onoff_line=onoff_line)

        except:
            pub_busy.busyEnd(self.parent.parent)  # catch here in order to turn off the busy cursor ganz
            raise
        finally:
            pub_busy.busyEnd(self.parent.parent)
        #       pub_busy.busyEnd( self.parent.parent )

        # Disable the "Data Publication" button
        self.parent.parent.pub_buttonexpansion.ControlButton3.configure(state="disabled")
    def start_update_extraction_button( self, append_status=False ):
       from esgcet.publish.utility import filelistIterator, directoryIterator
       from esgcet.publish.utility import StopEvent

      
       # To prevent unexplained core dumps, the scrollbar to the right and bottom must be removed
     
       try:
          from tkMessageBox   import askquestion, showerror
          ans = tkMessageBox.askquestion("Dataset Comments?", "For all new datasets, would you like to supply comments in an editor?")
          #ans = tkMessageBox.askokcancel("Dataset Comments?", "For all new datasets, would you like to supply comments in an editor?")
          ans1 = str(ans)  # since we get back a _tkinter.Tcl_Obj not a string we need to convert to test...ganz
        

          if (ans1 == 'yes' ):
            myeditor = comments_editor.EDITOR(self.parent)
            self.comments = myeditor.edit()
         
     #        for x in self.comments:
     #          print x

          self.parent.parent.log_output_window.configure(hscrollmode = 'none', vscrollmode = 'none')
       except:
          pass
   
       self.parent.did_start = True
       self.parent.parent.se = StopEvent()
       self.parent.parent.se.wait = False

       # Start the busy routine to indicate to the users something is happening
       self.parent.parent.busyCursor = 'watch'
       self.parent.parent.busyWidgets = [self.parent.parent.pane2.pane( 'EditPaneTop' ), self.parent.parent.pane2.pane( 'EditPaneBottom' ), self.parent.parent.pane2.pane( 'EditPaneStatus' ), self.parent.parent.pane.pane( 'ControlPane' )]
       pub_busy.busyStart( self.parent.parent )
       try:
          self.return_content2( appendOpt = append_status )

       except:
            pub_busy.busyEnd( self.parent.parent )  # catch here in order to turn off the busy cursor ganz
            raise
       finally:
           pub_busy.busyEnd( self.parent.parent )
Beispiel #9
0
 def evt_unselect_all_dataset(self, parent):
     # Start the busy routine to indicate to the users something is happening
     parent.busyCursor = 'watch'
     parent.busyWidgets = [
         parent.pane2.pane('EditPaneTop'),
         parent.pane2.pane('EditPaneBottom'),
         parent.pane2.pane('EditPaneStatus'),
         parent.pane.pane('ControlPane')
     ]
     pub_busy.busyStart(parent)
     try:
         selected_page = parent.main_frame.selected_top_page
         if selected_page is not None:
             for x in parent.main_frame.top_page_id[selected_page]:
                 parent.main_frame.top_page_id[selected_page][x].configure(
                     relief='raised', background='salmon', image=self.off)
     except:
         pub_busy.busyEnd(
             parent)  # catch here in order to turn off the busy cursor ganz
         raise
     finally:
         pub_busy.busyEnd(parent)
    def evt_popup_directory_window(self):
        # Reset the button colors
        self.cw_dir.configure(background=self.save_dir_btn_color, foreground="black")
        self.cw_file.configure(background=self.save_file_btn_color, foreground="black")
        # self.cw_reg.configure( background=self.save_reg_btn_color, foreground='black' )

        # Start the busy routine to indicate to the users something is happening
        self.parent.parent.busyCursor = "watch"
        self.parent.parent.busyWidgets = [
            self.parent.parent.pane2.pane("EditPaneTop"),
            self.parent.parent.pane2.pane("EditPaneBottom"),
            self.parent.parent.pane2.pane("EditPaneStatus"),
            self.parent.parent.pane.pane("ControlPane"),
        ]
        pub_busy.busyStart(self.parent.parent)

        try:
            # if true, then the dataset is not directly readable and on tertiary storage
            if self.parent.parent.offline == True:
                onoff_line = "offline"
                dirfilename = None
                # Create the dialog to prompt for the entry input
                self.dialog = Pmw.Dialog(
                    self.parent.control_frame2,
                    title="Working off-line",
                    buttons=("OK", "Cancel"),
                    defaultbutton="OK",
                    command=pub_controls.Command(self.evt_work_off_line_directory),
                )

                self.entry1 = Pmw.EntryField(
                    self.dialog.interior(),
                    labelpos="w",
                    label_text="Directory:",
                    entry_width=75,
                    entry_background="aliceblue",
                    entry_foreground="black",
                )
                self.entry1.pack(side="top", fill="x", expand=1, padx=10, pady=5)
                self.entry2 = Pmw.EntryField(
                    self.dialog.interior(),
                    labelpos="w",
                    label_text="Dataset Name:",
                    entry_width=75,
                    entry_background="aliceblue",
                    entry_foreground="black",
                )
                self.entry2.pack(side="top", fill="x", expand=1, padx=10, pady=5)

                Pmw.alignlabels((self.entry1, self.entry2))

                parent_geom = self.parent.parent.geometry()
                geom = string.split(parent_geom, "+")
                d1 = string.atoi(geom[1])
                d2 = string.atoi(geom[2])
                p1 = string.atoi(geom[0].split("x")[0]) * 0.3
                p2 = string.atoi(geom[0].split("x")[1]) * 0.3
                self.dialog.activate(geometry="+%d+%d" % (p1 + d1, p2 + d2))
                if self.parent.parent.offline_directories != "Cancel":
                    # Load up the data information from data extraction
                    self.fill_in_data_information_directory(dirfilename, True, onoff_line=onoff_line)
            else:
                onoff_line = "online"
                if self.generating_file_list_flg == 1:
                    return
                dialog_icon = tkFileDialog.Directory(
                    master=self.parent.control_frame2, title="Directory and File Selection"
                )
                dirfilename = dialog_icon.show(initialdir=os.getcwd())
                if dirfilename in [(), ""]:
                    pub_busy.busyEnd(self.parent.parent)
                    return

                self.stop_listing_flg = 0

                self.parent.parent.extension = []
                self.parent.parent.extension.append((self.data_filter._entryfield.get().split()[-1]))

                # Load up the data information from data extraction
                self.fill_in_data_information_directory(dirfilename, True, onoff_line=onoff_line)

            # Change the color of the selected button
            bcolorbg = Pmw.Color.changebrightness(self.parent.parent, "aliceblue", 0.25)
            bcolorfg = Pmw.Color.changebrightness(self.parent.parent, "aliceblue", 0.85)
            self.cw_dir.configure(background=bcolorbg, foreground=bcolorfg)

        #
        except:
            pub_busy.busyEnd(self.parent.parent)  # catch here in order to turn off the busy cursor ganz
            raise
        finally:
            pub_busy.busyEnd(self.parent.parent)
        #
        #       pub_busy.busyEnd( self.parent.parent )

        # Disable the "Data Publication" button
        self.parent.parent.pub_buttonexpansion.ControlButton3.configure(state="disabled")
Beispiel #11
0
    def evt_popup_directory_window(self):
        # Reset the button colors
        self.cw_dir.configure(background=self.save_dir_btn_color,
                              foreground='black')
        self.cw_file.configure(background=self.save_file_btn_color,
                               foreground='black')
        #self.cw_reg.configure( background=self.save_reg_btn_color, foreground='black' )

        # Start the busy routine to indicate to the users something is happening
        self.parent.parent.busyCursor = 'watch'
        self.parent.parent.busyWidgets = [
            self.parent.parent.pane2.pane('EditPaneTop'),
            self.parent.parent.pane2.pane('EditPaneBottom'),
            self.parent.parent.pane2.pane('EditPaneStatus'),
            self.parent.parent.pane.pane('ControlPane')
        ]
        pub_busy.busyStart(self.parent.parent)

        try:
            # if true, then the dataset is not directly readable and on tertiary storage
            if self.parent.parent.offline == True:
                onoff_line = "offline"
                dirfilename = None
                # Create the dialog to prompt for the entry input
                self.dialog = Pmw.Dialog(
                    self.parent.control_frame2,
                    title='Working off-line',
                    buttons=('OK', 'Cancel'),
                    defaultbutton='OK',
                    command=pub_controls.Command(
                        self.evt_work_off_line_directory, ),
                )

                self.entry1 = Pmw.EntryField(
                    self.dialog.interior(),
                    labelpos='w',
                    label_text='Directory:',
                    entry_width=75,
                    entry_background='aliceblue',
                    entry_foreground='black',
                )
                self.entry1.pack(side='top',
                                 fill='x',
                                 expand=1,
                                 padx=10,
                                 pady=5)
                self.entry2 = Pmw.EntryField(
                    self.dialog.interior(),
                    labelpos='w',
                    label_text='Dataset Name:',
                    entry_width=75,
                    entry_background='aliceblue',
                    entry_foreground='black',
                )
                self.entry2.pack(side='top',
                                 fill='x',
                                 expand=1,
                                 padx=10,
                                 pady=5)

                Pmw.alignlabels((self.entry1, self.entry2))

                parent_geom = self.parent.parent.geometry()
                geom = string.split(parent_geom, '+')
                d1 = string.atoi(geom[1])
                d2 = string.atoi(geom[2])
                p1 = string.atoi(geom[0].split('x')[0]) * 0.3
                p2 = string.atoi(geom[0].split('x')[1]) * 0.3
                self.dialog.activate(geometry="+%d+%d" % (p1 + d1, p2 + d2))
                if self.parent.parent.offline_directories != "Cancel":
                    # Load up the data information from data extraction
                    self.fill_in_data_information_directory(
                        dirfilename, True, onoff_line=onoff_line)
            else:
                onoff_line = "online"
                if self.generating_file_list_flg == 1: return
                dialog_icon = tkFileDialog.Directory(
                    master=self.parent.control_frame2,
                    title='Directory and File Selection')
                dirfilename = dialog_icon.show(initialdir=os.getcwd())
                if dirfilename in [(), '']:
                    pub_busy.busyEnd(self.parent.parent)
                    return

                self.stop_listing_flg = 0

                self.parent.parent.extension = []
                self.parent.parent.extension.append(
                    (self.data_filter._entryfield.get().split()[-1]))

                # Load up the data information from data extraction
                self.fill_in_data_information_directory(dirfilename,
                                                        True,
                                                        onoff_line=onoff_line)

        # Change the color of the selected button
            bcolorbg = Pmw.Color.changebrightness(self.parent.parent,
                                                  'aliceblue', 0.25)
            bcolorfg = Pmw.Color.changebrightness(self.parent.parent,
                                                  'aliceblue', 0.85)
            self.cw_dir.configure(background=bcolorbg, foreground=bcolorfg)

#
        except:
            pub_busy.busyEnd(
                self.parent.parent
            )  # catch here in order to turn off the busy cursor ganz
            raise
        finally:
            pub_busy.busyEnd(self.parent.parent)
#
#       pub_busy.busyEnd( self.parent.parent )

# Disable the "Data Publication" button
        self.parent.parent.pub_buttonexpansion.ControlButton3.configure(
            state='disabled')
    def new_query_page(self, parent, tab_name=None, query_id=None):
        # Start the busy routine to indicate to the users something is happening

        self.parent.parent.busyCursor = "watch"
        self.parent.parent.busyWidgets = [
            self.parent.parent.pane2.pane("EditPaneTop"),
            self.parent.parent.pane2.pane("EditPaneBottom"),
            self.parent.parent.pane2.pane("EditPaneStatus"),
            self.parent.parent.pane.pane("ControlPane"),
        ]
        pub_busy.busyStart(self.parent.parent)

        try:
            properties = {}
            projectName = self.parent.query_fields["project"].get()  # Must have projectName
            handler = getHandlerByName(projectName, None, self.Session)
            tabcolor = Pmw.Color.changebrightness(self.parent.parent, pub_controls.query_tab_color, 0.6)

            # works up to here

            if query_id is None:
                for x in self.parent.query_fields.keys():
                    query_string = self.parent.query_fields[x].get().lstrip()
                    if (query_string == "-Any-") or (len(query_string) == 0):
                        properties[x] = (2, "%")
                    elif query_string != "-Any-":
                        properties[x] = (1, query_string)

                if properties["id"] == (2, "%"):
                    del properties["id"]  # This causes an error because you cannot modify the 'id'

                listProperties = False

                result, headers = queryDatasets(projectName, handler, self.Session, properties)
                # works up to here

                # running this causes it to fail!
                self.new_page(
                    parent,
                    tabName=None,
                    tab_color=tabcolor,
                    page_type="query",
                    query_result=result,
                    list_fields=headers,
                )

            else:
                result, headers = queryDatasets(projectName, handler, self.Session, properties)
                for x in result:
                    query_id_found = False
                    if query_id == x[0][:-1]:
                        self.new_page(
                            parent,
                            tabName=None,
                            tab_color=tabcolor,
                            page_type="query",
                            query_result=[x],
                            list_fields=headers,
                        )
                        query_id_found = True
                        break
                if query_id_found is False:
                    warning("The specified dataset id '%s' was not found.", query_id)

            # fails here

            # Enable the "Data Publication" button
            self.parent.ControlButton3.configure(state="normal")

            datasetNames = []
            for x in result:
                datasetNames.append(x[1])
            dmap, offline_map, extraFields = queryDatasetMap(datasetNames, self.Session, extra_fields=True)
            # Check if offline or not, then set the iteration values for each page

            selected_page = self.parent.parent.main_frame.selected_top_page
            self.parent.parent.hold_offline[selected_page] = offline_map
            self.parent.parent.main_frame.projectName[selected_page] = projectName
            self.parent.parent.main_frame.dmap[selected_page] = dmap
            self.parent.parent.main_frame.extraFields[selected_page] = extraFields
            self.parent.parent.main_frame.datasetMapfile[selected_page] = None
            self.parent.parent.directoryMap[selected_page] = None
            self.parent.parent.main_frame.dirp_firstfile[selected_page] = None
            self.parent.parent.defaultGlobalValues[selected_page] = {}

        except:
            pub_busy.busyEnd(self.parent.parent)  # catch here in order to turn off the busy cursor ganz
            raise
        finally:
            pub_busy.busyEnd(self.parent.parent)
Beispiel #13
0
   def evt_remove_dataset(self, parent):
      from esgcet.publish import pollDatasetPublicationStatus

      # Start the busy routine to indicate to the users something is happening
      parent.busyCursor = 'watch'
      parent.busyWidgets = [parent.pane2.pane( 'EditPaneTop' ), parent.pane2.pane( 'EditPaneBottom' ), parent.pane2.pane( 'EditPaneStatus' ), parent.pane.pane( 'ControlPane' )]
      pub_busy.busyStart( parent )

      datasetNames = []
      GUI_line = {}
      DELETE = 1
      #UNPUBLISH = 2
      NO_OPERATION = 3
      DeleteLocalDB = pub_expand_deletion_control_gui.deletion_widgets.get_CheckBox1() #   DeleteLocalDB 
      DeleteGateway = pub_expand_deletion_control_gui.deletion_widgets.get_CheckBox2() #   DeleteGateway
      DeleteThredds = pub_expand_deletion_control_gui.deletion_widgets.get_CheckBox3() #   DeleteThredds


      selected_page = parent.main_frame.selected_top_page
      if selected_page is not None:
         tab_name = parent.top_notebook.getcurselection()
         for x in parent.main_frame.top_page_id[selected_page]:
            if parent.main_frame.top_page_id[selected_page][x].cget('bg') != 'salmon' and parent.main_frame.top_page_id2[selected_page][x].cget('bg') != 'salmon':
                dset_name = parent.main_frame.top_page_id2[selected_page][x].cget('text')
                               
                #dsetVersionName1 = self.parent.parent.main_frame.top_page_id2v[selected_page][x].cget('text')
                #query_name, dset_version = parseDatasetVersionId(dsetVersionName1)
                """ ganz I am modifying this so that if a user selects a dataset without a version then we delete all versions of that dataset"""
                try:
                    dset_version = parent.main_frame.version_label[selected_page][x].cget('text')
                except:
                    dset_version = -1
                    #print 'Delete all versions'   
                #dset_version = 1
                if (dset_version == 'N/A' or not dset_version):
                    dset_version = -1
                    # continue   # not published, yet
                # Only delete published events
                status = pollDatasetPublicationStatus(dset_name, self.Session)
                if status == 3  or DeleteGateway or DeleteThredds or DeleteLocalDB:
                   #datasetNames.append(generateDatasetVersionId((dset_name, dset_version)))   
                   datasetNames.append([dset_name, dset_version])   # ganz create name/version to delete                 
                else:
                   parent.main_frame.top_page_id[selected_page][x].configure(relief = 'raised', background = 'salmon', image = self.off)
                GUI_line[ dset_name ] = x
            else:
                if parent.main_frame.top_page_id2[selected_page][x].cget('bg') == 'salmon':
                   parent.main_frame.top_page_id[selected_page][x].configure(relief = 'raised', background = 'salmon', image = self.off)
      else:
         warning("%d: No pages generated for selection. Remove is only used to remove datasets from the Publisher." % logging.WARNING)

      # Remove dataset from the gateway, etc.
      if ((DeleteGateway==0 or DeleteThredds==0) and DeleteLocalDB==1) :
          ans = self.warn_On_Removal()
          if (ans == FALSE):
              return
      
      if DeleteGateway==1:
          gatewayOp = DELETE
      else:
          gatewayOp = NO_OPERATION
    # now decide if there is anything to do
      if (gatewayOp==1 or DeleteThredds==1 or DeleteLocalDB==1) :   
          las=False
          thredds = (DeleteThredds==1)              
          deleteDset = (DeleteLocalDB==1)
              
          testProgress = (parent.parent.statusbar.show, 0, 100)
          status_dict = deleteDatasetList(datasetNames, self.Session, gatewayOp, thredds, las, deleteDset, progressCallback=testProgress)


      # Show the published status
      try:
         for x in status_dict.keys():
            status = status_dict[ x ]
            parent.main_frame.status_label[selected_page][GUI_line[x]].configure(text=pub_controls.return_status_text( status) )
      except:
         pass

      pub_busy.busyEnd( parent )
      # ganz refresh [if there were no exceptions] dataset list after deletions 
      parent.pub_buttonexpansion.query_widgets.parent.parent.ntk.evt_refresh_list_of_datasets(selected_page )
    def start_harvest( self, parent ):
        from esgcet.publish import publishDatasetList
        from esgcet.model import Dataset, PUBLISH_FAILED_EVENT, ERROR_LEVEL

        dcolor1 = Pmw.Color.changebrightness(self.parent.parent, 'aliceblue', 0.8 )

        # Make sure the publisher is logged in
       # if not self.parent.parent.password_flg:
       #    self.parent.parent.menu.login_menu.evt_login( self.parent.parent )

        # Start the busy routine to indicate to the users something is happening
        self.parent.parent.busyCursor = 'watch'
        self.parent.parent.busyWidgets = [self.parent.parent.pane2.pane( 'EditPaneTop' ), self.parent.parent.pane2.pane( 'EditPaneBottom' ), self.parent.parent.pane2.pane( 'EditPaneStatus' ), self.parent.parent.pane.pane( 'ControlPane' )]
        pub_busy.busyStart( self.parent.parent )
        try:
        # Generate the list of datasets to be published
           datasetNames=[]
           GUI_line = {}
           tab_name = self.parent.parent.top_notebook.getcurselection()
           selected_page = self.parent.parent.main_frame.selected_top_page

           if (selected_page is None):
              warning("Must generate a list of datasets to scan before publishing can occur.")
              pub_busy.busyEnd( self.parent.parent )
              return

           for x in self.parent.parent.main_frame.top_page_id[selected_page]:

               if self.parent.parent.main_frame.top_page_id[selected_page][x].cget('bg') != 'salmon' and self.parent.parent.main_frame.top_page_id2[selected_page][x].cget('bg') != 'salmon':
                   dset_name = self.parent.parent.main_frame.top_page_id2[selected_page][x].cget('text')
                #######################################
                                  # ganz added this 1/18/11    
                   versionNum = self.parent.parent.main_frame.version_label[selected_page][x].cget('text') 
                   dsetTuple = (dset_name, versionNum)
                #dsetName = generateDatasetVersionId(dsetTuple)                
                  #####################################################################################
                # dsetTuple = parseDatasetVersionId(dset_name) # ganz no longer necessary
                   datasetNames.append(dsetTuple)
                   GUI_line[ dset_name ] = x
               else:
                   if self.parent.parent.main_frame.top_page_id2[selected_page][x].cget('bg') == 'salmon':
                      self.parent.parent.main_frame.top_page_id[selected_page][x].configure(relief = 'raised', background = 'salmon', image = self.off)

        # Publish collection of datasets
           testProgress = (self.parent.parent.statusbar.show, 0, 100)
           publishThredds = (quality_control_widgets.get_CheckBox3()==1)
           publishGateway = (quality_control_widgets.get_CheckBox2()==1)
           if (publishThredds):
               print 'publishing to Thredds'
           if (publishGateway):
               print 'publishing to Gateway'  
                      
           status_dict = publishDatasetList(datasetNames, self.Session, publish=publishGateway, thredds=publishThredds, progressCallback=testProgress)

        # Show the published status
           for x in status_dict.keys():
                status = status_dict[ x ]
                dsetName, versionNo = x
                dsetVersionName = generateDatasetVersionId(x)
                guiLine = GUI_line[dsetName] # dsetVersionName]
            
                self.parent.parent.main_frame.status_label[selected_page][guiLine].configure(text=pub_controls.return_status_text( status) )
                dset = Dataset.lookup(dsetName, self.Session)
                if dset.has_warnings(self.Session):
                    warningLevel = dset.get_max_warning_level(self.Session)
                    if warningLevel>=ERROR_LEVEL:
                        buttonColor = "pink"
                        buttonText = "Error"
                    else:
                        buttonColor = "yellow"
                        buttonText = "Warning"
                    self.parent.parent.main_frame.ok_err[selected_page][guiLine].configure(
                        text = buttonText,
                        bg = buttonColor,
                        relief = 'raised',
                        command = pub_controls.Command( self.parent.parent.pub_buttonexpansion.extraction_widgets.error_extraction_button, dset ) )
                else:
                    self.parent.parent.main_frame.ok_err[selected_page][guiLine].configure(
                        text = 'Ok',
                        bg = dcolor1,
                        highlightcolor = dcolor1,
                        relief = 'sunken',
                        )
        except:
            pub_busy.busyEnd( self.parent.parent )  # catch here in order to turn off the busy cursor ganz
            raise
        finally:
           pub_busy.busyEnd( self.parent.parent )
           self.my_refresh()
Beispiel #15
0
    def evt_remove_dataset(self, parent):
        from esgcet.publish import pollDatasetPublicationStatus

        # Start the busy routine to indicate to the users something is happening
        parent.busyCursor = 'watch'
        parent.busyWidgets = [
            parent.pane2.pane('EditPaneTop'),
            parent.pane2.pane('EditPaneBottom'),
            parent.pane2.pane('EditPaneStatus'),
            parent.pane.pane('ControlPane')
        ]
        pub_busy.busyStart(parent)

        datasetNames = []
        GUI_line = {}
        DELETE = 1
        #UNPUBLISH = 2
        NO_OPERATION = 3
        DeleteLocalDB = pub_expand_deletion_control_gui.deletion_widgets.get_CheckBox1(
        )  #   DeleteLocalDB
        DeleteGateway = pub_expand_deletion_control_gui.deletion_widgets.get_CheckBox2(
        )  #   DeleteGateway
        DeleteThredds = pub_expand_deletion_control_gui.deletion_widgets.get_CheckBox3(
        )  #   DeleteThredds

        selected_page = parent.main_frame.selected_top_page
        if selected_page is not None:
            tab_name = parent.top_notebook.getcurselection()
            for x in parent.main_frame.top_page_id[selected_page]:
                if parent.main_frame.top_page_id[selected_page][x].cget(
                        'bg') != 'salmon' and parent.main_frame.top_page_id2[
                            selected_page][x].cget('bg') != 'salmon':
                    dset_name = parent.main_frame.top_page_id2[selected_page][
                        x].cget('text')

                    #dsetVersionName1 = self.parent.parent.main_frame.top_page_id2v[selected_page][x].cget('text')
                    #query_name, dset_version = parseDatasetVersionId(dsetVersionName1)
                    """ ganz I am modifying this so that if a user selects a dataset without a version then we delete all versions of that dataset"""
                    try:
                        dset_version = parent.main_frame.version_label[
                            selected_page][x].cget('text')
                    except:
                        dset_version = -1
                        #print 'Delete all versions'
                    #dset_version = 1
                    if (dset_version == 'N/A' or not dset_version):
                        dset_version = -1
                        # continue   # not published, yet
                    # Only delete published events
                    status = pollDatasetPublicationStatus(
                        dset_name, self.Session)
                    if status == 3 or DeleteGateway or DeleteThredds or DeleteLocalDB:
                        #datasetNames.append(generateDatasetVersionId((dset_name, dset_version)))
                        datasetNames.append([
                            dset_name, dset_version
                        ])  # ganz create name/version to delete
                    else:
                        parent.main_frame.top_page_id[selected_page][
                            x].configure(relief='raised',
                                         background='salmon',
                                         image=self.off)
                    GUI_line[dset_name] = x
                else:
                    if parent.main_frame.top_page_id2[selected_page][x].cget(
                            'bg') == 'salmon':
                        parent.main_frame.top_page_id[selected_page][
                            x].configure(relief='raised',
                                         background='salmon',
                                         image=self.off)
        else:
            warning(
                "%d: No pages generated for selection. Remove is only used to remove datasets from the Publisher."
                % logging.WARNING)

        # Remove dataset from the gateway, etc.
        if ((DeleteGateway == 0 or DeleteThredds == 0) and DeleteLocalDB == 1):
            ans = self.warn_On_Removal()
            if (ans == FALSE):
                return

        if DeleteGateway == 1:
            gatewayOp = DELETE
        else:
            gatewayOp = NO_OPERATION

    # now decide if there is anything to do
        if (gatewayOp == 1 or DeleteThredds == 1 or DeleteLocalDB == 1):
            las = False
            thredds = (DeleteThredds == 1)
            deleteDset = (DeleteLocalDB == 1)

            testProgress = (parent.parent.statusbar.show, 0, 100)
            status_dict = deleteDatasetList(datasetNames,
                                            self.Session,
                                            gatewayOp,
                                            thredds,
                                            las,
                                            deleteDset,
                                            progressCallback=testProgress)

        # Show the published status
        try:
            for x in status_dict.keys():
                status = status_dict[x]
                parent.main_frame.status_label[selected_page][
                    GUI_line[x]].configure(
                        text=pub_controls.return_status_text(status))
        except:
            pass

        pub_busy.busyEnd(parent)
        # ganz refresh [if there were no exceptions] dataset list after deletions
        parent.pub_buttonexpansion.query_widgets.parent.parent.ntk.evt_refresh_list_of_datasets(
            selected_page)
    def start_harvest(self, parent):
        from esgcet.publish import publishDatasetList
        from esgcet.model import Dataset, PUBLISH_FAILED_EVENT, ERROR_LEVEL

        dcolor1 = Pmw.Color.changebrightness(self.parent.parent, 'aliceblue',
                                             0.8)

        # Make sure the publisher is logged in
        # if not self.parent.parent.password_flg:
        #    self.parent.parent.menu.login_menu.evt_login( self.parent.parent )

        # Start the busy routine to indicate to the users something is happening
        self.parent.parent.busyCursor = 'watch'
        self.parent.parent.busyWidgets = [
            self.parent.parent.pane2.pane('EditPaneTop'),
            self.parent.parent.pane2.pane('EditPaneBottom'),
            self.parent.parent.pane2.pane('EditPaneStatus'),
            self.parent.parent.pane.pane('ControlPane')
        ]
        pub_busy.busyStart(self.parent.parent)
        try:
            # Generate the list of datasets to be published
            datasetNames = []
            GUI_line = {}
            tab_name = self.parent.parent.top_notebook.getcurselection()
            selected_page = self.parent.parent.main_frame.selected_top_page

            if (selected_page is None):
                warning(
                    "Must generate a list of datasets to scan before publishing can occur."
                )
                pub_busy.busyEnd(self.parent.parent)
                return

            for x in self.parent.parent.main_frame.top_page_id[selected_page]:

                if self.parent.parent.main_frame.top_page_id[selected_page][x].cget(
                        'bg'
                ) != 'salmon' and self.parent.parent.main_frame.top_page_id2[
                        selected_page][x].cget('bg') != 'salmon':
                    dset_name = self.parent.parent.main_frame.top_page_id2[
                        selected_page][x].cget('text')
                    #######################################
                    # ganz added this 1/18/11
                    versionNum = self.parent.parent.main_frame.version_label[
                        selected_page][x].cget('text')
                    dsetTuple = (dset_name, versionNum)
                    #dsetName = generateDatasetVersionId(dsetTuple)
                    #####################################################################################
                    # dsetTuple = parseDatasetVersionId(dset_name) # ganz no longer necessary
                    datasetNames.append(dsetTuple)
                    GUI_line[dset_name] = x
                else:
                    if self.parent.parent.main_frame.top_page_id2[
                            selected_page][x].cget('bg') == 'salmon':
                        self.parent.parent.main_frame.top_page_id[
                            selected_page][x].configure(relief='raised',
                                                        background='salmon',
                                                        image=self.off)

        # Publish collection of datasets
            testProgress = (self.parent.parent.statusbar.show, 0, 100)
            publishThredds = (quality_control_widgets.get_CheckBox3() == 1)
            publishGateway = (quality_control_widgets.get_CheckBox2() == 1)
            if (publishThredds):
                print 'publishing to Thredds'
            if (publishGateway):
                print 'publishing to Gateway'

            status_dict = publishDatasetList(datasetNames,
                                             self.Session,
                                             publish=publishGateway,
                                             thredds=publishThredds,
                                             progressCallback=testProgress)

            # Show the published status
            for x in status_dict.keys():
                status = status_dict[x]
                dsetName, versionNo = x
                dsetVersionName = generateDatasetVersionId(x)
                guiLine = GUI_line[dsetName]  # dsetVersionName]

                self.parent.parent.main_frame.status_label[selected_page][
                    guiLine].configure(
                        text=pub_controls.return_status_text(status))
                dset = Dataset.lookup(dsetName, self.Session)
                if dset.has_warnings(self.Session):
                    warningLevel = dset.get_max_warning_level(self.Session)
                    if warningLevel >= ERROR_LEVEL:
                        buttonColor = "pink"
                        buttonText = "Error"
                    else:
                        buttonColor = "yellow"
                        buttonText = "Warning"
                    self.parent.parent.main_frame.ok_err[selected_page][
                        guiLine].configure(
                            text=buttonText,
                            bg=buttonColor,
                            relief='raised',
                            command=pub_controls.Command(
                                self.parent.parent.pub_buttonexpansion.
                                extraction_widgets.error_extraction_button,
                                dset))
                else:
                    self.parent.parent.main_frame.ok_err[selected_page][
                        guiLine].configure(
                            text='Ok',
                            bg=dcolor1,
                            highlightcolor=dcolor1,
                            relief='sunken',
                        )
        except:
            pub_busy.busyEnd(
                self.parent.parent
            )  # catch here in order to turn off the busy cursor ganz
            raise
        finally:
            pub_busy.busyEnd(self.parent.parent)
            self.my_refresh()
    def evt_refresh_list_of_datasets(self, selected_page):

        # Start the busy routine to indicate to the users something is happening
        self.parent.parent.busyCursor = "watch"
        self.parent.parent.busyWidgets = [
            self.parent.parent.pane2.pane("EditPaneTop"),
            self.parent.parent.pane2.pane("EditPaneBottom"),
            self.parent.parent.pane2.pane("EditPaneStatus"),
            self.parent.parent.pane.pane("ControlPane"),
        ]
        pub_busy.busyStart(self.parent.parent)

        try:
            if self.parent.parent.refreshButton[selected_page].cget("relief") == "raised":
                for x in self.parent.parent.main_frame.top_page_id[selected_page]:
                    if self.parent.parent.main_frame.top_page_id[selected_page][x].cget("relief") == "raised":
                        dsetVersionName = self.parent.parent.main_frame.top_page_id2[selected_page][x].cget("text")

                        # ganz added this 1/18/11
                        query_name = self.parent.parent.main_frame.top_page_id2[selected_page][x].cget("text")
                        versionNum = self.parent.parent.main_frame.version_label[selected_page][x].cget("text")
                        #####################################################################################

                        query_name, versionNum = parseDatasetVersionId(dsetVersionName)
                        # ganz TODO test only remove
                        #                  print query_name
                        #                  print versionNum

                        status = pollDatasetPublicationStatus(query_name, self.Session)
                        # ganz catch non selected Red entries to skip 3/20/2011
                        try:
                            self.parent.parent.main_frame.status_label[selected_page][x].configure(
                                text=pub_controls.return_status_text(status)
                            )
                        except:
                            continue

                        # Make sure you update the Ok/Err button
                        # ganz added this (1/18/11) here to catch the case when dset=None (e.g. no local db entry exists)
                        dset = Dataset.lookup(query_name, self.Session)
                        if dset == None:
                            buttonColor = "yellow"
                            buttonText = "Warning"
                            self.parent.parent.main_frame.ok_err[selected_page][x].configure(
                                bg=buttonColor, text=buttonText
                            )
                        elif dset.has_warnings(self.Session):
                            warningLevel = dset.get_max_warning_level(self.Session)
                            if warningLevel >= ERROR_LEVEL:
                                buttonColor = "pink"
                                buttonText = "Error"
                            else:
                                buttonColor = "yellow"
                                buttonText = "Warning"
                            self.parent.parent.main_frame.ok_err[selected_page][x].configure(
                                bg=buttonColor, text=buttonText
                            )
        except:
            pub_busy.busyEnd(self.parent.parent)  # catch here in order to turn off the busy cursor ganz
            raise
        finally:
            pub_busy.busyEnd(self.parent.parent)
        #  pub_busy.busyEnd( self.parent.parent )
        info("Completed refreshing the display.")