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
|
#!/usr/bin/python
# vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=python:tw=0
#############################################################################
#
# Copyright (c) 2005 Dell Computer Corporation
# Dual Licenced under GNU GPL and OSL
#
#############################################################################
"""dumpCmos"""
from __future__ import generators, division
# import arranged alphabetically
import gettext
import locale
import os
import sys
import traceback
# the following vars are all substituted on install
# this bin isnt byte-compiled, so this is ok
__VERSION__="uninstalled-version"
pythondir=os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), "..", "python")
clidir=os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), "..", "py-cli")
# end vars
# import all local modules after this.
sys.path.insert(0,pythondir)
sys.path.insert(0,clidir)
import cli
from libsmbios_c import token, smbios, smi, system_info as sysinfo, localedir, GETTEXT_PACKAGE
from libsmbios_c.trace_decorator import decorate, traceLog, getLog
locale.setlocale(locale.LC_ALL, '')
gettext.install(GETTEXT_PACKAGE, localedir, unicode=1)
moduleLog = getLog()
verboseLog = getLog(prefix="verbose.")
class CmdlineError(Exception): pass
def command_parse():
parser = cli.OptionParser(usage=__doc__, version=__VERSION__)
cli.addStdOptions(parser, passwordOpts=True, securityKeyOpt=False)
return parser.parse_args()
def main():
exit_code = 0
(options, args) = command_parse()
cli.setup_std_options(options)
try:
pass # put code here
except (smi.SMIExecutionError, ), e:
exit_code=3
moduleLog.info( _("ERROR: Could not execute SMI.") )
verboseLog.info( _("The smi library returned this error:") )
verboseLog.info( str(e) )
moduleLog.info( cli.standardFailMessage )
except (smbios.TableParseError, token.TokenTableParseError), e:
exit_code=3
moduleLog.info( _("ERROR: Could not parse system SMBIOS table.") )
verboseLog.info( _("The smbios library returned this error:") )
verboseLog.info( str(e) )
moduleLog.info( cli.standardFailMessage )
except (token.TokenManipulationFailure,), e:
exit_code=4
moduleLog.info( _("ERROR: Could not manipulate system token.") )
verboseLog.info( _("The token library returned this error:") )
verboseLog.info( str(e) )
moduleLog.info( cli.standardFailMessage )
return exit_code
if __name__ == "__main__":
sys.exit( main() )
|