[Bf-committers] API: How to get a list of running scripts?
hi all, I am looking for a method for conditional start of a script only if no instance of it is running already. How to get a list of running scripts through API? thanks in advance, migius ___ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers
Re: [Bf-committers] API: How to get a list of running scripts?
Do you mean the Python API? Seems like it's not possible yet... But I guess in your case, you can just have a global variable in the script (or add some property to a WindowManager) and set it to True/False accordingly. ___ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers
Re: [Bf-committers] API: How to get a list of running scripts?
Dima, yes, i meant Python API, and particularly 2.49 API. Global variables (like Blender.myvariable) are perfect for script-to-script communication but there seems to be no way to update/delete them when the script cancels unexpectedly (by user_cancel or by errors). 2012/4/11 Dima Glibitsky : > Do you mean the Python API? Seems like it's not possible yet... But I > guess in your case, you can just have a global variable in the script > (or add some property to a WindowManager) and set it to True/False > accordingly. ___ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers
Re: [Bf-committers] API: How to get a list of running scripts?
What is your script doing? Some realtime background processing? I'm not familiar with 2.49 API, and I'm not sure if this helps your case, but here's my suggestion: perhaps you can pass all the relevant data to the new instance of the script (which would continue the job), and the old one would shut down itself? I used a similar approach during the development of one of my scripts, though it was 2.5+ API. For what reasons are you still using 2.49, by the way? ___ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers
Re: [Bf-committers] API: How to get a list of running scripts?
Dima, > perhaps you can pass all the relevant data to the new instance of the > script (which would continue the job), and the old one would shut down > itself? i use something similar already, but this is not the issue. The problem stays (2.49 and 2.6x API): how to prevent user and other scripts to start next instances of running scripts. As i said before, setting a global variable as indicator of running script fails: if the script suddenly collapses there is no way to alter the variable automatically - the variable continues to indicate running status what is false. > For what reasons are you still using 2.49, by the way? > I like 2.49 for stability, decent system requirements (building/developing/usage) and good performance on old hardware (like my old portable, hehe). And for its python API. I am prototyping a CAD system and 2.49 is more than enough for this job: www.cad4arch.com/cadtools/ I have planed to migrate to 2.5x, but the new UI and API are quite different and effectively still kind of restricted in compare to 2.49 version. The combination of unified API and python driven UI is a great concept and an opportunity to create a number of easily switchable specialized UI-s for beginners, filmmakers, animators, game-developers, engineers, scientists, musicians... even in 2.25 or 2.49 style, but unfortunately the current implementation does not allow it. ___ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers
Re: [Bf-committers] API: How to get a list of running scripts?
Remigiusz, then how about incrementing a global variable each frame? Can a new instance wait one frame and then actually launch if the value of the variable hasn't changed? Anyway, seems like I'm the only one responding to this thread, and I'm in no way an expert... Have you tried to ask main developers in the IRC directly? P.S. As I've learned recently, in 2.63 (or maybe even 2.6+), there are bpy.app.handlers.scene_update_pre and bpy.app.handlers.scene_update_post -- these event handlers are invoked each frame (not sure if this behavior will persist, though). It's possible to get the list of the handlers, so I guess in recent Blender versions your idea can be implemented. ___ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers
Re: [Bf-committers] API: How to get a list of running scripts?
> how about incrementing a global variable each frame? > Can a new instance wait one frame and then actually launch if the > value of the variable hasn't changed? > my scripts are triggered by "Redraw" not by "Frame change", so i have thought about time stamps and delay value checks, but it is not reliable, because the idle periods may be unpredictable long. > Anyway, seems like I'm the only one responding to this thread, and I'm > in no way an expert... Have you tried to ask main developers in the > IRC directly? > asked Campbell, and the answer is, 2.49 API doesn't support this. Though it should be easy to extend - i have to look at Blender.Scene.getScriptLinks() method. > As I've learned recently, in 2.63 (or maybe even 2.6+), there are > bpy.app.handlers.scene_update_pre and > bpy.app.handlers.scene_update_post -- these event handlers are invoked > each frame (not sure if this behavior will persist, though). It's > possible to get the list of the handlers, so I guess in recent Blender > versions your idea can be implemented. > i am keeping my eyes on 2.6, but awaiting significant moves in UI+API area after bmesh integration at first. ___ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers
Re: [Bf-committers] API: How to get a list of running scripts?
Hi, If this is about an addon, there seems to be a function to check if it is running: import addon_utils addon_utils.check('space_view3d_3d_navigation') If not then it seems more difficult. I might be wrong here, but I think in that case there isn't really any running 'script object' that exists. There might be python objects in memory that were created by the script, like functions that were installed as handlers somewhere, but it's just bits of data attached in various places. An error in the code will not remove those python objects, they stick around until you actually go and delete them. Brecht. On Wed, Apr 11, 2012 at 3:40 AM, Remigiusz Fiedler wrote: > hi all, > I am looking for a method for conditional start of a script only if no > instance of it is running already. > How to get a list of running scripts through API? > > thanks in advance, > migius > ___ > Bf-committers mailing list > Bf-committers@blender.org > http://lists.blender.org/mailman/listinfo/bf-committers ___ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers
Re: [Bf-committers] API: How to get a list of running scripts?
Brecht, thanks. I am still on 2.49 though. I think it should be possible to use the same method the popup list uses for switching between running scripts in scripts viewport. ___ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers