Browse Source

Fail more gracefully if LyX isn't installed

If LyX isn't installed, LYXPATH will get set to "/bin/false", which will
cause the task to fail, but still doesn't give a satisfactory error
message. I suspect the real solution is to create a task whose only job
is to locate and store the path to LyX and make it a dependency of the
lyx2pdf task.
Ryan C. Thompson 9 years ago
parent
commit
e9d1261a3c
1 changed files with 10 additions and 4 deletions
  1. 10 4
      dodo.py

+ 10 - 4
dodo.py

@@ -53,9 +53,12 @@ scalar argument.
     return result
 
 def find_mac_app(name):
-    return check_output(
-        ["mdfind",
-         "kMDItemDisplayName==%s&&kMDItemKind==Application" % (name,) ]).strip()
+    try:
+        return check_output(
+            ["mdfind",
+             "kMDItemDisplayName==%s&&kMDItemKind==Application" % (name,) ]).strip()
+    except Exception:
+        return None
 
 def glob_recursive(pattern, top=".", include_hidden=False, *args, **kwargs):
     """Combination of glob.glob and os.walk.
@@ -72,7 +75,8 @@ os.walk."""
                 yield os.path.normpath(os.path.join(path, f))
 
 LYXPATH = find_executable("lyx") or \
-    os.path.join(find_mac_app("LyX"), "Contents/MacOS/lyx")
+    os.path.join(find_mac_app("LyX"), "Contents/MacOS/lyx") or \
+    '/bin/false'
 
 @kwonly(0)
 def rsync_list_files(extra_rsync_args=(), include_dirs=False, *paths):
@@ -107,6 +111,8 @@ def task_lyx2pdf():
         yield {
             'name': lyxfile,
             'actions': [lyx_cmd],
+            # Assume every bib file is a dependency of any LaTeX
+            # operation
             'file_dep': [lyxfile] + list(glob_recursive('*.bib')),
             'targets': [pdffile],
             'verbosity': 0,