cvs update non verbose output
1 2 import pexpect 3 4 def update(): 5 child = pexpect.spawn('cvs update -dP') 6 7 for line in child: 8 if not line.startswith('?') and not line.startswith('cvs update'): 9 print line[:-1]
14094 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Philippe Normand http://base-art.net/
1 2 import pexpect 3 4 def update(): 5 child = pexpect.spawn('cvs update -dP') 6 7 for line in child: 8 if not line.startswith('?') and not line.startswith('cvs update'): 9 print line[:-1]
1 2 from svn import fs, repos, core, delta 3 import difflib 4 5 def cat(path, rev, fs_ptr, taskpool): 6 """dump the contents of a file""" 7 contents = '' 8 root = fs.revision_root(fs_ptr, rev, taskpool) 9 if not len(path): 10 print "You must supply a file path." 11 return contents 12 kind = fs.check_path(root, path, taskpool) 13 if kind == core.svn_node_none: 14 print "Path '%s' does not exist." % path 15 return contents 16 if kind == core.svn_node_dir: 17 print "Path '%s' is not a file." % path 18 return contents 19 20 filelen = fs.file_length(root, path, taskpool) 21 stream = fs.file_contents(root, path, taskpool) 22 read = 0 23 while read < filelen: 24 contents += core.svn_stream_read(stream, int(core.SVN_STREAM_CHUNK_SIZE)) 25 read += len(contents) 26 contents += core.svn_stream_read(stream, int(filelen)) 27 return contents 28 29 def diff(text1, text2): 30 result = difflib.unified_diff(text1.splitlines(1), text2.splitlines(1)) 31 return ''.join(result) 32 33 def get_diff(rev, fs_ptr, pool): 34 root = fs.revision_root(fs_ptr, rev, pool) 35 editor = repos.RevisionChangeCollector(fs_ptr, rev, pool) 36 e_ptr, e_baton = delta.make_editor(editor, pool) 37 repos.svn_repos_replay(root, e_ptr, e_baton, pool) 38 39 changes = [] 40 for path, change in editor.changes.items(): 41 changes.append([path, change.base_rev]) 42 changes.sort() 43 44 final_diff = '' 45 for path, base_rev in changes: 46 text1 = cat(path, base_rev, fs_ptr, pool) 47 text2 = ccat(path, rev, fs_ptr, pool) 48 final_diff += diff(text1, text2) 49 50 return final_diff 51 52 def main(pool): 53 54 # customize this 55 repos_path = '/path/to/repository/' 56 revision = 3 57 58 repos_ptr = repos.svn_repos_open(repos_path, pool) 59 fs_ptr = repos.svn_repos_fs(repos_ptr) 60 61 print get_diff(revision, fs_ptr, pool) 62 63 core.run_app(main)
1 2 find . -type d ! \( -name "*CVS" \) -exec python cvsAdd.py {} \; 3 find . -name "*.py" -exec python cvsAdd.py {} \;
1 2 import sys, pexpect, getpass 3 4 PASS='myPass' 5 6 def cvsAdd(fname): 7 global PASS 8 if not PASS: 9 PASS = getpass.getpass() 10 11 child = pexpect.spawn('cvs add "%s"' % fname) 12 child.expect("me@my-cvs-host password:") 13 child.sendline(PASS) 14 15 for line in child: 16 print line 17 18 cvsAdd(sys.argv[1])