Go to:
Gentoo Home
Documentation
Forums
Lists
Bugs
Planet
Store
Wiki
Get Gentoo!
Gentoo's Bugzilla – Attachment 25290 Details for
Bug 33877
include distfiles-clean into gentoolkit
Home
|
New
–
[Ex]
|
Browse
|
Search
|
Privacy Policy
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
yadc.py
ultimate-distfiles-clean.py (text/plain), 3.55 KB, created by
TGL
on 2004-02-09 13:12:44 UTC
(
hide
)
Description:
yadc.py
Filename:
MIME Type:
Creator:
TGL
Created:
2004-02-09 13:12:44 UTC
Size:
3.55 KB
patch
obsolete
>#!/usr/bin/env python >#from: http://forums.gentoo.org/viewtopic.php?t=3011 > >import sys, os, string, re, getopt, fpformat, signal >import portage >from output import * > >progname = os.path.basename(sys.argv[0]) >distdir = portage.settings["DISTDIR"] >cachedir = "/var/cache/edb/dep" >pretend = False >quiet = False >ask = False >accept_all = False >keep = [] >file_regexp = re.compile('([a-zA-Z0-9_,\.\-\+]*)[\s\)]') > >def exitsig(signum, frame): > sys.exit(128+signum) >signal.signal(signal.SIGINT, exitsig) > >def visit(spam, dir, filelist): > global keep > for file in filelist: > if not file[-8:] == '.cpickle': > path = os.path.join(dir, file) > try: > f = open(path) > src_uri = f.readlines()[3] > except: pass > else: > f.close() > keep += file_regexp.findall(src_uri) > >def usage(out): > print >>out, "Usage:", progname, "[option]..." > print >>out, "Available options:" > print >>out, "-a, --ask ask confirmation before deleting files" > print >>out, "-h, --help display this short help message" > print >>out, "-p, --pretend display files names, but don't actually delete them" > print >>out, "-q, --quiet be as quiet as possible" > >def prettysize(size,pretty=False): > units = [" G"," M"," K"] > size = size / 1024. > while len(units) and size > 1024: > size = size / 1024. > units.pop() > sizestr = fpformat.fix(size,2)+units[-1] > if pretty: sizestr = blue("[ ")+" "*(8-len(sizestr))+green(sizestr)+blue(" ]") > return sizestr > >def ask_prompt(): > import tty, termios > fd = sys.stdin.fileno() > origtty = termios.tcgetattr(fd) > ch='x' > try: > tty.setcbreak(fd) > while not string.lower(ch) in 'yna': > sys.stdout.write("Do you want to delete this file (n/y/a): ") > sys.stdout.flush() > ch = sys.stdin.read(1) > sys.stdout.write(ch) > finally: > sys.stdout.write('\n') > sys.stdout.flush() > termios.tcsetattr(fd, termios.TCSADRAIN, origtty) > if string.lower(ch) == 'a': > global accept_all > accept_all = True > myanswer = (string.lower(ch) in 'ya') > return myanswer > >try: opts, args = getopt.getopt(sys.argv[1:], "ahpq", ["ask", "help", "pretend", "quiet"]) >except getopt.GetoptError: > usage(sys.stderr) > sys.exit(2) >for o, a in opts: > if o in ("-h", "--help"): > usage(sys.stdout) > sys.exit(0) > if o in ("-a", "--ask") and not pretend: > ask = True > if o in ("-p", "--pretend"): > pretend = True > ask = False > if o in ("-q", "--quiet"): > quiet = True > >if not pretend and portage.secpass != 2: > print >>sys.stderr, "Permission denied: you must be root to actually delete some files." > sys.exit(1) > >if not quiet: > print " "+green("*"),"Building file list..." > >os.path.walk(cachedir, visit, None) > >remove = {} >for file in os.listdir(distdir): > if file not in keep: > file = os.path.join(distdir, file) > if os.path.isfile(file): > remove[file]=os.path.getsize(file) > >mykeys = remove.keys() >mykeys.sort() > >if len(mykeys): > if pretend and not quiet: > print " "+green("*"),"Here are files that would be deleted:" > elif not quiet: > print " "+green("*"),"Cleaning distfiles..." >else: > if not quiet: > print " "+green("*"),"Your distfiles was already clean." > sys.exit(0) > >totalsize = 0 >for file in mykeys: > if pretend or ask: > if quiet: print file > else: print prettysize(remove[file],True)," "+teal(file) > if pretend: > totalsize += remove[file] > elif not ask or accept_all or ask_prompt(): > try: os.remove(file) > except: print >>sys.stderr, "Could not remove", file > else: totalsize += remove[file] > >if not quiet: > if pretend: > print " "+green("*"),"Total space that would be freed:",red(prettysize(totalsize)) > else: > print " "+green("*"),"Total space that has been freed:",red(prettysize(totalsize)) > >sys.exit(0)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 33877
:
20965
|
25211
|
25290
|
25298
|
25498
|
29493
|
32982
|
53397
|
62807
|
62908
|
67046
|
67047
|
67081
|
67082