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()
def SaveSettings(self): # FIXME: Change name not working (under windows)? # Register folders # Get gallery connection gallery_conn = database.get_current_gallery("connection") cursor = gallery_conn.cursor() location = self.tc_directory.GetValue() name = self.tc_name.GetValue() if self.cb_automatic.GetValue(): add_new_tag = 1 else: add_new_tag = 0 if self.rb_softlinks.GetValue(): use_softlink = True else: use_softlink = False if not os.path.isdir(location): wx.MessageBox("Location does not exist!", "Error") return if name == "": wx.MessageBox("Must define a name.", "Error") return output.change_link_type(self.folder_id, False, use_softlink) new_checked_tags = self.lb.GetCheckedStrings() for tag in new_checked_tags: if tag not in self.checked_tags: tag_id = tagging.tag_name_to_id(tag.replace(" ", "_")) output.change_gallery(self.folder_id, tag_id, True) for tag in self.checked_tags: if tag not in new_checked_tags: tag_id = tagging.tag_name_to_id(tag.replace(" ", "_")) output.change_gallery(self.folder_id, tag_id, False) if name != self.name or location != self.location: if os.path.isdir(os.path.join(location, name)): print "koko made NI" wx.MessageBox( ("Location or target folder already exists, " "remove it first."), "Error", ) return if name != self.name: output.rename(self.folder_id, False, name) if location != self.location: output.move(self.folder_id, False, location) query_save = ("UPDATE gallery_folder SET " "add_new_tag = %d " "WHERE pk_id = %d" % (add_new_tag, self.folder_id)) cursor.execute(query_save) gallery_conn.commit() self.Close()
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()
def SaveSettings(self): # FIXME: Change name not working (under windows)? # Register folders # Get gallery connection gallery_conn = database.get_current_gallery("connection") cursor = gallery_conn.cursor() location = self.tc_directory.GetValue() name = self.tc_name.GetValue() if self.cb_automatic.GetValue(): add_new_tag = 1 else: add_new_tag = 0 if self.rb_softlinks.GetValue(): use_softlink = True else: use_softlink = False if not os.path.isdir(location): wx.MessageBox("Location does not exist!", "Error") return if name == "": wx.MessageBox("Must define a name.", "Error") return output.change_link_type(self.folder_id, False, use_softlink) new_checked_tags = self.lb.GetCheckedStrings() for tag in new_checked_tags: if tag not in self.checked_tags: tag_id = tagging.tag_name_to_id(tag.replace(" ", "_")) output.change_gallery(self.folder_id, tag_id, True) for tag in self.checked_tags: if tag not in new_checked_tags: tag_id = tagging.tag_name_to_id(tag.replace(" ", "_")) output.change_gallery(self.folder_id, tag_id, False) if name != self.name or location != self.location: if os.path.isdir(os.path.join(location, name)): print "koko made NI" wx.MessageBox( ("Location or target folder already exists, " "remove it first."), "Error", ) return if name != self.name: output.rename(self.folder_id, False, name) if location != self.location: output.move(self.folder_id, False, location) query_save = ( "UPDATE gallery_folder SET " "add_new_tag = %d " "WHERE pk_id = %d" % (add_new_tag, self.folder_id) ) cursor.execute(query_save) gallery_conn.commit() self.Close()