Ejemplo n.º 1
0
def guess_overwrite_paths():
    """Guess which partitions to overwrite (to hide deleted files)"""
    # In case overwriting leaves large files, placing them in
    # ~/.config makes it easy to find them and clean them.
    ret = []
    if 'posix' == os.name:
        home = os.path.expanduser('~/.cache')
        if not os.path.exists(home):
            home = os.path.expanduser("~")
        ret.append(home)
        if not same_partition(home, '/tmp/'):
            ret.append('/tmp')
    elif 'nt' == os.name:
        localtmp = expandvars('$TMP')
        logger = logging.getLogger(__name__)
        if not os.path.exists(localtmp):
            logger.warning('%TMP% does not exist: %s', localtmp)
            localtmp = None
        else:
            from win32file import GetLongPathName
            localtmp = GetLongPathName(localtmp)
        from Windows import get_fixed_drives
        for drive in get_fixed_drives():
            if localtmp and same_partition(localtmp, drive):
                ret.append(localtmp)
            else:
                ret.append(drive)
    else:
        NotImplementedError('Unsupported OS in guess_overwrite_paths')
    return ret
Ejemplo n.º 2
0
def guess_overwrite_paths():
    """Guess which partitions to overwrite (to hide deleted files)"""
    # In case overwriting leaves large files, placing them in
    # ~/.config makes it easy to find them and clean them.
    ret = []
    if 'posix' == os.name:
        home = os.path.expanduser('~/.cache')
        if not os.path.exists(home):
            home = os.path.expanduser("~")
        ret.append(home)
        if not same_partition(home, '/tmp/'):
            ret.append('/tmp')
    elif 'nt' == os.name:
        localtmp = os.path.expandvars('$TMP')
        logger = logging.getLogger(__name__)
        if not os.path.exists(localtmp):
            logger.warning('%TMP% does not exist: %s', localtmp)
            localtmp = None
        else:
            from win32file import GetLongPathName
            localtmp = GetLongPathName(localtmp)
        from Windows import get_fixed_drives
        for drive in get_fixed_drives():
            if localtmp and same_partition(localtmp, drive):
                ret.append(localtmp)
            else:
                ret.append(drive)
    else:
        NotImplementedError('Unsupported OS in guess_overwrite_paths')
    return ret
Ejemplo n.º 3
0
def guess_overwrite_paths():
    """Guess which partitions to overwrite (to hide deleted files)"""
    # In case overwriting leaves large files, placing them in
    # ~/.config makes it easy to find them and clean them.
    ret = []
    if 'posix' == os.name:
        home = os.path.expanduser('~/.cache')
        if not os.path.exists(home):
            home = os.path.expanduser("~")
        ret.append(home)
        if not same_partition(home, '/tmp/'):
            ret.append('/tmp')
    elif 'nt' == os.name:
        localtmp = os.path.expandvars('$TMP')
        if not os.path.exists(localtmp):
            print 'ERROR: %TMP% does not exist:', localtmp
            localtmp = None
        else:
            from win32file import GetLongPathName
            localtmp = GetLongPathName(localtmp)
        from Windows import get_fixed_drives
        for drive in get_fixed_drives():
            try:
                if localtmp and same_partition(localtmp, drive):
                    ret.append(localtmp)
                else:
                    ret.append(drive)
            except Exception, e:
                # see https://github.com/az0/bleachbit/issues/27
                # https://bugs.launchpad.net/bleachbit/+bug/1372179
                print 'ERROR in same_partition(%s, %s): %s' % (localtmp, drive,
                                                               e)
Ejemplo n.º 4
0
def guess_overwrite_paths():
    """Guess which partitions to overwrite (to hide deleted files)"""
    # In case overwriting leaves large files, placing them in
    # ~/.config makes it easy to find them and clean them.
    ret = []
    if 'posix' == os.name:
        home = os.path.expanduser('~/.cache')
        if not os.path.exists(home):
            home = os.path.expanduser("~")
        ret.append(home)
        if not same_partition(home, '/tmp/'):
            ret.append('/tmp')
    elif 'nt' == os.name:
        localtmp = os.path.expandvars('$TMP')
        logger = logging.getLogger(__name__)
        if not os.path.exists(localtmp):
            logger.warning('%TMP% does not exist: %s' % localtmp)
            localtmp = None
        else:
            from win32file import GetLongPathName
            localtmp = GetLongPathName(localtmp)
        from Windows import get_fixed_drives
        for drive in get_fixed_drives():
            try:
                if localtmp and same_partition(localtmp, drive):
                    ret.append(localtmp)
                else:
                    ret.append(drive)
            except Exception, e:
                # see https://github.com/az0/bleachbit/issues/27
                # https://bugs.launchpad.net/bleachbit/+bug/1372179
                logger.error('error in same_partition(%s, %s): %s' %
                             (localtmp, drive, Common.decode_str(e)))
def guess_overwrite_paths():
    """Guess which partitions to overwrite (to hide deleted files)"""
    # In case overwritting leaves large files, placing them in
    # ~/.config makes it easy to find them and clean them.
    ret = []
    if 'posix' == os.name:
        home = os.path.expanduser('~/.cache')
        if not os.path.exists(home):
            home = os.path.expanduser("~")
        ret.append(home)
        if not same_partition(home, '/tmp/'):
            ret.append('/tmp')
    elif 'nt' == os.name:
        localtmp = dirname = os.path.expandvars(
            "$USERPROFILE\\Local Settings\\Temp\\")
        from Windows import get_fixed_drives
        for drive in get_fixed_drives():
            if same_partition(localtmp, drive):
                ret.append(localtmp)
            else:
                ret.append(drive)
    else:
        NotImplementedError('Unsupported OS in guess_overwrite_paths')
    return ret
Ejemplo n.º 6
0
def guess_overwrite_paths():
    """Guess which partitions to overwrite (to hide deleted files)"""
    # In case overwritting leaves large files, placing them in
    # ~/.config makes it easy to find them and clean them.
    ret = []
    if 'posix' == os.name:
        home = os.path.expanduser('~/.cache')
        if not os.path.exists(home):
            home = os.path.expanduser("~")
        ret.append(home)
        if not same_partition(home, '/tmp/'):
            ret.append('/tmp')
    elif 'nt' == os.name:
        localtmp = dirname = os.path.expandvars(
            "$USERPROFILE\\Local Settings\\Temp\\")
        from Windows import get_fixed_drives
        for drive in get_fixed_drives():
            if same_partition(localtmp, drive):
                ret.append(localtmp)
            else:
                ret.append(drive)
    else:
        NotImplementedError('Unsupported OS in guess_overwrite_paths')
    return ret