Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 266996
Collapse All | Expand All

(-)eclean (-7 / +22 lines)
Lines 1-9 Link Here
1
#!/usr/bin/env python
1
#!/usr/bin/python
2
# Copyright 2003-2005 Gentoo Foundation
2
# Copyright 2003-2005 Gentoo Foundation
3
# Distributed under the terms of the GNU General Public License v2
3
# Distributed under the terms of the GNU General Public License v2
4
# $Header: $
4
# $Header: $
5
5
6
7
###############################################################################
6
###############################################################################
8
# Meta:
7
# Meta:
9
__author__ = "Thomas de Grenier de Latour (tgl)"
8
__author__ = "Thomas de Grenier de Latour (tgl)"
Lines 22-27 Link Here
22
import getopt
21
import getopt
23
import fpformat
22
import fpformat
24
import signal
23
import signal
24
from __future__ import with_statement
25
try:
25
try:
26
	import portage
26
	import portage
27
except ImportError:
27
except ImportError:
Lines 678-684 Link Here
678
		                       "Do you want to delete this " \
678
		                       "Do you want to delete this " \
679
				       + file_type+"?"):
679
				       + file_type+"?"):
680
			# non-interactive mode or positive answer. 
680
			# non-interactive mode or positive answer. 
681
			# For each file,...
681
			# For each file, try to delete the file and clean it out
682
			# of Packages metadata file
683
			if action == 'packages':
684
				metadata = portage.getbinpkg.PackageIndex()
685
				with open(os.path.join(pkgdir, 'Packages')) as metadata_file:
686
					metadata.read(metadata_file)
682
			for file in clean_dict[mykey]:
687
			for file in clean_dict[mykey]:
683
				# ...get its size...
688
				# ...get its size...
684
				filesize = 0
689
				filesize = 0
Lines 688-698 Link Here
688
					except: eerror("Could not read size of "\
693
					except: eerror("Could not read size of "\
689
					               +file, myoptions['nocolor'])
694
					               +file, myoptions['nocolor'])
690
				# ...and try to delete it.
695
				# ...and try to delete it.
691
				try: os.unlink(file)
696
				try:
692
				except: eerror("Could not delete "+file, \
697
					os.unlink(file)
693
				               myoptions['nocolor'])
698
				except:
699
					eerror("Could not delete "+file, \
700
				         myoptions['nocolor'])
694
				# only count size if successfully deleted
701
				# only count size if successfully deleted
695
				else: clean_size += filesize
702
				else:
703
					clean_size += filesize
704
					if action == 'packages':
705
						metadata.packages[:] = [p for p in metadata.packages if 'CPV' in p and p['CPV'] != file]
706
				
707
			if action == 'packages':
708
				with open(os.path.join(pkgdir, 'Packages'), 'w') as metadata_file:
709
					metadata.write(metadata_file)
710
696
	# return total size of deleted or to delete files
711
	# return total size of deleted or to delete files
697
	return clean_size
712
	return clean_size
698
713

Return to bug 266996