Exemplo n.º 1
0
    def do_bash_rpm_install():
        global noscripts_pkg_list
        global use_noscripts
        mia.set_step(operid, 1, 1)
            
        try:
            cmd = '/bin/rpm'
            argv = ['-i', '--noorder','--nosuggest',
                    '--force','--nodeps',
                    '--ignorearch',
                    '--root', CONF_TGTSYS_ROOT,
                    pkgpath,
                ]
            if use_noscripts or noscripts:
                argv.append('--noscripts')
                noscripts_pkg_list.append(pkgpath)

            #cmd_res = {'err':[], 'std': [], 'ret':0}   # DEBUG
            cmd_res = run_bash(cmd, argv)
            # Sign the installing pkg name in stderr
            if cmd_res['err']:
                # Ok the stderr will dup2 a log file, so we just out it on err screen
                print >>sys.stderr, '***INSTALLING %s:\n**STDERR:\n%s\n' \
                        %(pkgname, ''.join(cmd_res['err']))
            problems = cmd_res['ret']
            if problems:
                errormsg = ''.join(cmd_res['err'])
                message = 'PROBLEMS on %s: \n return code is %s error message is\n[%s]' \
                          % (pkgname, str(problems), errormsg)
                dolog(message)
                return  message
        except Exception, errmsg:
            dolog('FAILED on %s: %s\n' % (pkgname, str(errmsg)))
            return str(errmsg)
Exemplo n.º 2
0
def logger_copy_logfiles(mia, operid, param):
    def start_operate(title):
        time.sleep(0.2)
        print title

    usb_dev_path, usb_fs_type, logfiles = param
    usb_mount_dir = ""
    steps = 4
    step = 0
    mia.set_step(operid, step, steps)
    # mount the usb device.
    step = step + 1
    mia.set_step(operid, step, steps)
    start_operate('Mount...')
    ret, msg = mount_dev(usb_fs_type, usb_dev_path)
    if not ret:
        return str(msg)
    else:
        usb_mount_dir = msg

    # Copy logfiles to usb.
    step = step + 1
    mia.set_step(operid, step, steps)
    start_operate('Copy logfiles...')
    ret, msg = copy_logfiles(logfiles, os.path.join(usb_mount_dir, "magiclogger"))
    if ret:
        return str(msg)
    
    step = step + 1
    mia.set_step(operid, step, steps)
    start_operate('Sync files...')
    run_bash('/bin/sync')

    # umount the usb device.
    step = step + 1
    mia.set_step(operid, step, steps)
    start_operate('Umount...')
    ret, msg = umount_dev(usb_mount_dir)
    if not ret:
        return str(msg)

    return 0
Exemplo n.º 3
0
def copy_logfiles(logfiles, destdir):
    ret = []
    errormsg = []
    for logfile in logfiles:
        if not os.path.exists(logfile):
            continue
        if not os.path.exists(destdir):
            os.makedirs(destdir)
        cmd_res = run_bash("cp",[ "-r", logfile, destdir])
        if cmd_res['ret']:
            ret.append(cmd_res['ret'])
            errormsg.append(cmd_res['err'])
    return ret, errormsg