I use a construct as:
if os.system("ex.exe")>0:do_something()
Thex execution time is about a minute. clicking than into the rhino shows an annoying popup talking something like server busy. How could I prevent this.
I use a construct as:
if os.system("ex.exe")>0:do_something()
Thex execution time is about a minute. clicking than into the rhino shows an annoying popup talking something like server busy. How could I prevent this.
What do you want Rhino to do while you are waiting for the exe to complete? Do you want to pop up some other sort of message box?
Why not showing a popup or maybe just a busy cursor, but the main problem is the annoying message. Would showing a popup solve the problem?
Not exactly. I'm just trying to understand what you want your script to do so I can think of a solution. I'm thinking you could do something like the following
Python Code:
import Systemimport Rhinodef shellexectest():app = "C:\\dev\\rhino\\usr\\Steve\\TimeWaster\\TimeWaster.exe"process = System.Diagnostics.Process.Start(app)tick_count = 0while not process.WaitForExit(100):tick_count += 1if tick_count>10: tick_count = 1Rhino.RhinoApp.SetCommandPrompt("Waiting" + "."*tick_count)Rhino.RhinoApp.Wait()shellexectest()
Thanks a lot that works. I had to use System.Diagnostics.Process.Start(app,arg). I'v got a question on the path for the executed file. This is actually code which will be executed from the embedded IDE through run. Is it secure to use os.getcwd() in this situation to get the executed files path? The normal way in CPython would be to use the __file__ var but you do not set this in your IDE.
os.getcwd() would return the working directory of your running instance of python, and not the location of the .exe file.
__file__ only works on imported modules.
Are you passing in the exe file path as an argument?
Do you already know the path, but simply want to manipulate the path for use in other parts of the script or are you trying to find the file?
If you know the path, but want to manipulate it (for example, to create new files in similar locations to the exe), python's os.path module would probably be helpful:
http://docs.python.org/library/os.path.html
Here's an example of finding a file using python:
http://code.activestate.com/recipes/...-subdirectory/
I do not want to use walk. The subdirectory could exists multiple times and the approach is too slow.
It would be nice to have the __file__ variable set by the Rhino's IDE if possible. This is supported by all Python IDE's I tried so far. Using relative paths should be possible. A workaround I found is to use sys.path[0].
Hi Ralph,
I'll add a definition for __file__ in the next beta.
Thanks,
-Steve
this helped me for a similar problem while waiting for Illustartor COM to react:
Code:import Rhino Rhino.Runtime.HostUtils.DisplayOleAlerts(False)