mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
7373d2362a
commit
2be0d6a650
@ -845,6 +845,8 @@ def viewer_main():
|
|||||||
render_for_viewer(*args)
|
render_for_viewer(*args)
|
||||||
|
|
||||||
|
|
||||||
|
# QuickLook {{{
|
||||||
|
|
||||||
def quicklook(pathtoebook: str, output_dir: str) -> dict[str, object]:
|
def quicklook(pathtoebook: str, output_dir: str) -> dict[str, object]:
|
||||||
pathtoebook = os.path.abspath(pathtoebook)
|
pathtoebook = os.path.abspath(pathtoebook)
|
||||||
output_dir = os.path.abspath(output_dir)
|
output_dir = os.path.abspath(output_dir)
|
||||||
@ -880,10 +882,10 @@ def handle_quicklook_client(c) -> None:
|
|||||||
return
|
return
|
||||||
req = json.loads(line)
|
req = json.loads(line)
|
||||||
try:
|
try:
|
||||||
output = {'ok': True, 'result': quicklook(req['path'], req['output_dir'])}
|
output = {'ok': True, 'path': req['path'], 'result': quicklook(req['path'], req['output_dir'])}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
import traceback
|
import traceback
|
||||||
output = {'ok': False, 'error': str(e), 'traceback': traceback.format_exc()}
|
output = {'ok': False, 'path': req['path'], 'error': str(e), 'traceback': traceback.format_exc()}
|
||||||
with c.makefile('w', encoding='utf-8') as outf:
|
with c.makefile('w', encoding='utf-8') as outf:
|
||||||
json.dump(output, outf)
|
json.dump(output, outf)
|
||||||
print(file=outf, flush=True)
|
print(file=outf, flush=True)
|
||||||
@ -938,6 +940,8 @@ def quicklook_service(path_to_socket: str) -> None:
|
|||||||
c.shutdown(socket.SHUT_RDWR)
|
c.shutdown(socket.SHUT_RDWR)
|
||||||
c.close()
|
c.close()
|
||||||
|
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
class Profiler:
|
class Profiler:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user