[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [1862] trunk/py/scripts/addons/ render_povray/render.py: Added Linux Binary detection thanks to Bela Mihalik's patch.

Maurice Raybaud mauriceraybaud at hotmail.fr
Sun Apr 24 15:03:31 CEST 2011


Revision: 1862
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=1862
Author:   mauriceraybaud
Date:     2011-04-24 13:03:31 +0000 (Sun, 24 Apr 2011)
Log Message:
-----------
Added Linux Binary detection thanks to Bela Mihalik's patch.

Modified Paths:
--------------
    trunk/py/scripts/addons/render_povray/render.py

Modified: trunk/py/scripts/addons/render_povray/render.py
===================================================================
--- trunk/py/scripts/addons/render_povray/render.py	2011-04-24 11:09:44 UTC (rev 1861)
+++ trunk/py/scripts/addons/render_povray/render.py	2011-04-24 13:03:31 UTC (rev 1862)
@@ -1707,11 +1707,38 @@
             # DH - added -d option to prevent render window popup which leads to segfault on linux
             extra_args.append("-d")
 
-            # TODO, when POV-Ray isn't found this can probably still give a cryptic error on linux,
-            # would be nice to be able to detect if it exists
+            isExists = False
+            sysPathList = os.getenv("PATH").split(':')
+            sysPathList.append("")
 
-            print("Command line arguments passed: " + str(extra_args))
+            for dirName in sysPathList:
+                if (os.path.exists(os.path.join(dirName, pov_binary))):
+                    isExists = True
+                    break
 
+            if not isExists:
+                print("POV-Ray 3.7: could not found execute '%s' - not if PATH" % pov_binary)
+                import traceback
+                traceback.print_exc()
+                print ("***-DONE-***")
+                return False
+
+            try:
+                self._process = subprocess.Popen([pov_binary, self._temp_file_ini] + extra_args)
+
+            except OSError:
+                # TODO, report api
+                print("POV-Ray 3.7: could not execute '%s'" % pov_binary)
+                import traceback
+                traceback.print_exc()
+                print ("***-DONE-***")
+                return False
+
+            else:
+                print("POV-Ray 3.7 found")
+                print("Command line arguments passed: " + str(extra_args))
+                return True
+
     def _cleanup(self):
         for f in (self._temp_file_in, self._temp_file_ini, self._temp_file_out):
             try:



More information about the Bf-extensions-cvs mailing list