Forum Coordinators: RedPhantom
Poser - OFFICIAL F.A.Q (Last Updated: 2024 Nov 24 8:11 pm)
The script doesn't behave on my Mac with PP2010. When I double-click a script nothing happens at all - it doesn't work and I get no error messages.
The script allows me to choose a python editor and the "Edit script" option in the menu isn't greyed out anymore but I can't actually edit anything - when I choose edit nothing happens.
I downloaded Dizzi's script as well and it seems to work, at least the simple scripts I tried with it:
Quote - The script doesn't behave on my Mac with PP2010. When I double-click a script nothing happens at all - it doesn't work and I get no error messages.
The script allows me to choose a python editor and the "Edit script" option in the menu isn't greyed out anymore but I can't actually edit anything - when I choose edit nothing happens.
I downloaded Dizzi's script as well and it seems to work, at least the simple scripts I tried with it:
Hmm...
Well if you are willing I can get with you via email and see if I can get it to work better with mac. I don't have a mac to test with locally so I had to make some guesses. Shoot me a Rendo pm if you are interested.
.
Hope this gives a clue...
"If I were a shadow, I know I wouldn't like to be half of
what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki
Murakami)
I can get it to run scripts by taking the appended 'ScriptsMenu' text out of the 'self.root = ' string assignment (in the class definition), but of course the Menu then shows the contents of the poserScripts folder instead of the ScriptsMenu folder.
I can't do any more detective work tonight (or rather, this morning)... I'm off to bed.
"If I were a shadow, I know I wouldn't like to be half of
what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki
Murakami)
It's cool, thanks for your help so far.
self.root = os.path.join(os.path.dirname(poser.AppLocation()), 'Runtime', 'Python', 'poserScripts', 'ScriptsMenu') code is identical to Dizzi's script
that "should" be saying find the location of poser.exe or poserpro.exe and build a path adding Runtime:Python:poserScripts:ScriptsMenu
Is the ScriptsMenu folder somewhere different on mac?
From your debug info, I don't know why it's adding scriptsmenu twice..
The changes here (pathPyc, pathPy), were added to detect if that extension exists to the particular file it's trying to run since I reduced the filenames from MyScript.py (for example) to MyScript. It's kind-of a "kludge" approach, I would have to admit.
.
I'm at work sans Poser, but I can do some more debugging as soon as I get home this afternoon. I was just beginning to sort out the code last night, but I was running a bit low on concentration - too sleepy.
Quote - Is the ScriptsMenu folder somewhere different on mac?
Nope, it's exactly the same path to that folder.
Quote - that "should" be saying find the location of poser.exe or poserpro.exe and build a path adding Runtime:Python:poserScripts:ScriptsMenu
I didn't specifically check the results of this assignment, but I'm almost certain it's working correctly. The extra 'ScriptsMenu' level is being added to the path after building the menu tree, but before trying to execute the activated menu item. I'll track it down.
"If I were a shadow, I know I wouldn't like to be half of
what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki
Murakami)
Okay, I've taken a slightly different approach and I'm hoping that it is giving mac less problems.
http://www.netherworks-studios.com/freebies/NWS-ScriptsMenu_Panel.zip
You don't need to remove any configuration files. Those should be fine.
.
I'll try the new version now...
"If I were a shadow, I know I wouldn't like to be half of
what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki
Murakami)
And I added a debug print... you can see it's doing the same thing as before. It's the iterations in the GetPath() routine... for some reason this works differently on a Mac and it's doing an extra iteration. This is a little beyond my ken.
Edit: oops, I started my reply before testing, and ended up cross-posting, sorry.
"If I were a shadow, I know I wouldn't like to be half of
what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki
Murakami)
Sorry for the poser crash :/
Okay, I cleaned up a part that might be causing confusion. This still keeps the notion of hiding the .py or .pyc extension, which I think might be one issue.
http://www.netherworks-studios.com/freebies/NWS-ScriptsMenu_Panel.zip
If the above doesn't work, here is a version that is closer to Dizzi's in that it is not going to hide the extension of the python scripts. It is quickly zipped (there is no pathing in the zip file so you will have to place it manually):
http://www.netherworks-studios.com/freebies/NWS-ScriptsMenu Panel mac.zip
.
Okay, the duplicate issue is a problem with the original script (I'm hoping):
self.Build(self.root, self.tree.AddRoot('ScriptsMenu')) in line 91
Once more, with feeling:
http://www.netherworks-studios.com/freebies/NWS-ScriptsMenu_Panel.zip
.
Quote - Bingo! Well done.
But why didn't it do the same on PC?
I don't know. I can only guess that each OS is probably sensitive about different functions in their own way.
I changed that line to:
self.Build(self.root, self.tree.AddRoot(''))
and Windows is not having a problem with it either so I can only assume that its extraneous to even add a name to the root. I'm working with XP here so I can only hope that there is no issue with Vista or 7 (hides in a corner)
Okay, for the other functions...
Can you define an editor using "Set Python Editor" in the script? If so, will "Edit Script" allow you to open the script in that editor?
Also, I tried to include a routine for "Finder" as I understand that is the equivalent to Windows Explorer. Do you get the option to "Browse with Finder" on a folder and does it work?
.
"If I were a shadow, I know I wouldn't like to be half of
what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki
Murakami)
Traceback (most recent call last):
File "/Applications/Poser Pro 2010/Runtime/Python/poserScripts/ScriptsMenu/ScriptsMenu Panel.py", line 227, in EvtMenu
subprocess.Popen([path],executable=self.pyEditPath,shell=False)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/subprocess.py", line 542, in init
errread, errwrite)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/subprocess.py", line 975, in _execute_child
raise child_exception
What do you mean, "Permission denied"?
Don't you know who I am, you pathetic little snake?
(Have to go to bed now).
"If I were a shadow, I know I wouldn't like to be half of
what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki
Murakami)
LOL!
No worries and thanks for trying.
I'm going to have to raise the white flag on trying to get the mac to cooperate. I just don't know what it wants and if there are any os specific issues on using subprocess. I can get it to work using both the original way I wrote it and using arguments (which is probably the correct way) in Windows.
I can't seem to figure out how to get Browse with Explorer to work by using arguments. Searches and code snippets are saying to use
subprocess.Popen('explorer '+path)
which is doing it without arguments. I can't even fathom how to get finder to work if it isn't going to do it similarly. I really hate to give up but it's obvious that things are working differently between the os'es even though this is more or less a universal platform. We saw that happen a LOT with Tkinter, which still doesn't work properly between Windows and Mac across various versions of python.
Still, this is and will always be a freebie so if a mac python wizard wants to help make it work across both OSes, you have my blessing! :)
Until I can figure out what's going on, I can hide the menu entries for mac users so that there isn't any confusion or expectation.
.
You haven't tried the form Popen([program, file])
What appears to be happening on Windows (and the example you mentioned seems to bear it out) is that a string is parsed, but on MacOS its treating it as the program (equivalent to putting quotes around the whole thing).
It also may be that you have to specify the full path to the program and/or specify use of a shell.
Check what works using a command prompt.
Okay, that also works :)
Okay mac folks, does this test script work for you? (It should open the folder where your poser preferences reside):
# open directory test<br></br>
import poser<br></br>
import subprocess<br></br>
import os<br></br><br></br>
path = os.path.abspath(poser.PrefsLocation())<br></br>
subprocess.Popen(['finder',path])<br></br><br></br>
If I use 'explorer',path here it works on windows since explorer.exe is a running process.
.
I put the script in the poserScripts folder and called it Testdir.py and this is what I got:
Traceback (most recent call last):
File "/Applications/Poser Pro 2010/Runtime/Python/poserScripts/Testdir.py", line 7, in ?
subprocess.Popen(['finder',path])
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/subprocess.py", line 542, in init
errread, errwrite)
File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/subprocess.py", line 975, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
"If I were a shadow, I know I wouldn't like to be half of
what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki
Murakami)
os.system('open "%s"' % path)
I tried this code in the ScriptsMenu script, and it works fine.
EDIT: note the single quotes outside the double quotes.
"If I were a shadow, I know I wouldn't like to be half of
what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki
Murakami)
BUT
this is not a robust solution - it only works for me because in my OS I have chosen to open Python script files by default with TextEdit.
EDIT: cross-post.. I'll try the update.
"If I were a shadow, I know I wouldn't like to be half of
what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki
Murakami)
Oh okay... on the version I just downloaded I was getting no 'Browse with Finder' option on the menu.
Edit Script is still giving me the Permission denied error message. I need some supper now, but afterwards I'll see if I can find the correct os.system() syntax for opening a file with a specified app, rather than just with the OS default app.
"If I were a shadow, I know I wouldn't like to be half of
what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki
Murakami)
Quote - Well, at least poser didn't crash :D
True. Unfortunately I must do just that. NIte!
PS: I have found nothing definite about how to open the script file for editing. Most forums recommend using subprocess rather than os.system, but I can't find any useful info about the permission problem we are getting.
"If I were a shadow, I know I wouldn't like to be half of
what I should be."
Mr Otsuka, the old black tomcat in Kafka on the Shore (Haruki
Murakami)
This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.
Poser 8 or Poser Pro 2010 (or later)
Written on Windows PC, untested but theoretically works on Mac.
To replicate Poser's Scripts Menu in a floating/dockable panel and to provide some additional functions when working with python scripts.
In an attempt at a more seamless integration with Poser's existing panels, there is no docked border and background colour is set to that of other panels. Folder color is darker with yellow text. Script color is lighter with white text. The .py and .pyc extensions are hidden to match the scripts menu.
Simply double-click to run a script or open a folder. The plus boxes on the left side can also be used to expand or collapse folders.
A menu is available via right-click.
Copy path to the clipboard (original) - works with files and folders
Refresh Folder and Tree (original) - you can refresh the individual folders or tree if you have made changes outside of Poser.
Browse with Explorer (new) - windows users can browse script folders in Window's Explorer. Similar functionality is implemented for mac users (untested).
Collapse All (new) - Collapses all expanded folders.
Edit Script (new) - scripts with a .py extension can be edited with your file editor of choice. File editor is defined by using "Set Python Editor", which allows you to browse to an .exe or .app installed on your system. The script remembers which editor you have set between poser sessions.
Comments and suggestions are always welcome!
Based on ORIGINAL WORK done by Dizzi, a modification done to ScriptsMenu v1.1. Code redistributed with permission.
.