summaryrefslogtreecommitdiffstats
path: root/src/fedora-cvs.py
blob: 3ca9bb8aa49cddfc8ae67fabfc76e0d7dc7e6b33 (plain)
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
#!/usr/bin/python

import os
import string
import sys
import commands

def readUser():
    ''' sample line "Subject: C=US, ST=North Carolina, O=Fedora Project, OU=Dennis Gilmore, CN=ausil/emailAddress=dennis@ausil.us" '''
    userCert = ""
    if os.access(os.path.join(os.path.expanduser('~'),".fedora.cert"), os.R_OK):
            userCert = open(os.path.join(os.path.expanduser('~'),".fedora.cert"), "r").read()
    else:
        print "!!!    cannot read your ~/.fedora.cert file   !!!"
        print "!!! Ensure the file is readable and try again !!!"
        os.exit(1)
    for certLine in  userCert.split("\n"):
        if not len(certLine):
            continue
        stripCertLine = certLine.strip()
        if stripCertLine.startswith("Subject: "):
            subjectLine = certLine.split("CN=")
            name = subjectLine[1].split("/")
            return name[0]
      

def cvsco(user, module):
    '''CVSROOT=:ext:ausil@cvs.fedoraproject.org:/cvs/extras/'''
    print "Checking out %s from fedora cvs:" % module
    (s, o) = commands.getstatusoutput("CVSROOT=:ext:%s@cvs.fedoraproject.org:/cvs/pkgs/ CVS_RSH=ssh cvs co %s" % (user, module))
    if s != 0:
        print "Error: %s" % o
    else:
        print o

def usage():
    print """
    add the modules you wish to check out from cvs
    example fedora-cvs konversation mysql cvs mercurial
    """

def main(pkg):
    userName = readUser()
    for Item in pkg:
        cvsco(userName, Item)

if __name__ == '__main__':
    if len(sys.argv) < 2:
        usage()
        sys.exit(1)
    #the package we want to pull from cvs 
    pkg = sys.argv
    pkg.remove(sys.argv[0])

    main(pkg)