/usr/lib/plainbox-provider-checkbox/bin/graphic_memory_info is in plainbox-provider-checkbox 0.25-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# graphic_memory_info
#
# This file is part of Checkbox.
#
# Copyright 2012 Canonical Ltd.
#
# Authors: Shawn Wang <shawn.wang@canonical.com>
#
# Checkbox is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3,
# as published by the Free Software Foundation.
#
# Checkbox is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
"""
The graphic_memory_info got information from lspci
"""
import re
import sys
import subprocess
# 00:01.0 VGA compatible controller: \
# Advanced Micro Devices [AMD] nee ATI Wrestler [Radeon HD 6320] \
# (prog-if 00 [VGA controller])
def vgamem_paser(data=None):
'''Parsing type vga and find memory information'''
device = None
vgamems = list()
for line in data.split('\n'):
for match in re.finditer('(\d\d:\d\d\.\d) VGA(.+): (.+)', line):
device = match.group(1)
name = match.group(3)
if device is None:
continue
#Memory at e0000000 (32-bit, prefetchable) [size=256M]
for match in re.finditer('Memory(.+) prefetchable\) \[size=(\d+)M\]',
line):
vgamem_size = match.group(2)
vgamem = {'device': device,
'name': name,
'vgamem_size': vgamem_size}
vgamems.append(vgamem)
return vgamems
def main():
'''main function
lspci -v -s 00:01.0 | grep ' prefetchable'
'''
try:
data = subprocess.check_output(['lspci', '-v'],
universal_newlines=True)
except subprocess.CalledProcessError as exc:
return exc.returncode
vgamems = vgamem_paser(data)
for vgamem in vgamems:
output_str = "Device({0})\t Name: {1}\tVGA Memory Size: {2}M"
print(output_str.format(vgamem['device'],
vgamem['name'],
vgamem['vgamem_size']))
if __name__ == '__main__':
sys.exit(main())
|