add ftabs script which allow me to open freebsd related tabs on my
authorSofian Brabez <sbz@6dev.net>
Wed, 15 Jun 2016 19:03:06 +0000 (21:03 +0200)
committersbz <sbz@6dev.net>
Wed, 15 Jun 2016 19:03:06 +0000 (21:03 +0200)
browser at once

ftabs [new file with mode: 0755]

diff --git a/ftabs b/ftabs
new file mode 100755 (executable)
index 0000000..04a1609
--- /dev/null
+++ b/ftabs
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+
+import os
+import webbrowser
+import sys
+
+username = os.environ.get('USER') or 'sbz'
+g_label = "freebsd/freebsd-{}".format(username)
+g_link = "https://mail.google.com/mail/u/0/?tab=wm#label/{}".format(g_label)
+out_link = "http://portscout.freebsd.org/{}@freebsd.org.html".format(username)
+bts_args = "?email1={}%40FreeBSD.org&order=changeddate&resolution=---"
+bts_args = bts_args.format(username)
+bts_link = "https://bugs.freebsd.org/bugzilla/buglist.cgi{}"
+
+
+class URL(object):
+    def __init__(self, **kwargs):
+        self.link = kwargs.get("link")
+        self.desc = kwargs.get("desc", "N/A")
+        self.abrv = kwargs.get("abrv", "N/A")
+
+    def link(self):
+        return self.link
+
+    def desc(self):
+        return self.desc
+
+    def abrv(self):
+        return self.abrv.upper()
+
+URLS = [
+    URL(link="https://reviews.freebsd.org/", desc="code review", abrv="cr"),
+    URL(link=bts_link.format(bts_args), desc="bug tracking", abrv="bts"),
+    URL(link="https://github.com/freebsd/", desc="github", abrv="gh"),
+    URL(link="https://svnweb.freebsd.org/", desc="code browser", abrv="cb"),
+    URL(link=out_link, desc="portcout", abrv="pc"),
+    URL(link=g_link, desc="freebsd-{}".format(username), abrv="gmail"),
+    URL(link="https://wiki.freebsd.org", desc="wiki", abrv="wk"),
+    URL(link="http://beefy6.nyi.freebsd.org/", desc="builder status",
+        abrv="build"),
+    URL(link="https://secure.freshbsd.org/search?project=freebsd",
+        desc="commit stats", abrv="stats"),
+    URL(link="http://grok.dragonflybsd.org/source/xref/freebsd/",
+        desc="xref browser", abrv="xref"),
+]
+
+
+def main():
+    rc = 1
+    browser = webbrowser.get()
+    for url in URLS:
+        ret = browser.open_new_tab(url.link)
+        if ret is False:  # cannot open the link, try next one
+            rc = 0
+            continue
+
+    return rc
+
+if __name__ == "__main__":
+    sys.exit(main())