#!/usr/bin/env python

import subprocess
import sys

try:
    # Python 3
    from urllib.error import URLError
    from urllib.request import urlopen
except ImportError:
    # Python 2
    from urllib2 import URLError, urlopen


URL = ('https://raw.githubusercontent.com/reviewboard/pysvn-installer/'
       'master/install.py')


try:
    script = urlopen(URL).read()
except URLError as e:
    sys.stderr.write('Unable to fetch %s: %s\n' % (URL, e))
    sys.exit(1)


p = subprocess.Popen([sys.executable] + sys.argv[1:],
                     stdin=subprocess.PIPE)
p.communicate(input=script)
sys.exit(p.wait())
