Beispiel #1
0
def insensitive_path(path, opts):
	if os.path.exists(path):
		return (True, path, None)

	basename = os.path.basename(path)
	dirname = pretty_dirname = os.path.dirname(path)

	if not os.path.isdir(dirname):
		(found, dirname, pretty_dirname) = insensitive_path(dirname, opts)
		if not found:
			return (False, dirname, os.path.join(pretty_dirname, basename))

	pretty_basename = ''
	for entry in os.listdir(dirname):
		if entry.lower() == basename.lower():
			for i in range(len(entry)):
				if entry[i] != basename[i]:
					pretty_basename += ui._ctext('back_yellow black', entry[i])
				else:
					pretty_basename += entry[i]
			if opts.rename:
				os.rename(os.path.join(dirname, entry), os.path.join(dirname, basename))
				return (True, os.path.join(dirname, basename), os.path.join(pretty_dirname, pretty_basename))
			return (True, os.path.join(dirname, entry), os.path.join(pretty_dirname, pretty_basename))
	return (False, path, ui._ctext('back_red black', path))
Beispiel #2
0
def insensitive_path(path, opts):
    if os.path.exists(path):
        return (True, True, path, path)

    basename = os.path.basename(path)
    dirname = pretty_dirname = os.path.dirname(path)

    if not os.path.isdir(dirname):
        (found, correct, dirname,
         pretty_dirname) = insensitive_path(dirname, opts)
        if not found:
            return (False, False, dirname,
                    os.path.join(pretty_dirname, basename))

    pretty_basename = ''
    for entry in os.listdir(dirname):
        if entry.lower() == basename.lower():
            for i in range(len(entry)):
                if entry[i] != basename[i]:
                    pretty_basename += ui._ctext('back_yellow black', entry[i])
                else:
                    pretty_basename += entry[i]
            if opts.rename:
                os.rename(os.path.join(dirname, entry),
                          os.path.join(dirname, basename))
                return (True, False, os.path.join(dirname, basename),
                        os.path.join(pretty_dirname, pretty_basename))
            return (True, False, os.path.join(dirname, entry),
                    os.path.join(pretty_dirname, pretty_basename))
    return (False, False, path, ui._ctext('back_red black', path))
Beispiel #3
0
def main():
	parser = optparse.OptionParser()
	parser.add_option('-v', '--verbose', action='count',
			help='Print out info about things that pasesd. Use multiple times for more info.')
	parser.add_option('-r', '--rename', action='store_true',
			help='Rename files & directories to correct case mismatches')
	parser.add_option('-e', '--extra', '--extraneous', action='store_true',
			help='List any files in the game directory that are not tracked by any manifest files. Extraneous files are highlighted in ' + \
				ui._ctext('back_blue yellow', 'blue'))
	# '-d': Interractively delete (implies -e) files that not listed in the manifest file
	parser.add_option('-D', '--delete', action='store_true',
			help='Delete any extraneous files, without asking for confirmation (implies -e). CAUTION: Some games may store legitimate files in their directory that are not tracked by Steam which this option will delete. Also beware that a few games (e.g. Borderlands) still have their DLC managed by the legacy NCF format, which this script is not aware of and could therefore delete required files. BE CAREFUL WITH THIS OPTION!')
	parser.add_option('-M', '--move', action='store_true', help="Move any extraneous files to SteamApps/common/game~EXTRANEOUS (implies -e). rsync may be used to merge them back into the game directory later.")
	parser.add_option('-U', '--uninstall', action='store_true',
			help="Mark games with bad acf files (Currently that means 0 depotcaches mounted, but that definition may change in the future) as uninstalled. This WILL NOT DELETE THE GAME - it is intended to quickly remove bad acf files that may be interfering with launching or updating particular games. These games will need to be manually re-installed in Steam. (NOTE: Restart Steam afterwards)")
	# TODO:
	# '--verify': Mark game as needs verification on next launch (XXX: What option is that in the .acf? XXX: happens if Steam is running at the time?)
	#             Also, when I can do this it might be an idea for some of the above rename/delete options to imply this.
	(opts, args) = parser.parse_args()
	# TODO: If directory specified, interactively ask which game to check by name (maybe change default to do this to)
	if len(args) == 0:
		args = glob.glob(os.path.expanduser('~/.steam/root/SteamApps/appmanifest_*.acf'))
	for filename in args:
		check_acf(filename, opts)
		ui._print()
