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 from __future__ import print_function
21 import os
22 import subprocess
23 import re
24 import sys
25 import smolt_config
26 from i18n import _
27 
28 
30  if os.access('/usr/bin/lsb_release', os.X_OK):
31  return subprocess.getstatusoutput('/usr/bin/lsb_release')[1].strip()
32  return ''
33 
34 initdefault_re = re.compile(r':(\d+):initdefault:')
35 
37  defaultRunlevel = '9'
38  try:
39  with open('/etc/inittab') as i_tab:
40  inittab = i_tab.read()
41  match = initdefault_re.search(inittab)
42  if match:
43  defaultRunlevel = match.group(1)
44  except IOError:
45  try:
46  defaultRunlevel = subprocess.getstatusoutput('/sbin/runlevel')[1].split()[1].strip()
47  except:
48  sys.stderr.write(_('Cannot Determine Runlevel'))
49  return defaultRunlevel.strip()
50 
51 def read_os():
52  return smolt_config.get_config_attr("OS", "Calvin and Hobbes")
53 
54 if __name__ == '__main__':
55  dict = {
56  'LSB release':read_lsb_release(),
57  'Run level':read_runlevel(),
58  'OS':read_os(),
59  }
60  for k, v in list(dict.items()):
61  print('%s: "%s"' % (k, v))
hardwareprofile.software.read_runlevel
def read_runlevel()
Definition: software.py:36
hardwareprofile.software.read_os
def read_os()
Definition: software.py:51
hardwareprofile.software.read_lsb_release
def read_lsb_release()
Definition: software.py:29
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