def setupWine():
    getLog(prefix="verbose.").info("Running pre-setup for wine.")
    global wineprefix
    wineprefix = tempfile.mkdtemp(prefix="wineprefix-")
    env={
        "DISPLAY":"",
        "TERM":"",
        "PATH":os.environ["PATH"],
        "HOME":os.environ["HOME"],
        "WINEPREFIX": wineprefix,
        }
    common.loggedCmd(["wineprefixcreate", "-w", "--prefix", wineprefix], cwd=wineprefix, env=env, logger=getLog(), raiseExc=False)
    atexit.register(shutil.rmtree, wineprefix)
    getLog(prefix="verbose.").info("Wine pre-setup finished.")
def setupFreedos():
    getLog(prefix="verbose.").info("Running pre-setup for freedos.")
    global dosprefix
    dosprefix = tempfile.mkdtemp(prefix="dosprefix-")
    common.loggedCmd(["tar", "xvjf", conf.helper_dat], cwd=dosprefix, logger=getLog())
    import commands
    status, output = commands.getstatusoutput("uname -m")
    if output.startswith("x86_64"):
        os.rename(os.path.join(dosprefix, "both", "64"), os.path.join(dosprefix, "freedos"))
    else:
        os.rename(os.path.join(dosprefix, "both", "32"), os.path.join(dosprefix, "freedos"))
    if not os.path.isdir(os.path.join(os.environ["HOME"], ".dosemu")):
        os.mkdir(os.path.join(os.environ["HOME"], ".dosemu"))
        open(os.path.join(os.environ["HOME"], ".dosemu", "disclaimer"), "w+").close()

    atexit.register(shutil.rmtree, dosprefix)
    getLog(prefix="verbose.").info("Freedos pre-setup finished.")
Esempio n. 3
0
def runLongProcess(function, args=None, kargs=None, waitLoopFunction=None):
    # runs a function in a separate thread. Runs waitLoopFunction() while it
    # waits for the function to finish. Good for updating GUI, or other stuff
    thread = BackgroundWorker(function, args, kargs)
    while thread.running:
        if waitLoopFunction is not None:
            waitLoopFunction()

    # run waitLoopFunction one last time before exit.
    # gives status opportunity to update to 100%
    if waitLoopFunction is not None:
        waitLoopFunction()

    if thread.exception:
        getLog(prefix="verbose.").exception(thread.exception)
        raise thread.exception
    return thread.returnCode
Esempio n. 4
0
#
# Copyright (C) 2008 Dell Inc.
#  by Michael Brown <*****@*****.**>
"""
Classes for subcommands of the yum command line interface.
"""

from firmwaretools.trace_decorator import decorate, traceLog, getLog
import firmwaretools.plugins as plugins

import ftcommands

plugin_type = (plugins.TYPE_CLI, )
requires_api_version = "2.0"

moduleLog = getLog()


def config_hook(conduit, *args, **kargs):
    conduit.getOptParser().addEarlyParse("--bootstrap")
    conduit.getOptParser().add_option("-b",
                                      "--bootstrap",
                                      help="List the bootstrap inventory",
                                      action="store_const",
                                      const="bootstrap",
                                      dest="mode",
                                      default=None)
    conduit.getBase().registerCommand(BootstrapCommand())


class BootstrapCommand(ftcommands.YumCommand):
Esempio n. 5
0
from __future__ import generators

import os
import time
import logging

# import arranged alphabetically
import package
from firmwaretools.trace_decorator import decorate, traceLog, getLog
import firmwaretools.plugins as plugins

plugin_type = (plugins.TYPE_MOCK_INVENTORY, )
requires_api_version = "2.0"

moduleLog = getLog()
moduleVerboseLog = getLog(prefix="verbose.")

#==============================================================
# mock classes for unit tests
#   plus expected data returns
#==============================================================
decorate(traceLog())


def inventory_hook(conduit, inventory=None, *args, **kargs):
    base = conduit.getBase()
    cb = base.cb

    import firmwaretools as ft
    ft.callCB(cb,
except ImportError:
    # disable this plugin if firmware_extract not installed
    raise plugins.DisablePlugin

import firmware_addon_dell as fad
import extract_common as common
import biosHdr
from extract_bios_blacklist import dell_system_id_blacklist, dell_system_specific_bios_blacklist 

# required by the Firmware-Tools plugin API
__VERSION__ = firmwaretools.__VERSION__
plugin_type = (plugins.TYPE_CORE,)
requires_api_version = "2.0"
# end: api reqs

moduleLog = getLog()
conf = None
wineprefix = None
dosprefix = None

class noHdrs(fte.DebugExc): pass

# this is called from doCheck in buildrpm_cmd and should register any spec files
# and hooks this module supports
decorate(traceLog())
def buildrpm_doCheck_hook(conduit, *args, **kargs):
    global conf
    conf = checkConf_buildrpm(conduit.getConf(), conduit.getBase().opts)
    br.specMapping["BiosPackage"] = {"spec": conf.biospackagespec, "ini_hook": buildrpm_ini_hook}

# this is called by the buildrpm_doCheck_hook and should ensure that all config
Esempio n. 7
0
    def exFatal(e):
        logger.critical('%s' % e)
        sys.exit(1)

    try:
        locale.setlocale(locale.LC_ALL, '')
    except locale.Error, e:
        # default to C locale if we get a failure.
        print >> sys.stderr, 'Failed to set locale, defaulting to C'
        locale.setlocale(locale.LC_ALL, 'C')

    # our core object for the cli
    base = cli.BaseCli()

    logger = getLog()
    verbose_logger = getLog(prefix="verbose.")

    # do our cli parsing and config file setup
    # also sanity check the things being passed on the cli
    try:
        # no logging before this returns.
        base.getOptionsConfig(args)
    except plugins.PluginExit, e:
        exPluginExit(e)
    except errors.BaseError, e:
        exFatal(e)

    lockerr = ""
    while True:
        try: