Beispiel #1
0
    def on_ok(self, e):

        # Check for valid input

        location = self.tc_directory.GetValue()
        dir = os.path.normpath(location)
        name = self.tc_name.GetValue()
        expr = expression.map_tag_name(self.tc_expression.GetValue(),
                                       tagging.tag_name_to_id)

        if "?" in expr:
            wx.MessageBox(
                ("One or more of the tags in the specified expression "
                 "does not exist. Please create them first, "
                 "or change the expression."), "Error")
            return

        if self.rb_softlinks.GetValue():
            softlink = True
        else:
            softlink = False
        output.change_link_type(self.folder_id, True, softlink)

        if (name == ""):
            wx.MessageBox('Please enter a name!', 'Error',
                          wx.OK | wx.ICON_EXCLAMATION)

            return

        if (expr == ""):
            wx.MessageBox('Please enter an expression!', 'Error',
                          wx.OK | wx.ICON_EXCLAMATION)

            return

        if (location == ""):
            wx.MessageBox('Please enter a location!', 'Error',
                          wx.OK | wx.ICON_EXCLAMATION)

            return

        if (not os.path.exists(dir) or not os.path.isdir(dir)):
            wx.MessageBox('Invalid location!', 'Error',
                          wx.OK | wx.ICON_EXCLAMATION)

            return

        # TODO: Implement relevent output functions
        output.move(self.folder_id, True, dir)
        output.rename(self.folder_id, True, name)
        output.change_expression(self.folder_id, expr)

        # Exit
        self.Close()
Beispiel #2
0
    def on_ok(self, e):

        # Check for valid input

        location = self.tc_directory.GetValue()
        dir = os.path.normpath(location)
        name = self.tc_name.GetValue()
        expr = expression.map_tag_name(self.tc_expression.GetValue(),
                                       tagging.tag_name_to_id)

        if "?" in expr:
            wx.MessageBox(
                ("One or more of the tags in the specified expression "
                 "does not exist. Please create them first, "
                 "or change the expression."), "Error")
            return

        if self.rb_softlinks.GetValue():
            softlink = 1
        else:
            softlink = 0

        if (name == ""):
            wx.MessageBox('Please enter a name!', 'Error',
                          wx.OK | wx.ICON_EXCLAMATION)

            return

        if (expr == ""):
            wx.MessageBox('Please enter an expression!', 'Error',
                          wx.OK | wx.ICON_EXCLAMATION)

            return

        if (location == ""):
            wx.MessageBox('Please enter a location!', 'Error',
                          wx.OK | wx.ICON_EXCLAMATION)

            return

        if (not os.path.exists(dir) or not os.path.isdir(dir)):
            wx.MessageBox('Invalid location!', 'Error',
                          wx.OK | wx.ICON_EXCLAMATION)

            return

        # Create database entry

        gallery_conn = database.get_current_gallery("connection")
        cursor = gallery_conn.cursor()

        query_insert_folder = ("INSERT INTO folder"
                               "(name, location, expression, use_softlink) "
                               "VALUES (\'%s\', \'%s\', \'%s\', %d)" %
                               (name, dir, expr, softlink))

        cursor.execute(query_insert_folder)
        gallery_conn.commit()

        # Create folders
        create_folders.create_folders()
        self.EndModal(0)
    def on_ok(self, e):

        # Check for valid input

        location = self.tc_directory.GetValue()
        dir = os.path.normpath(location)
        name = self.tc_name.GetValue()
        expr = expression.map_tag_name(self.tc_expression.GetValue(), tagging.tag_name_to_id)

        if "?" in expr:
            wx.MessageBox(
                (
                    "One or more of the tags in the specified expression "
                    "does not exist. Please create them first, "
                    "or change the expression."
                ),
                "Error",
            )
            return

        if self.rb_softlinks.GetValue():
            softlink = 1
        else:
            softlink = 0

        if name == "":
            wx.MessageBox("Please enter a name!", "Error", wx.OK | wx.ICON_EXCLAMATION)

            return

        if expr == "":
            wx.MessageBox("Please enter an expression!", "Error", wx.OK | wx.ICON_EXCLAMATION)

            return

        if location == "":
            wx.MessageBox("Please enter a location!", "Error", wx.OK | wx.ICON_EXCLAMATION)

            return

        if not os.path.exists(dir) or not os.path.isdir(dir):
            wx.MessageBox("Invalid location!", "Error", wx.OK | wx.ICON_EXCLAMATION)

            return

        # Create database entry

        gallery_conn = database.get_current_gallery("connection")
        cursor = gallery_conn.cursor()

        query_insert_folder = (
            "INSERT INTO folder"
            "(name, location, expression, use_softlink) "
            "VALUES ('%s', '%s', '%s', %d)" % (name, dir, expr, softlink)
        )

        cursor.execute(query_insert_folder)
        gallery_conn.commit()

        # Create folders
        create_folders.create_folders()
        self.EndModal(0)
    def on_ok(self, e):

        # Check for valid input

        location = self.tc_directory.GetValue()
        dir = os.path.normpath(location)
        name = self.tc_name.GetValue()
        expr = expression.map_tag_name(
            self.tc_expression.GetValue(),
            tagging.tag_name_to_id
        )

        if "?" in expr:
            wx.MessageBox(
                ("One or more of the tags in the specified expression "
                 "does not exist. Please create them first, "
                 "or change the expression."),
                "Error"
            )
            return

        if self.rb_softlinks.GetValue():
            softlink = True
        else:
            softlink = False
        output.change_link_type(self.folder_id, True, softlink)

        if(name == ""):
            wx.MessageBox(
                'Please enter a name!',
                'Error',
                wx.OK | wx.ICON_EXCLAMATION)

            return

        if(expr == ""):
            wx.MessageBox(
                'Please enter an expression!',
                'Error',
                wx.OK | wx.ICON_EXCLAMATION)

            return

        if(location == ""):
            wx.MessageBox(
                'Please enter a location!',
                'Error',
                wx.OK | wx.ICON_EXCLAMATION)

            return

        if(not os.path.exists(dir) or not os.path.isdir(dir)):
            wx.MessageBox(
                'Invalid location!',
                'Error',
                wx.OK | wx.ICON_EXCLAMATION)

            return

        # TODO: Implement relevent output functions
        output.move(self.folder_id, True, dir)
        output.rename(self.folder_id, True, name)
        output.change_expression(self.folder_id, expr)

        # Exit
        self.Close()