代码拉取完成,页面将自动刷新
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import re
PATH='/usr/share/kylin-update-desktop/'
class main:
def generate_old_system_packagelist(self):
os.system('dpkg -l > '+ PATH +'dpkgl')
ff = open(PATH +'old-system-packagelist','w')
with open(PATH +'dpkgl') as f:
for line in f:
if line.startswith('ii '):
line = line.replace('ii ','')
line = re.sub('( *)arm64(.*)','',line)
line = re.sub('( *)i386(.*)','',line)
line = re.sub('( *)amd64(.*)','',line)
line = re.sub('( *)i686(.*)','',line)
line = re.sub('( *)all(.*)','',line)
line = re.sub('( *)','\t',line)
ff.write(line)
ff.close()
def specification_old_system_packagelist(self):
f = open(PATH +'old-system-packagelist', mode='r')
ff = open(PATH + "pkglist", mode='w')
for line in f:
linesp = line.split("\t")
pkgname = linesp[0]
pkgversion = linesp[1]
if(pkgname.find(":arm64") != -1):
pkgname = pkgname[:pkgname.find(":arm64")]
newline = pkgname + "_" + pkgversion
ff.write(newline)
f.close()
ff.close()
def generate_install_list(self):
newnames = []
oldnames = []
f = open(PATH +'new-system-packagelist', mode='r')
ff = open(PATH +'pkglist', mode='r')
fff = open(PATH +'install', mode='w')
for line in f:
newnames.append(line.strip())
for line in ff:
oldnames.append(line.strip())
for name in newnames:
for nameold in oldnames:
if(name == nameold):
break
else:
# name = name.replace('_', '=')
fff.write(name + '*deb ')
f.close()
ff.close()
fff.close()
if __name__ == '__main__':
m = main()
m.generate_old_system_packagelist()
m.specification_old_system_packagelist()
m.generate_install_list()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。