blob: 84100c2187f0a77150711d0b797e70d0d7e5850d [file] [log] [blame]
Hal Canaryd7b38452017-12-11 17:46:26 -05001#! /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
6import os
7import subprocess
8import sys
9
Hal Canaryba160282019-04-19 14:38:59 -040010def spawn(cmd):
11 with open(os.devnull, 'w') as o:
12 subprocess.Popen(cmd, stdout=o, stderr=o)
13
Hal Canaryd7b38452017-12-11 17:46:26 -050014def sysopen(arg):
15 plat = sys.platform
16 if plat.startswith('darwin'):
Hal Canaryba160282019-04-19 14:38:59 -040017 spawn(["open", arg])
Hal Canaryd7b38452017-12-11 17:46:26 -050018 elif plat.startswith('win'):
19 os.startfile(arg)
20 else:
Hal Canaryba160282019-04-19 14:38:59 -040021 spawn(["xdg-open", arg])
Hal Canaryd7b38452017-12-11 17:46:26 -050022
23if __name__ == '__main__':
24 for a in sys.argv[1:]:
25 sysopen(a)