Beispiel #4
0
def str_depot_summary(mounted, managed):
	if isinstance(managed, UnknownLen):
		l = ui._ctext('back_yellow black', '?')
	else:
		l = str(len(managed))
	ret = '%i/%s depotcaches mounted' % (len(mounted), l)
	if len(mounted) == 0:
		ret += ' - Not released on this platform yet?'
	return ret
Beispiel #5
0
def str_depot_summary(mounted, managed):
    if isinstance(managed, UnknownLen):
        l = ui._ctext('back_yellow black', '?')
    else:
        l = str(len(managed))
    ret = '%i/%s depotcaches mounted' % (len(mounted), l)
    if len(mounted) == 0:
        ret += ' - Not released on this platform yet?'
    return ret
Beispiel #6
0
def main():
	parser = optparse.OptionParser()
	parser.add_option('-v', '--verbose', action='count',
			help='Print out info about things that pasesd. Use multiple times for more info.')
	parser.add_option('-r', '--rename', action='store_true',
			help='Rename files & directories to correct case mismatches')
	parser.add_option('-e', '--extra', '--extraneous', action='store_true',
			help='List any files in the game directory that are not tracked by any manifest files. Extraneous files are highlighted in ' + \
				ui._ctext('back_blue yellow', 'blue'))
	parser.add_option('--verify', action='count',
			help='Validate files integrity (Note: may show false positives if a file is in multiple depots). Specify twice to identify corrupt chunks.')
	parser.add_option('--file-filter', action='append',
			help='Specify file to check. Useful with --verify on large games when the bad files are already known. Can be specified multiple times.')
	parser.add_option('--depot-filter', action='append',
			help='Specify which mounted depots to process. Can be specified multiple times.')
	# '-d': Interractively delete (implies -e) files that not listed in the manifest file
	parser.add_option('-D', '--delete', action='store_true',
			help='Delete any extraneous files, without asking for confirmation (implies -e). CAUTION: Some games may store legitimate files in their directory that are not tracked by Steam which this option will delete. BE CAREFUL WITH THIS OPTION!')
	parser.add_option('--delete-bad', action='store_true',
			help='Delete any files with bad checksums, without asking for confirmation (implies --verify). CAUTION: Some games may store legitimate configuration files in their directory which this option may delete, potentially losing settings. BE CAREFUL WITH THIS OPTION!')
	parser.add_option('-M', '--move', action='store_true', help="Move any extraneous files to SteamApps/common/game~EXTRANEOUS (implies -e). rsync may be used to merge them back into the game directory later.")
	parser.add_option('-U', '--uninstall', action='store_true',
			help="Mark games with bad acf files (Currently that means 0 depotcaches mounted, but that definition may change in the future) as uninstalled. This WILL NOT DELETE THE GAME - it is intended to quickly remove bad acf files that may be interfering with launching or updating particular games. These games will need to be manually re-installed in Steam. (NOTE: Restart Steam afterwards)")
	parser.add_option('--steam-root',
			help="Specify where Steam is installed. This is usually detected automatically based on the acf path, but it may be necessary to specify it if working with games installed in an alternate steam library and this script can't find the game's manifest files.")
	# TODO:
	# '--verify': Mark game as needs verification on next launch (XXX: What option is that in the .acf? XXX: happens if Steam is running at the time?)
	#             Also, when I can do this it might be an idea for some of the above rename/delete options to imply this.
	(opts, args) = parser.parse_args()
	# TODO: If directory specified, interactively ask which game to check by name (maybe change default to do this to)

	if opts.file_filter is not None:
		opts.file_filter = [ x.replace('/', '\\') for x in opts.file_filter ]

	if len(args) == 0:
		if opts.steam_root is None:
			opts.steam_root = find_steam_root(opts)
		args = glob.glob(os.path.join(opts.steam_root, 'SteamApps/appmanifest_*.acf'))
	elif opts.steam_root is None:
		opts.steam_root = find_steam_root(opts, args[0])
	else:
		opts.steam_root = os.path.expanduser(opts.steam_root)

	if opts.verbose:
		ui._print("Using Steam root: '%s'" % opts.steam_root)

	for filename in args:
		check_acf(filename, opts)
		ui._print()