mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-11 09:13:57 -04:00
OS X build: If setting up ASL fails, redirect to /dev/null to ensure we dont get errors writing to stdout
This commit is contained in:
parent
d7d35b16e9
commit
72a30b9c9e
@ -181,16 +181,23 @@ def setup_asl():
|
|||||||
return
|
return
|
||||||
if asl_log_descriptor(cl, msg, ASL_LEVEL_NOTICE, sys.stderr.fileno(), ASL_LOG_DESCRIPTOR_WRITE) != 0:
|
if asl_log_descriptor(cl, msg, ASL_LEVEL_NOTICE, sys.stderr.fileno(), ASL_LOG_DESCRIPTOR_WRITE) != 0:
|
||||||
return
|
return
|
||||||
|
return True
|
||||||
|
|
||||||
|
def nuke_stdout():
|
||||||
|
# Redirect stdout, stdin and stderr to /dev/null
|
||||||
|
from calibre.constants import plugins
|
||||||
|
plugins['speedup'][0].detach(os.devnull)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
global __file__
|
global __file__
|
||||||
|
asl_ok = True
|
||||||
|
|
||||||
if sys.calibre_is_gui_app and not (
|
if sys.calibre_is_gui_app and not (
|
||||||
sys.stdout.isatty() or sys.stderr.isatty() or sys.stdin.isatty()):
|
sys.stdout.isatty() or sys.stderr.isatty() or sys.stdin.isatty()):
|
||||||
try:
|
try:
|
||||||
setup_asl()
|
asl_ok = setup_asl()
|
||||||
except:
|
except:
|
||||||
pass # Failure to log to Console.app is not critical
|
asl_ok = False
|
||||||
|
|
||||||
# Needed on OS X <= 10.8, which passes -psn_... as a command line arg when
|
# Needed on OS X <= 10.8, which passes -psn_... as a command line arg when
|
||||||
# starting via launch services
|
# starting via launch services
|
||||||
@ -206,4 +213,10 @@ def main():
|
|||||||
add_calibre_vars(base)
|
add_calibre_vars(base)
|
||||||
addsitedir(sys.site_packages)
|
addsitedir(sys.site_packages)
|
||||||
|
|
||||||
|
if not asl_ok:
|
||||||
|
try:
|
||||||
|
nuke_stdout()
|
||||||
|
except Exception:
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
return run_entry_point()
|
return run_entry_point()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user