Exemple #1
0
 def do_umount(self):
     if not self.has_mounted: return True
     ret, errmsg = umount_dev(self.mntdir)
     if not ret:
         Log.e("MiDevice.do_umount UMount(%s) failed: %s" % (self.mntdir, str(errmsg))); return False
     else:
         self.has_mounted = False
         if not self.mntdir_fixed: self.mntdir = ''
         return True
Exemple #2
0
def win_probe(mia, operid, hdpartlist):
    mia.set_step(operid, 0, -1)
    result = []
    all_drives = hdpartlist
    for (device, fstype, new_device) in all_drives:
        dolog('Search %s for Windows files\n' % device)
        if fstype not in CONF_FSTYPE_MAP or \
               CONF_FSTYPE_MAP[fstype][0] not in ('vfat', 'ntfs', 'ntfs-3g'):
            continue
        ret, mntdir = mount_dev(CONF_FSTYPE_MAP[fstype][0], device)
        if ret:
            if os.path.exists(os.path.join(mntdir, 'bootmgr')):
                result.append((new_device, 'vista/7'))
            elif os.path.exists(os.path.join(mntdir, 'ntldr')):
                result.append((new_device, 'winnt'))
            elif os.path.exists(os.path.join(mntdir, 'io.sys')):
                result.append((new_device, 'win98'))
            else:
                 result.append((new_device, 'win'))
            umount_dev(mntdir)
    return result
Exemple #3
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
Exemple #4
0
        boot_ini = open(os.path.join(win_mntdir, 'boot.ini'), 'r+')
        found = False
        for line in boot_ini.readlines():
            dolog('%s' % line)
            if 'grldr' in line.lower():
                found = True
                break
        if not found:
            dolog('APPEND')
            boot_ini.seek(0, 2)
            boot_ini.write('\nc:\\grldr="Grub"\n')
        boot_ini.close()

        os.system('cp -a %s %s/' % ('/usr/share/grldr',
                                   win_mntdir))
        umount_dev(win_mntdir)
        return 0

    else:
        if os.path.exists('/tmpfs/debug/nobootloader'):
            dolog('TURN ON: nobootloader\n')
            return 0
        # Get the command arguments for grub.
        #floppy = kudzu.probe(kudzu.CLASS_FLOPPY,
        #                     kudzu.BUS_IDE | kudzu.BUS_SCSI | kudzu.BUS_MISC,
        #                     kudzu.PROBE_ALL)
        floppy = getdev.probe(getdev.CLASS_FLOPPY)

        # Because --batch will cause a bus error, we don not use this
        # option.
        #grubopt = '--batch'
Exemple #5
0
        os.system('rm -r %s' % os.path.join(CONF_TGTSYS_ROOT, tmp_config_dir))
        
    global ts
    if ts is not None:
        dolog('Close TransactionSet\n')
        ts.closeDB()
        ts = None
    dolog('instpkg_post(%s, %s, %s)\n' % (dev, reldir, fstype))
    if fstype == 'iso9660':
        return  0  # It is ok for CDROM installation.
    mia.set_step(operid, 0, -1) # Sync is the long operation.
    if mntxxxpoint != 0: #### TODO;
        mntdir = os.path.join(CONF_TGTSYS_ROOT, mntxxxpoint)     ####TODO
    else:
        mntdir = os.path.join(CONF_MNT_ROOT, os.path.basename(dev))
        ret, errmsg = umount_dev(mntdir)
        if not ret:
            syslog.syslog(syslog.LOG_ERR, 'UMount(%s) failed: %s' % \
                          (mntdir, str(errmsg)))
            return str(errmsg)
    try:
        isys.sync()
    except Expection, errmsg:
        syslog.syslog(syslog.LOG_ERR, 'sync failed: %s' % str(errmsg))
        return str(errmsg)
    return  0
    
######################   Install package below code    #########################
# Now package_install support rpm only.
@register.server_handler('long')
def rpm_installcb(what, bytes, total, h, data):