#!/usr/bin/env python

import urllib2
import json
import os
import platform

def open_browser(url):
    platform_name = platform.system()
    if platform_name == 'Darwin':
        os.system('open ' + url)
    elif platform_name == 'Windows':
        os.system('start ' + url)
    else:
        print "TBD"

def rto_main():
    redmine_url = os.environ['REDMINE_URL']
    if redmine_url[-1] != '/':
        redmine_url += '/'
    api_key = os.environ['REDMINE_API_KEY']
    rest_url = redmine_url + 'issues.json?key=' + api_key + '&status_id=open&assigned_to_id=me'
    req = urllib2.Request(rest_url)
    try:
        res = urllib2.urlopen(req)
        ret = res.read()
        data = json.loads(ret)
        for issue in data['issues']:
            issue_url = redmine_url + "issues/" + str(issue['id'])
            open_browser(issue_url)

    except urllib2.HTTPError:
        print "error"


if __name__ == '__main__':
    rto_main()

@@ -316,16 +316,29 @@
 main():%0A
+    try:%0A    
     redm
@@ -373,16 +373,109 @@
 E_URL'%5D%0A
+    except:%0A        print %22you should set REDMINE_URL environment variable.%22%0A        return%0A%0A
     if r
@@ -524,16 +524,30 @@
  += '/'%0A
+%0A    try:%0A    
     api_
@@ -582,16 +582,113 @@
 I_KEY'%5D%0A
+    except:%0A        print %22you should set REDMINE_API_KEY environment variable.%22%0A        return%0A%0A
     rest

check environment variable.