コード例 #1
0
ファイル: softupdater.py プロジェクト: 360849048/MyProj
 def startUpdate(self):
     '''
         将getUpdateInfo返回的数据,传入该函数,进行数据库写入更新操作
     '''
     if self.running_update:
         print('其他人正在更新')
         while self.running_update:
             # 等待其他线程操作完成
             pass
         return True
     else:
         if self.vers_ready_to_append is None:
             return False
         self.running_update = True
         try:
             t_soft = TableManager(self.table_name, self.version_db_path)
             t_soft.auto_commit = False
             for new_vers in self.vers_ready_to_append:
                 t_soft.appendLine(client=new_vers[0],
                                   version=new_vers[1],
                                   date=new_vers[2],
                                   base=new_vers[3],
                                   record=new_vers[4],
                                   reason=new_vers[5],
                                   remark=new_vers[6],
                                   author=new_vers[7],
                                   path='')
             t_soft.commitData()
             t_soft.auto_commit = True
             self.vers_ready_to_append = None
             return True
         except:
             return False
         finally:
             self.running_update = False
コード例 #2
0
def markToRefresh(table_name, ids):
    t_soft = TableManager(table_name, SOFTWARE_VERSION_INFO_DB_PATH)
    if isinstance(ids, int):
        t_soft.modifyLine(ids, torefresh='1')
    elif isinstance(ids, tuple) or isinstance(ids, list) or isinstance(ids, set):
        # 多次commit很耗费性能,需要避免
        t_soft.auto_commit = False
        for id in ids:
            t_soft.modifyLine(id, torefresh='1')
        t_soft.commitData()
        t_soft.auto_commit = True