P4 Python and P4Config files

Hey all,

We’ve recently started using an edge server to get faster access for remote workers, but this introduced several connection errors with our p4python queries in maya, as the default server/port was being used, not the new edge server/port. Our P4 admin suggested using P4CONFIG files, but try as I might, I have not been able to get the p4python API to recognize and use the settings from the config file.

I can get the instance to recognize there is a p4config file via the environment settings, but it does not seem to recognize the config file in the actual connection instance, or setting the port the way I would expect it.

from P4 import P4, P4Exception
p4 = P4()
print p4.port
print p4.p4config_file
print p4.env('P4CONFIG')

Anyone have experience using P4CONFIG files successfully with p4python? any tips on what I seem to be missing?

thanks all!

What’s the current working directory when initialising the P4 object, and would that result in the P4CONFIG file being missed?

The config file is resolved by starting in the current working directory and then recursively checking parent directories. Running from Maya for instance (depending on what environment you launch from) unless you explicitly change it the cwd will be

import os
# Result: C:\Program Files\Autodesk\Maya2019 #
1 Like

That was one hope I’d had earlier this week while digging through stackoverflow. I am setting the cwd for the instance to the base perforce directory where the config file is located, but that does not seem to get the instance to see the config file either.