mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-02-07 05:31:21 +00:00
Added open_file to misc utils.
A function to open a file using an associated launcher in an OS-agnostic way.
This commit is contained in:
parent
61b834e52c
commit
8e340e456d
@ -701,3 +701,16 @@ def unique(alist):
|
|||||||
if item not in result:
|
if item not in result:
|
||||||
result.append(item)
|
result.append(item)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def open_file(filepath):
|
||||||
|
"""
|
||||||
|
Open the specified file path with the associated launcher in an OS-agnostic way.
|
||||||
|
|
||||||
|
"""
|
||||||
|
if os.name == 'nt': # Windows
|
||||||
|
return os.startfile(filepath) # pylint: disable=no-member
|
||||||
|
elif sys.platform == 'darwin': # Mac OSX
|
||||||
|
return subprocess.call(['open', filepath])
|
||||||
|
else: # assume Linux or similar running a freedesktop-compliant GUI
|
||||||
|
return subprocess.call(['xdg-open', filepath])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user