-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.py
122 lines (110 loc) · 3.6 KB
/
client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os, sys
import wmi
c = wmi.WMI()
#处理器
def printCPU():
tmpdict = {}
tmpdict["CpuCores"] = 0
for cpu in c.Win32_Processor():
tmpdict["cpuid"] = cpu.ProcessorId.strip()
tmpdict["CpuType"] = cpu.Name
tmpdict['systemName'] = cpu.SystemName
try:
tmpdict["CpuCores"] = cpu.NumberOfCores
except:
tmpdict["CpuCores"] += 1
tmpdict["CpuClock"] = cpu.MaxClockSpeed
tmpdict['DataWidth'] = cpu.DataWidth
# print(tmpdict)
return tmpdict
#主板
def printMain_board():
boards = []
# print len(c.Win32_BaseBoard()):
for board_id in c.Win32_BaseBoard():
tmpmsg = {}
tmpmsg['UUID'] = board_id.qualifiers['UUID'][1:-1] #主板UUID,有的主板这部分信息取到为空值,ffffff-ffffff这样的
tmpmsg['SerialNumber'] = board_id.SerialNumber #主板序列号
tmpmsg['Manufacturer'] = board_id.Manufacturer #主板生产品牌厂家
tmpmsg['Product'] = board_id.Product #主板型号
boards.append(tmpmsg)
print(boards)
return boards
#BIOS
def printBIOS():
bioss = []
for bios_id in c.Win32_BIOS():
tmpmsg = {}
tmpmsg['BiosCharacteristics'] = bios_id.BiosCharacteristics #BIOS特征码
tmpmsg['version'] = bios_id.Version #BIOS版本
tmpmsg['Manufacturer'] = bios_id.Manufacturer.strip() #BIOS固件生产厂家
tmpmsg['ReleaseDate'] = bios_id.ReleaseDate #BIOS释放日期
tmpmsg['SMBIOSBIOSVersion'] = bios_id.SMBIOSBIOSVersion #系统管理规范版本
bioss.append(tmpmsg)
print(bioss)
return bioss
#硬盘
def printDisk():
disks = []
for disk in c.Win32_DiskDrive():
# print disk.__dict__
tmpmsg = {}
tmpmsg['SerialNumber'] = disk.SerialNumber.strip()
tmpmsg['DeviceID'] = disk.DeviceID
tmpmsg['Caption'] = disk.Caption
tmpmsg['Size'] = disk.Size
tmpmsg['UUID'] = disk.qualifiers['UUID'][1:-1]
disks.append(tmpmsg)
for d in disks:
print(d)
return disks
#内存
def printPhysicalMemory():
memorys = []
for mem in c.Win32_PhysicalMemory():
tmpmsg = {}
tmpmsg['UUID'] = mem.qualifiers['UUID'][1:-1]
tmpmsg['BankLabel'] = mem.BankLabel
tmpmsg['SerialNumber'] = mem.SerialNumber.strip()
tmpmsg['ConfiguredClockSpeed'] = mem.ConfiguredClockSpeed
tmpmsg['Capacity'] = mem.Capacity
tmpmsg['ConfiguredVoltage'] = mem.ConfiguredVoltage
memorys.append(tmpmsg)
for m in memorys:
print(m)
return memorys
#电池信息,只有笔记本才会有电池选项
def printBattery():
isBatterys = False
for b in c.Win32_Battery():
isBatterys = True
return isBatterys
#网卡mac地址:
def printMacAddress():
macs = []
for n in c.Win32_NetworkAdapter():
mactmp = n.MACAddress
if mactmp and len(mactmp.strip()) > 5:
tmpmsg = {}
tmpmsg['MACAddress'] = n.MACAddress
tmpmsg['Name'] = n.Name
tmpmsg['DeviceID'] = n.DeviceID
tmpmsg['AdapterType'] = n.AdapterType
tmpmsg['Speed'] = n.Speed
macs.append(tmpmsg)
print(macs)
return macs
def main():
cpu_str = printCPU()
for i in cpu_str.values():
print(i)
# printMain_board()
# printBIOS()
# printDisk()
# printPhysicalMemory()
# printMacAddress()
# print(printBattery())
if __name__ == '__main__':
main()