Add open_file() RPC method
This commit is contained in:
parent
2c9c0da501
commit
51a5510b38
1 changed files with 21 additions and 0 deletions
|
@ -2219,6 +2219,27 @@ class Daemon(AuthJSONRPCServer):
|
|||
|
||||
return d
|
||||
|
||||
@AuthJSONRPCServer.auth_required
|
||||
def jsonrpc_open_file(self, p):
|
||||
"""
|
||||
Instruct the OS to open a file.
|
||||
|
||||
Args:
|
||||
'path': path of file to be opened
|
||||
Returns:
|
||||
True, opens file
|
||||
"""
|
||||
path = p['path']
|
||||
if sys.platform == 'darwin':
|
||||
d = threads.deferToThread(subprocess.Popen, ['open', path])
|
||||
elif os.name == 'posix':
|
||||
d = threads.deferToThread(subprocess.Popen, ['xdg-open', path])
|
||||
elif sys.platform == 'win32':
|
||||
d = threads.deferToThread(os.startfile, path)
|
||||
|
||||
d.addCallback(lambda _: self._render_response(True, OK_CODE))
|
||||
return d
|
||||
|
||||
@AuthJSONRPCServer.auth_required
|
||||
def jsonrpc_reveal(self, p):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue