+ Reply to Thread
Results 1 to 9 of 9

Thread: Server Busy popup when starting external process

  1. #1

    Server Busy popup when starting external process

    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.

  2. #2
    Senior Member Steve Baer's Avatar
    Join Date
    Apr 2010
    Location
    Seattle
    Posts
    1,472
    Blog Entries
    19
    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?

  3. #3
    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?

  4. #4
    Senior Member Steve Baer's Avatar
    Join Date
    Apr 2010
    Location
    Seattle
    Posts
    1,472
    Blog Entries
    19
    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 System
      import Rhino
       
      def shellexectest():
          app = "C:\\dev\\rhino\\usr\\Steve\\TimeWaster\\TimeWaster.exe"
          process = System.Diagnostics.Process.Start(app)
          tick_count = 0
          while not process.WaitForExit(100):
              tick_count += 1
              if tick_count>10: tick_count = 1
              Rhino.RhinoApp.SetCommandPrompt("Waiting" + "."*tick_count)
              Rhino.RhinoApp.Wait()
       
      shellexectest()

  5. #5
    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.

  6. #6
    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/

  7. #7
    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].

  8. #8
    Senior Member Steve Baer's Avatar
    Join Date
    Apr 2010
    Location
    Seattle
    Posts
    1,472
    Blog Entries
    19
    Hi Ralph,
    I'll add a definition for __file__ in the next beta.
    Thanks,
    -Steve

  9. #9
    this helped me for a similar problem while waiting for Illustartor COM to react:
    Code:
    import Rhino
    Rhino.Runtime.HostUtils.DisplayOleAlerts(False)

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts