MythTV  master
software.py
Go to the documentation of this file.
1 # smolt - Fedora hardware profiler
2 #
3 # Copyright (C) 2007 Mike McGrath
4 # Copyright (C) 2009 Sebastian Pipping <sebastian@pipping.org>
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 
20 import os
21 import subprocess
22 import re
23 import sys
24 import smolt_config
25 from i18n import _
26 
27 
29  if os.access('/usr/bin/lsb_release', os.X_OK):
30  return subprocess.getstatusoutput('/usr/bin/lsb_release')[1].strip()
31  return ''
32 
33 initdefault_re = re.compile(r':(\d+):initdefault:')
34 
36  defaultRunlevel = '9'
37  try:
38  with open('/etc/inittab') as i_tab:
39  inittab = i_tab.read()
40  match = initdefault_re.search(inittab)
41  if match:
42  defaultRunlevel = match.group(1)
43  except IOError:
44  try:
45  defaultRunlevel = subprocess.getstatusoutput('/sbin/runlevel')[1].split()[1].strip()
46  except:
47  sys.stderr.write(_('Cannot Determine Runlevel'))
48  return defaultRunlevel.strip()
49 
50 def read_os():
51  return smolt_config.get_config_attr("OS", "Calvin and Hobbes")
52 
53 if __name__ == '__main__':
54  dict = {
55  'LSB release':read_lsb_release(),
56  'Run level':read_runlevel(),
57  'OS':read_os(),
58  }
59  for k, v in list(dict.items()):
60  print('%s: "%s"' % (k, v))
hardwareprofile.software.read_runlevel
def read_runlevel()
Definition: software.py:35
hardwareprofile.software.read_os
def read_os()
Definition: software.py:50
hardwareprofile.software.read_lsb_release
def read_lsb_release()
Definition: software.py:28
hardwareprofile.i18n._
_
Definition: i18n.py:44
print
static void print(const QList< uint > &raw_minimas, const QList< uint > &raw_maximas, const QList< float > &minimas, const QList< float > &maximas)
Definition: vbi608extractor.cpp:29