/[gentoo]/xml/htdocs/proj/en/devrel/undertakers/scripts/retstats.py.txt
Gentoo

Contents of /xml/htdocs/proj/en/devrel/undertakers/scripts/retstats.py.txt

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Mon May 23 11:32:59 2011 UTC (3 years, 6 months ago) by hwoarang
Branch: MAIN
File MIME type: text/plain
Initial commit of retstats.py script. Update docs

1 hwoarang 1.1 #!/usr/bin/env python
2    
3     import urllib
4     import sys
5     import re
6     from BeautifulSoup import BeautifulSoup
7    
8     def usage():
9     print("""
10     **Retirement script**
11    
12     v0.1 2011-05-23
13     Markos Chandras <hwoarang@gentoo.org>
14     Developed for Gentoo Linux Undertaker Project
15    
16     usage: ./retstats <developer> <username> <password>
17    
18     <developer>: The developer you are looking for
19     <username> : Your bugzilla username
20     <password> : Your bugzilla password
21    
22     Your credentials are required when searching bugzilla history.
23     If you want to avoid using your credentials over and over you can
24     hardcode them by opening the script and adjusting the "username"
25     and "password" variables as appropriate.
26     """)
27    
28     def main():
29     try:
30     args = sys.argv
31     except getopt.GetoptError, err:
32     print(str(err))
33     if len(args) != 4:
34     usage()
35     sys.exit(1)
36    
37     # Save arguments #
38     user = args[2]+"@gentoo.org"
39     password = args[3]
40     dev = args[1]
41    
42     # Handle CIA.vc
43     print("\n----Activity Results -----")
44     string = "http://cia.vc/stats/author/"+dev+"/.rss"
45     url=urllib.urlopen(string)
46     devinfo = url.read()
47     data = BeautifulSoup(devinfo)
48     data=data.find("pubdate")
49     final=str(data).replace("<pubdate>",'').replace("+0000",'').replace("</pubdate>",'')
50    
51    
52     # Handle Bugzie
53     string = "http://bugs.gentoo.org/custom_userhistory.cgi?matchstr="+dev+"@gentoo.org"
54     # bugzie requires login
55     p = urllib.urlencode( { 'Bugzilla_login': user, 'Bugzilla_password': password} )
56    
57     url = urllib.urlopen(string,p)
58     devinfo = url.read()
59     data = BeautifulSoup(devinfo)
60     data=str(data).split("<br />")
61     pattern = re.compile(r'(\d+\-\d+\-\d+)')
62     top=pattern.search(data[1])
63    
64     # Output
65     print("developer: "+dev)
66     print("cia.vc : "+final)
67     print("Bugzie : "+top.group(0))
68    
69    
70     # Main
71     if __name__ == "__main__":
72     main()

  ViewVC Help
Powered by ViewVC 1.1.20