2
from common import get_dir_size
3
from common import confirm_filesize_unit
10
def get_apt_cache(self):
11
apt_cache = '/var/cache/apt/archives'
12
#aptcachelist = map(lambda filename: '%s/%s<2_2>%s' % (apt_cache, filename, str(os.path.getsize('%s/%s' % (apt_cache, filename)))), filter(lambda filestr: filestr.endswith('deb'), os.listdir(apt_cache)))
13
aptcachelist = ['%s/%s<2_2>%s' % (apt_cache,filename, confirm_filesize_unit(os.path.getsize('%s/%s' % (apt_cache, filename)))) for filename in os.listdir(apt_cache) if filename.endswith('deb')]
16
def scan_apt_cache(self, path):
18
if os.path.exists(path):
19
aptcache_list = ['%s/%s' % (path, filename) for filename in os.listdir(path) if filename.endswith('deb')]
23
def public_scan_cache(self, path):
25
if os.path.exists(path):
26
publiccache_list = ['%s/%s' % (path, filename) for filename in os.listdir(path)]
28
return publiccache_list
30
def firefox_scan_cache(self, path):
31
firefoxcache_list = []
32
if os.path.exists(path):
33
firefoxcache_list = ['%s/%s' % (path, filename) for filename in os.listdir(path) if filename in 'Cache']
34
return firefoxcache_list
36
def get_softwarecenter_cache(self, homedir):
39
softwarecenter_cache = '%s/.cache/software-center/' % homedir
41
softwarecenter_cache = os.path.expanduser('~/.cache/software-center/')
42
full_path = softwarecenter_cache
43
if os.path.exists(full_path):
44
for one in os.listdir(full_path):
45
tmp_path = full_path + one
46
if os.path.isdir(tmp_path):
47
size = get_dir_size(tmp_path)
48
centercachelist.append('%s<2_2>%s' % (tmp_path, confirm_filesize_unit(size)))
50
centercachelist.append('%s<2_2>%s' % (tmp_path, confirm_filesize_unit(os.path.getsize(tmp_path))))
51
return centercachelist
53
if __name__ == "__main__":
56
obja.get_softwarecenter_cache()