finalize_tags Namespace Reference

Functions

def _spawn (args, kwargs)
 
def _exec_cmd (args, kwargs)
 
def _exec_cmd_output (args, kwargs)
 
def svn (args, kwargs)
 
def svn_output (args, kwargs)
 
def svn_ci_fake
 
def basename (url)
 
def dirname (url)
 
def svn_exists (url)
 
def checkout_structure (url, proj)
 
def svn_listdir (path)
 
def main ()
 

Variables

string __author__ = "Marco Clemencic <Marco.Clemencic@cern.ch>"
 
 svn_ci_real = svn_ci
 

Function Documentation

def finalize_tags._exec_cmd (   args,
  kwargs 
)
private

Definition at line 19 of file finalize_tags.py.

19 def _exec_cmd(*args, **kwargs):
20  return apply(_spawn, args, kwargs).wait()
def _exec_cmd(args, kwargs)
def finalize_tags._exec_cmd_output (   args,
  kwargs 
)
private

Definition at line 21 of file finalize_tags.py.

21 def _exec_cmd_output(*args, **kwargs):
22  kwargs["stdout"] = PIPE
23  p = apply(_spawn, args, kwargs)
24  out = p.communicate()[0]
25  return out, p.returncode
26 
def _exec_cmd_output(args, kwargs)
def finalize_tags._spawn (   args,
  kwargs 
)
private

Definition at line 14 of file finalize_tags.py.

14 def _spawn(*args, **kwargs):
15  cmd = args
16  cwd = kwargs.get("cwd", os.getcwd())
17  print ">>>> %s: %s" % (cwd, cmd)
18  return apply(Popen, (cmd,), kwargs)
def _spawn(args, kwargs)
def finalize_tags.basename (   url)

Definition at line 47 of file finalize_tags.py.

47 def basename(url):
48  return url.rsplit("/", 1)[-1]
49 
def basename(url)
def finalize_tags.checkout_structure (   url,
  proj 
)

Definition at line 58 of file finalize_tags.py.

58 def checkout_structure(url, proj):
59  def checkout_level(base):
60  dirs = ["%s/%s" % (base, d) for d in svn_ls_output(base)[0].splitlines() if d.endswith("/")]
61  apply(svn, ["up", "-N"] + dirs)
62  return dirs
63  root = basename(url)
64  svn("co","-N", url, root)
65  old_dir = os.getcwd()
66  os.chdir(root)
67  packages = [ pkg
68  for pkg, prj in
69  [ x.split()
70  for x in [ x.strip()
71  for x in svn_pg_output("packages", ".")[0].splitlines()]
72  if x and not x.startswith("#") ]
73  if prj == proj ]
74  pkg_tag_dirs = [ proj + "/tags/" + pkg for pkg in packages ]
75  apply(svn, ["up", "-N", proj, proj + "/tags"] + pkg_tag_dirs)
76  os.chdir(old_dir)
77  return root, packages
78 
def svn(args, kwargs)
def basename(url)
def checkout_structure(url, proj)
def finalize_tags.dirname (   url)

Definition at line 50 of file finalize_tags.py.

50 def dirname(url):
51  return url.rsplit("/", 1)[1]
52 
def dirname(url)
def finalize_tags.main ( )

Definition at line 82 of file finalize_tags.py.

82 def main():
83  url = "svn+ssh://svn.cern.ch/reps/gaudi"
84  proj = "Gaudi"
85  tempdir = tempfile.mkdtemp()
86  try:
87  os.chdir(tempdir)
88 
89  # prepare repository structure (and move to its top level)
90  root, packages = checkout_structure(url, proj)
91  os.chdir(root)
92 
93  pre_rx = re.compile("(v[0-9]+r[0-9]+(p[0-9]+)?)-pre([0-9]*)")
94  for p in packages:
95  entries = svn_listdir("%s/tags/%s" %(proj, p))
96  # get the list of -pre tags in the package
97  pre_tags = [ (t.group(0), t.group(1), t.group(3))
98  for t in map(pre_rx.match, entries)
99  if t ]
100  # extract the latest -pre tag for each tag
101  tags = {}
102  for pt, t, ptv in pre_tags:
103  if ptv:
104  ptv = int(ptv)
105  else:
106  ptv = -1
107  if (t not in tags) or (tags[t][0] < ptv):
108  tags[t] = (ptv, pt)
109  # throw away unneeded information from the map
110  tags = dict(zip(tags.keys(), map(lambda a: a[1], tags.values())))
111  for tag in tags:
112  pretagdir = "%s/tags/%s/%s" %(proj, p, tags[tag])
113  tagdir = "%s/tags/%s/%s" %(proj, p, tag)
114  if tag not in entries:
115  svn_up("-N", pretagdir)
116  svn_cp(pretagdir, tagdir)
117 
118  return svn_ci()
119 
120  finally:
121  shutil.rmtree(tempdir, ignore_errors = True)
122  pass
123 
struct GAUDI_API map
Parametrisation class for map-like implementation.
def svn_listdir(path)
def checkout_structure(url, proj)
def finalize_tags.svn (   args,
  kwargs 
)

Definition at line 27 of file finalize_tags.py.

27 def svn(*args, **kwargs):
28  return apply(_exec_cmd, ["svn"] + list(args), kwargs)
29 
def svn(args, kwargs)
def finalize_tags.svn_ci_fake (   args,
  cwd = "." 
)

Definition at line 42 of file finalize_tags.py.

42 def svn_ci_fake(args, cwd = "."):
43  cmd = ["svn", "ci"] + args
44  print "(n)> %s: %s" % (cwd, cmd)
45 #svn_ci = svn_ci_fake
46 
def finalize_tags.svn_exists (   url)

Definition at line 53 of file finalize_tags.py.

53 def svn_exists(url):
54  d,b = url.rsplit("/", 1)
55  l = [x.rstrip("/") for x in svn_ls(d)]
56  return b in l
57 
def svn_exists(url)
def finalize_tags.svn_listdir (   path)

Definition at line 79 of file finalize_tags.py.

79 def svn_listdir(path):
80  return [f.rstrip("/") for f in svn_ls_output(path)[0].splitlines()]
81 
def svn_listdir(path)
def finalize_tags.svn_output (   args,
  kwargs 
)

Definition at line 30 of file finalize_tags.py.

30 def svn_output(*args, **kwargs):
31  return apply(_exec_cmd_output, ["svn"] + list(args), kwargs)
32 
def svn_output(args, kwargs)

Variable Documentation

string finalize_tags.__author__ = "Marco Clemencic <Marco.Clemencic@cern.ch>"

Definition at line 8 of file finalize_tags.py.

finalize_tags.svn_ci_real = svn_ci

Definition at line 41 of file finalize_tags.py.