from Caches import * def cachetruster(cache): if caches.count(creg.url(cache))==0 and not cache=='*': if creg.has(cache): if switch('trust-all-caches') or switch('trust-registered-caches') or yesno('Do you want to trust the registered cache ['+cache+']?'): caches.append(creg.url(cache)) if switch('trust-all-caches') or switch('trust-registered-caches') or yesno('Do you want to add the registered cache ['+cache+'] to your caches file?'): f = open('caches','r') g = open('xxxtmpcaches','w') lines = f.readlines() already = 0 for line in lines: g.write(line) if line[:-1]==cache: already = 1 if not already: g.write(cache+'\n') f.close() g.close() os.system('rm -f caches; mv xxxtmpcaches caches') else: print "Pacman command can't proceed without trust of ["+cache+"]." print "Only trust a cache if you are sure of it's location and management." sys.exit() else: if switch('trust-all-caches') or yesno('Do you want to trust the unregistered cache ['+cache+']?'): caches.append(cache) if switch('trust-all-caches') or yesno('Do you want to add the unregistered cache ['+cache+'] to your caches file?'): f = open('caches','r') g = open('xxxtmpcaches','w') lines = f.readlines() for line in lines: g.write(line) g.write(cache+'\n') f.close() g.close() os.system('rm -f caches; mv xxxtmpcaches caches') else: print "Pacman command can't proceed without trust of ["+cache+"]." print "Only trust a cache if you are sure of it's location and management." sys.exit()