fix冲突
This commit is contained in:
commit
702c2887d4
|
@ -731,43 +731,38 @@ def get_package_label(pkg):
|
|||
|
||||
#安装时禁止关机 进行加锁
|
||||
def LockedPreventShutdown():
|
||||
global locked
|
||||
|
||||
#加锁后直接返回
|
||||
if locked:
|
||||
return
|
||||
#锁目录是否存在 不存在时 创建
|
||||
if not os.path.exists(FILELOCK_PATH):
|
||||
os.makedirs(FILELOCK_PATH)
|
||||
|
||||
with open(os.path.join(FILELOCK_PATH, SHUTDOWN_BLOCK_FILELOCK), "w+") as pidfile:
|
||||
global pidfile
|
||||
global locked
|
||||
if not os.path.exists(FILELOCK_PATH):
|
||||
os.makedirs(FILELOCK_PATH)
|
||||
pidfile = open(os.path.join(FILELOCK_PATH, SHUTDOWN_BLOCK_FILELOCK), "w+")
|
||||
try:
|
||||
fcntl.flock(pidfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
locked = True
|
||||
logging.info("Has been locked.")
|
||||
#多次加锁就会出现异常
|
||||
if not locked:
|
||||
fcntl.flock(pidfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
logging.info("Shutdown Has been locked...")
|
||||
locked = True
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
logging.error(str(e))
|
||||
locked = False
|
||||
logging.error("file cannot be locked.")
|
||||
return False
|
||||
|
||||
#解锁禁止关机
|
||||
def unLockedEnableShutdown():
|
||||
global pidfile
|
||||
global locked
|
||||
|
||||
if not locked:
|
||||
return
|
||||
|
||||
with open(os.path.join(FILELOCK_PATH, SHUTDOWN_BLOCK_FILELOCK), "w+") as pidfile:
|
||||
try:
|
||||
fcntl.flock(pidfile, fcntl.LOCK_UN)
|
||||
locked = False
|
||||
logging.info("Has been unlocked.")
|
||||
except:
|
||||
locked = False
|
||||
logging.error("unlock failed.")
|
||||
return False
|
||||
if not pidfile:
|
||||
logging.errr("pidfile file disc is None...")
|
||||
return False
|
||||
try:
|
||||
fcntl.flock(pidfile, fcntl.LOCK_UN)
|
||||
pidfile.close()
|
||||
locked = False
|
||||
logging.info("Shutdown Has been unlocked...")
|
||||
except Exception as e:
|
||||
logging.error(str(e))
|
||||
logging.error("unlock failed.")
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
#print(mirror_from_sources_list())
|
||||
|
|
|
@ -252,7 +252,7 @@ class UpdateManagerDbusController(dbus.service.Object):
|
|||
|
||||
# 处于更新和升级中的话 不进行升级
|
||||
if self.parent.is_working != InstallBackend.ACTION_DEFUALT_STATUS:
|
||||
self.PurgePackagesFinished(False,_("Other tasks are being updated and upgraded, please uninstall them later."),_(""))
|
||||
self.PurgePackagesFinished(False,_("Other tasks are being updated and upgraded, please uninstall them later."),'')
|
||||
logging.warning('PurgePackages In the process of updating or Upgrading...')
|
||||
return False
|
||||
else:
|
||||
|
@ -319,7 +319,7 @@ class UpdateManagerDbusController(dbus.service.Object):
|
|||
self.parent.start_deb_install(deb_path, _check_local_dep, _auto_satisfy)
|
||||
return True
|
||||
except Exception as e:
|
||||
logging.error(False, str(e))
|
||||
logging.error(str(e))
|
||||
return (False)
|
||||
|
||||
# dbus接口:向数据库display表中插入数据
|
||||
|
|
|
@ -245,10 +245,11 @@ class InstallBackendAptdaemon(InstallBackend):
|
|||
self._action_done(self.ACTION_REMOVE_PACKAGES,
|
||||
authorized=False, success=False,
|
||||
error_string='', error_desc='')
|
||||
except Exception:
|
||||
self._action_done(self.ACTION_REMOVE_PACKAGES,
|
||||
is_cancelled=False, success=False,
|
||||
error_string='', error_desc='')
|
||||
except Exception as e:
|
||||
logging.error(str(e))
|
||||
# self._action_done(self.ACTION_REMOVE_PACKAGES,
|
||||
# is_cancelled=False, success=False,
|
||||
# error_string='', error_desc='')
|
||||
|
||||
#进度回调
|
||||
def _on_progress_changed(self, trans,progress,action):
|
||||
|
@ -277,12 +278,14 @@ class InstallBackendAptdaemon(InstallBackend):
|
|||
if progress != 100:
|
||||
self.window_main.dbusController.UpdateDetectStatusChanged(progress,status)
|
||||
elif action == self.ACTION_INSTALL:
|
||||
#50%时候 属于下载状态切换到安装状态的过程
|
||||
#50%时候 属于下载状态切换到安装状态的过程 下面的代码只执行一次
|
||||
if progress >= 51 and self.on_install_stage == False:
|
||||
self.on_install_stage = True
|
||||
LockedPreventShutdown()
|
||||
|
||||
#进度安装阶段标志位,使用鉴别是否出现安装过程中强制关闭 之后进行修复使用得
|
||||
self.window_main.configs.setValue("SystemStatus","isabnormalreboot",str(True),True)
|
||||
pass #LockedPreventShutdown()
|
||||
|
||||
#在下载阶段发送取消信号
|
||||
if self.on_install_stage == False:
|
||||
self.window_main.dbusController.Cancelable(self.trans_cancelable)
|
||||
|
|
|
@ -377,7 +377,7 @@ class InstallBackend():
|
|||
self.window_main.configs.setValue("SystemStatus","isabnormalreboot",str(False),True)
|
||||
|
||||
upgrade_content = self.now_upgrade.upgrade_groups + self.now_upgrade.single_pkgs
|
||||
# unLockedEnableShutdown()
|
||||
unLockedEnableShutdown()
|
||||
#结果插入到数据库中
|
||||
self._make_insert_info(success,is_cancelled,self.now_upgrade.upgrade_mode,error_string,error_desc)
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@
|
|||
| SetDownloadspeedMax | sb | b | 设置限速 | |
|
||||
| GetBackendStatus | 无 | i | 控制获取后端状态 | |
|
||||
| UnattendedUpgradeValue | ss | bs | 获取是否允许关机前更新 | |
|
||||
| PurgePackages | as | bs | 卸载软件包 | 支持 |
|
||||
| InstalldebFile | ssb | bs | 安装本地deb包 | |
|
||||
| PurgePackages | as | b | 卸载软件包 | |
|
||||
| InstalldebFile | ssb | b | 安装本地deb包 | |
|
||||
| | | | | |
|
||||
| | | | | |
|
||||
#### Method分析
|
||||
|
@ -44,7 +44,7 @@
|
|||
- `简介:`更新cache对象,完成从之后拿到系统中所有可升级的包再经过源过滤、白名单等等的过滤,最后输出当前`可升级的包以及分组(JSON配置 输出目录: /var/lib/kylin-system-updater)
|
||||
|
||||
- `入参:`无
|
||||
- `出参:`True and False
|
||||
- `出参:`True or False
|
||||
- `对应信号:`
|
||||
- `UpdateDetectStatusChanged:` 更新的进度信息和状态信息
|
||||
- `UpdateDetectFinished:`更新的完成的信号
|
||||
|
@ -56,7 +56,7 @@
|
|||
- `简介:`升级全部可升级的分组
|
||||
|
||||
- `入参:` `b:` False模式:只进行获取升级列表以及计算修复依赖关系,以及计算是否存在删除的包,`True模式:`直接进行安装的操作 注意:必须选使用False模式获取升级列表以及计算依赖关系再进行True模式
|
||||
- `出参:`True and False
|
||||
- `出参:`True or False
|
||||
- `对应信号:`
|
||||
- `UpdateDependResloveStatus:` 升级计算依赖修复反馈信号
|
||||
- `UpdateDloadAndInstStaChanged:`升级安装过程的进度信号以及状态
|
||||
|
@ -68,7 +68,7 @@
|
|||
- `简介:`安装本地deb包
|
||||
|
||||
- `入参:` `s:` 安装模式,`s:`本地deb包绝对路径,`b:`出现依赖问题时是否查询本路径下是否存在满足的包
|
||||
- `出参:`True and False
|
||||
- `出参:`True or False
|
||||
- `对应信号:`
|
||||
|
||||
|
||||
|
@ -110,6 +110,8 @@
|
|||
ACTION_REMOVE_PACKAGES = 6 #卸载包的状态中
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### UnattendedUpgradeValue
|
||||
|
||||
- `介绍:` 设置或获取是否允许关机前更新
|
||||
|
@ -125,7 +127,55 @@
|
|||
|
||||
|
||||
|
||||
#### PurgePackages
|
||||
|
||||
- `简介:`卸载系统中的软件包
|
||||
- `入参:` `as:` 需要卸载的包列表
|
||||
- `出参:`True or False 出参值不做任何参考意义 `注意:`其中False的时候表示后端正在处理其他任务会报错,其中完成信号也会反馈结果,故不采用方法的返回值来判断错误类型
|
||||
- `对应信号:`
|
||||
- `PurgePkgStatusChanged:`卸载过程的进度信号以及状态
|
||||
- `PurgePackagesFinished:` 卸载完成的信号
|
||||
|
||||
|
||||
|
||||
#### PurgePkgStatusChanged
|
||||
|
||||
- `介绍:`卸载的进度信息和状态信息以及状态的细节信息
|
||||
|
||||
- `出参`:`i:`卸载的进度信息从0-100%,`s:`卸载的状态信息,`s:`卸载的细节信息
|
||||
|
||||
- `示例:`
|
||||
|
||||
```sh
|
||||
INFO:emit PurgePkgStatusChanged progress = 63 , status = 正在应用更改 ,current_details = 正在准备删除 kylin-video
|
||||
INFO:emit PurgePkgStatusChanged progress = 76 , status = 正在应用更改 ,current_details = 正在卸载 kylin-video
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
#### UpdateDetectFinished
|
||||
|
||||
- `介绍:`卸载的完成的信号
|
||||
|
||||
- `出参`: `b:`卸载是否成功,`s:`产生错误的结果,`s:`产生错误的原因
|
||||
|
||||
- `示例:`
|
||||
|
||||
```sh
|
||||
#卸载完成
|
||||
PurgePackagesFinished success = True , error_string = 卸载完成。 , error_desc =
|
||||
|
||||
#卸载失败
|
||||
PurgePackagesFinished success = False , error_string = 软件包不存在 , error_desc = 检查包名的拼写是否正确,以及是否启用了相应的仓库。
|
||||
PurgePackagesFinished success = False , error_string = 软件包没有安装 , error_desc = 不需要进行卸载。
|
||||
|
||||
#卸载失败 由于正在处理其他任务也同样会报错
|
||||
PurgePackagesFinished success = False , error_string = 其他任务正在更新升级中,请稍后再卸载。 , error_desc =
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -160,7 +210,7 @@
|
|||
|
||||
- `介绍:`更新的进度信息和状态信息
|
||||
|
||||
- `出参`:`i:`更新的进度信息从0-100%,`s:`更新的状态信息
|
||||
- `出参`:`i:`更新的进度信息从0-100%,`s:`更新的状态信息,
|
||||
|
||||
- `示例:`
|
||||
|
||||
|
|
Loading…
Reference in New Issue