马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#coding:utf-8
import os
from time import sleep
import multiprocessing as multi
from xml.etree.ElementTree import ElementTree as et
class thr_dxdi(multi.Process):
def __init__(self,filename):
multi.Process.__init__(self)
self.fn = filename
def run(self):
self.s = self.fn.get()
if self.s:
err = os.system('dxdiag /x ' + self.s)
if err != 0:
print('run dxdiag fail!')
input('')
exit()
self.fn.task_done()
os.chdir(r'D:\GIN\py\xml')
cf = 'config.xml'
if __name__ == '__main__':
os.system('chcp 936 >nul') #设置cmd页面代码
if os.path.exists(cf):
os.remove(cf)
q = multi.JoinableQueue() #队列
th = thr_dxdi(q)
th.start()
q.put(cf) #发送一个元素
# q.join() #等待队列完成
count = 0
while True:
if not os.path.exists(cf):
count += 1
print('请稍等,系统正在生成配置信息...', count, '秒')
sleep(1)
os.system('cls')
continue
break
syslist = ['SystemInformation',# 系统相关
'DisplayDevices/DisplayDevice', #显示相关
'LogicalDisks/LogicalDisk'] #硬盘
cfx = et(file = cf) #打开文件
for item in syslist:
for i in cfx.findall(item): #搜索信息,返回列表或者迭代器
for n in range(len(i)): #遍历列表
print('{:26}:{}'.format(i[n].tag,i[n].text))
|