add motd generator script
[freebsd-maintainer-scripts/.git] / ftabs.py
1 #!/usr/bin/env python
2
3 import os
4 import webbrowser
5 import sys
6
7 username = os.environ.get('USER') or 'sbz'
8 g_label = "freebsd/freebsd-{}".format(username)
9 g_link = "https://mail.google.com/mail/u/0/?tab=wm#label/{}".format(g_label)
10 out_link = "http://portscout.freebsd.org/{}@freebsd.org.html".format(username)
11 bts_args = "?email1={}%40FreeBSD.org&order=changeddate&resolution=---"
12 bts_args = bts_args.format(username)
13 bts_link = "https://bugs.freebsd.org/bugzilla/buglist.cgi{}"
14 repo_link = "https://repology.org/maintainer/{}%40freebsd.org".format(username)
15
16
17 class URL(object):
18     def __init__(self, **kwargs):
19         self.link = kwargs.get("link")
20         self.desc = kwargs.get("desc", "N/A")
21         self.abrv = kwargs.get("abrv", "N/A")
22
23     def link(self):
24         return self.link
25
26     def desc(self):
27         return self.desc
28
29     def abrv(self):
30         return self.abrv.upper()
31
32 URLS = [
33     URL(link="https://reviews.freebsd.org/", desc="code review", abrv="cr"),
34     URL(link=bts_link.format(bts_args), desc="bug tracking", abrv="bts"),
35     URL(link="https://github.com/freebsd/", desc="github", abrv="gh"),
36     URL(link="https://svnweb.freebsd.org/", desc="code browser", abrv="cb"),
37     URL(link=out_link, desc="portcout", abrv="pc"),
38     URL(link=repo_link, desc="repology", abrv="rl"),
39     URL(link=g_link, desc="freebsd-{}".format(username), abrv="gmail"),
40     URL(link="https://wiki.freebsd.org", desc="wiki", abrv="wk"),
41     URL(link="http://beefy6.nyi.freebsd.org/", desc="builder status",
42         abrv="build"),
43     URL(link="https://secure.freshbsd.org/search?project=freebsd",
44         desc="commit stats", abrv="stats"),
45     URL(link="http://grok.dragonflybsd.org/source/xref/freebsd/",
46         desc="xref browser", abrv="xref"),
47 ]
48
49
50 def main():
51     rc = 1
52     browser = webbrowser.get()
53     for url in URLS:
54         ret = browser.open_new_tab(url.link)
55         if ret is False:  # cannot open the link, try next one
56             rc = 0
57             continue
58
59     return rc
60
61 if __name__ == "__main__":
62     sys.exit(main())