Debian Codegraph @

bin/sysopen

raw
1 #! /usr/bin/env python3
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
10 def spawn(cmd):
11 with open(os.devnull, 'w') as o:
12 subprocess.Popen(cmd, stdout=o, stderr=o)
13
14 def sysopen(arg):
15 plat = sys.platform
16 if plat.startswith('darwin'):
17 spawn(["open", arg])
18 elif plat.startswith('win'):
19 os.startfile(arg)
20 else:
21 spawn(["xdg-open", arg])
22
23 if __name__ == '__main__':
24 for a in sys.argv[1:]:
25 sysopen(a)