예제 #1
0
 def commit(self):
     '''
         :description stroe pulish information to database        
     '''
     source = os.path.join(self.directory, self.type, self.tag)
     db = database.Connect(table=self.type)
     if self.isExists():
         result = self.removeOriginData(self.tag)
         if not result:
             return False, 'Not able to remove <%s>' % self.tag
         result, message = db.overwrite(tag=self.tag, manifest=source)
     else:
         result, message = db.insert(tag=self.tag, manifest=source)
     return result, message
예제 #2
0
 def load_data(self, combobox, treewidget, *args):
     treewidget.clear()
     table = str(combobox.itemText(args[0]))
     if not table or table == 'None':
         return
     db = database.Connect(table=table)
     columns = db.get_columns()
     if not columns:
         return
     treewidget.clear()
     for index, each in enumerate(columns):
         treewidget.headerItem().setText(index, each)
         treewidget.header().resizeSection(index, 250)
     treewidget.header().resizeSection(0, 100)
     treewidget.header().resizeSection(1, 200)
     treewidget.header().resizeSection(2, 200)
     treewidget.header().resizeSection(3, 300)
     contents = db.select()
     for content in contents:
         item = QtGui.QTreeWidgetItem(treewidget)
         for index, each in enumerate(content):
             item.setText(index, str(each))
예제 #3
0
 def remove(self):
     replay = QtGui.QMessageBox.question(
         self, 'Question', 'Are you sure\nWant to reomve?...',
         QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
     if replay == QtGui.QMessageBox.No:
         logging.warning('abort!...')
         return
     table = str(self.combobox_input.currentText())
     if not table or table == 'None':
         QtGui.QMessageBox.warning(
             self, 'Warning', 'Select the any one in the table and try!...',
             QtGui.QMessageBox.Ok)
         return
     if not self.treewidget.selectedItems():
         QtGui.QMessageBox.warning(
             self, 'Warning', 'Select the any one in the items and try!...',
             QtGui.QMessageBox.Ok)
         return
     select_items = self.treewidget.selectedItems()
     result = True
     for item in select_items:
         id = str(item.text(0))
         tag = str(item.text(1))
         db = database.Connect(table=table)
         try:
             db.delete(id, tag)
             result = True
         except Exception as error:
             QtGui.QMessageBox.warning(self, 'Warning', str(error),
                                       QtGui.QMessageBox.Ok)
             result = False
     if result:
         logging.info('Remove success!...')
     else:
         logging.warning('Remove failed!...')
     self.reload()
예제 #4
0
 def getDatas(self):
     db = database.Connect(table=self.type)
     data = db.select()
     return data
예제 #5
0
 def getTables(self):
     db = database.Connect(table=self.type)
     tags = db.get_columns()
     return tags
예제 #6
0
 def getTypes(self):
     db = database.Connect()
     tables = db.get_tables()
     return tables
예제 #7
0
 def modify_ui(self):
     db = database.Connect()
     tables = db.get_tables()
     tables = ['None'] + tables
     self.combobox_input.addItems(tables)