Hal Canary | d7b3845 | 2017-12-11 17:46:26 -0500 | [diff] [blame] | 1 | #! /usr/bin/env python2 |
| 2 | # Copyright 2017 Google Inc. |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | import os |
| 7 | import subprocess |
| 8 | import sys |
| 9 | |
Hal Canary | ba16028 | 2019-04-19 14:38:59 -0400 | [diff] [blame] | 10 | def spawn(cmd): |
| 11 | with open(os.devnull, 'w') as o: |
| 12 | subprocess.Popen(cmd, stdout=o, stderr=o) |
| 13 | |
Hal Canary | d7b3845 | 2017-12-11 17:46:26 -0500 | [diff] [blame] | 14 | def sysopen(arg): |
| 15 | plat = sys.platform |
| 16 | if plat.startswith('darwin'): |
Hal Canary | ba16028 | 2019-04-19 14:38:59 -0400 | [diff] [blame] | 17 | spawn(["open", arg]) |
Hal Canary | d7b3845 | 2017-12-11 17:46:26 -0500 | [diff] [blame] | 18 | elif plat.startswith('win'): |
| 19 | os.startfile(arg) |
| 20 | else: |
Hal Canary | ba16028 | 2019-04-19 14:38:59 -0400 | [diff] [blame] | 21 | spawn(["xdg-open", arg]) |
Hal Canary | d7b3845 | 2017-12-11 17:46:26 -0500 | [diff] [blame] | 22 | |
| 23 | if __name__ == '__main__': |
| 24 | for a in sys.argv[1:]: |
| 25 | sysopen(a) |