2
# -*- coding: utf-8 -*-
6
# This file is part of Checkbox.
8
# Copyright 2012 Canonical Ltd.
10
# Authors: Shawn Wang <shawn.wang@canonical.com>
12
# Checkbox is free software: you can redistribute it and/or modify
13
# it under the terms of the GNU General Public License as published by
14
# the Free Software Foundation, either version 3 of the License, or
15
# (at your option) any later version.
17
# Checkbox is distributed in the hope that it will be useful,
18
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
# GNU General Public License for more details.
22
# You should have received a copy of the GNU General Public License
23
# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
26
The graphic_memory_info got information from lspci
33
# 00:01.0 VGA compatible controller: \
34
# Advanced Micro Devices [AMD] nee ATI Wrestler [Radeon HD 6320] \
35
# (prog-if 00 [VGA controller])
38
def vgamem_paser(data=None):
40
'''Parsing type vga and find memory information'''
44
for line in data.split('\n'):
45
for match in re.finditer('(\d\d:\d\d\.\d) VGA(.+): (.+)', line):
46
device = match.group(1)
50
#Memory at e0000000 (32-bit, prefetchable) [size=256M]
51
for match in re.finditer('Memory(.+) prefetchable\) \[size=(\d+)M\]',
53
vgamem_size = match.group(2)
54
vgamem = {'device': device,
56
'vgamem_size': vgamem_size}
57
vgamems.append(vgamem)
64
lspci -v -s 00:01.0 | grep ' prefetchable'
68
data = subprocess.check_output(['lspci', '-v'],
69
universal_newlines=True)
70
except subprocess.CalledProcessError as exc:
73
vgamems = vgamem_paser(data)
74
for vgamem in vgamems:
75
output_str = "Device({0})\t Name: {1}\tVGA Memory Size: {2}M"
76
print(output_str.format(vgamem['device'],
78
vgamem['vgamem_size']))
80
if __name__ == '__main__':