File: cia_arch.py

package info (click to toggle)
cia-clients 20100528
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 196 kB
  • ctags: 137
  • sloc: python: 755; perl: 585; sh: 175; makefile: 27
file content (69 lines) | stat: -rwxr-xr-x 2,042 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python

import sys
import commands
import xmlrpclib
import string

################

debug = False
server = "http://cia.vc"

# Your project name, as known by CIA. You may wish to use your
# computer's name here, as arch archives are often personal in nature.
#
# NOTE: This shouldn't be a long description of your project. Ideally
#       it is a short identifier with no spaces, punctuation, or
#       unnecessary capitalization. This will be used in URLs related
#       to your project, as an internal identifier, and in IRC messages.
#       If you want a longer name shown for your project on the web
#       interface, please use the "title" metadata key rather than
#       putting that here.
#
project = "littlegreen"

###############

archname = sys.argv[1]

category = commands.getoutput("tla parse-package-name -c "+archname)
branch = commands.getoutput("tla parse-package-name -b "+archname)
revision = commands.getoutput("tla parse-package-name -l "+archname)
if revision[0:len("patch-")] == "patch-": revision = revision[len("patch-"):]

myid = commands.getoutput("tla my-id -u")

def send(msg):
    if debug:
        print msg
        return
    xmlrpclib.ServerProxy(server).hub.deliver(msg)

def escapeToXml(text, isAttrib=0):
    text = text.replace("&", "&")
    text = text.replace("<", "&lt;")
    text = text.replace(">", "&gt;")
    if isAttrib == 1:
        text = text.replace("'", "&apos;")
        text = text.replace("\"", "&quot;")
    return text

# grab the log message from tla
patchlog = commands.getoutput("tla cat-archive-log "+archname+" | formail -X Summary: | sed 's/Summary: //'")

msg = """
<message>
  <generator> <name>arch</name> <version>1.2</version> </generator>
  <source> <project>%s</project> <module>%s</module> <branch>%s</branch> </source>
  <body>
    <commit>
      <revision>%s</revision>
      <author>%s</author>
      <log>%s</log>
    </commit>
  </body>
</message>
""" % (project, category, branch, revision, escapeToXml(myid), escapeToXml(patchlog))

send(msg)