Forum: Poser Python Scripting


Subject: Environment variables - Mac equivalent of APPDATA

3dcheapskate opened this issue on Apr 28, 2020 ยท 7 posts


3dcheapskate posted Tue, 28 April 2020 at 3:07 AM

Environment variables - what's the Mac equivalent of APPDATA ?


The 3Dcheapskate (also available in DAZ and HiveWire3D flavours) occasionally posts sensible stuff. Usually by accident.
And it usually uses Poser 11, with units set to inches. Except when it's using Poser 6 or PP2014, or when its units are set to PNU.




adp001 posted Tue, 28 April 2020 at 4:45 AM

Is the APPDATA concept not Windows specific?

Using Python, os.gentenv("HOME") should you return the current users home directory.

Scripts running in Poser are part of the Poser-App. No need to keep some orphans which are dependent on Poser after Poser is deinstalled. On the other side: If I move Posers data area, I want to move script dependant data too.

Data areas under Poser-Pythons script path are completely safe and secure under all operating systems.




3dcheapskate posted Tue, 28 April 2020 at 5:55 AM

Perhaps "the Mac equivalent of APPDATA" was the wrong phraseology. In Windows, APPDATA appears to be the place where applications are supposed to save user-specific configuration files, etc. Sothe question'sreally where do Mac applications usually put their user-specific configuration files, etc ?

Regarding file location - the spanner in the works is that the specific datafile in question here is for both* Poser and DAZ Studio.

As I understand things now, because both PoserPython scripts and DAZ Scripts will need to be able to write to the file, it cannot go anywhere that the OS considers to be part of either the Poser or DAZ Studio installation, because the other program would be forbidden from writing to it.

Therefore in Windows a "%APPDATA%/Roaming/3DCheapskate_Pose_DAZ_SmartPlus" folder containing my "SmartPlusData.txt" file seems the best solution at present.

So now I'm really looking for the most sensible place to put my ":3DCheapskate_Pose_DAZ_SmartPlus:SmartPlusData.txt" file on a Mac.

*yes, I really do need (want?) to use exactly the same single file for both Poser and DAZ Studio.

Edit: forgot to add a crosslink to the original thread - How do you avoid UAC problems writing to poser.AppLocation() subfolders ?


The 3Dcheapskate (also available in DAZ and HiveWire3D flavours) occasionally posts sensible stuff. Usually by accident.
And it usually uses Poser 11, with units set to inches. Except when it's using Poser 6 or PP2014, or when its units are set to PNU.




adp001 posted Tue, 28 April 2020 at 11:29 AM

In a unixoid OS the users home directory is where apps store files. Where path-/filenames starting with a dot (".") in "home" are special and such pathnames are often used as "application pathes". All other pathes may need a special user to create/modify files.

By the way: os.getenv("USER") and os.getenv("HOME") seems to deliver nothing with Poser-Python (at least in my installation).




adp001 posted Tue, 28 April 2020 at 11:51 AM

path = os.path.expanduser("~/3Dcheapskate/config.txt")
os.mkdir(os.path.dirname(path))
fh = open(path, "w")
fh.close()

seams to deliver something useful with Windows, under Poser and also with Linux (should be the same with OSX).




3dcheapskate posted Thu, 30 April 2020 at 1:34 AM

adp001 posted at 1:33PM Thu, 30 April 2020 - #4387630

...

By the way: os.getenv("USER") and os.getenv("HOME") seems to deliver nothing with Poser-Python (at least in my installation).

I assume you're talking Windows there ?


The 3Dcheapskate (also available in DAZ and HiveWire3D flavours) occasionally posts sensible stuff. Usually by accident.
And it usually uses Poser 11, with units set to inches. Except when it's using Poser 6 or PP2014, or when its units are set to PNU.




an0malaus posted Thu, 07 May 2020 at 10:28 AM

The place where Poser puts its preferences in macOS (returned by poser.PrefsLocation() ) returns "/Users/[USERNAME]/Library/Application Support/Poser Pro/11". As you can see from the "Application Support" folder name, this is entirely equivalent to the Windows concept of AppData.

Again, I say. "Just use poser.PrefsLocation()!" If you don't like it being associated with Poser, because you want it for application data sharing, though if Poser weren't one of the apps you're sharing data between, that would be the sole reason I could imagine for not putting it there, as I suggested in the other thread, put your subfolder within the parent of the parent of poser.PrefsLocation(), or ~/Library/Application Support/Somewhere Nobody Will Ever Look But Can Always Write To. ;-)



My ShareCG Stuff

Verbosity: Profusely promulgating Graham's number epics of complete and utter verbiage by the metric monkey barrel.