I’m trying to build a movie render queue job and assign it a pre-saved output config. The file is saved under Content\Cinematics\MoviePipeline\Presets\myConfig.uasset.
My guess would be to use the unreal.MoviePipelineExecutorJob.set_configuration(preset) method. But how do I get an instance of MoviePipelineMasterConfig from a file path to apply to the job within a Python script?
Thanks.
So I found the answer I was looking for.
newConfig = unreal.load_asset( "/Game/Cinematics/MoviePipeline/Presets/myConfig" )
Will create an instance of MoviePipelineMasterConfig from an existing file that can be used within Python scripts.
Related
I need to automate the calling of a Python script like this:
python3 sendStuff.py --yaml yamlVariableFile.yaml
To automate this, I am using RobotFramework. I plan to call the Robot script like this:
robot robotScript.robot --variablefile yamlVariableFile.yaml
I can now access the variables specified within yamlVariableFile.yaml, but I need a way to access the name of this file as well - yamlVariableFile.yaml - since I need to pass it as an argument to the Python script - sendStuff.py - within the robot script. Is there a way to do this?
I do not think you can do that. What you can do is pass the file name in a separate variable (not variable file):
--variable filename:yamlVariableFile.yaml
or add an additional variable to the yaml file that could have the name of the file itself.
I am trying to temporarily store files within a function app. The function is triggered by an http request which contains a file name. I first check if the file is within the function app storage and if not, I write it into the storage.
Like this:
if local_path.exists():
file = json.loads(local_path.read_text('utf-8'))
else:
s = AzureStorageBlob(account_name=account_name, container=container,
file_path=file_path, blob_contents_only=True,
mi_client_id=mi_client_id, account_key=account_key)
local_path.write_bytes(s.read_azure_blob())
file = json.loads((s.read_azure_blob()).decode('utf-8'))
This is how I get the local path
root = pathlib.Path(__file__).parent.absolute()
file_name = pathlib.Path(file_path).name
local_path = root.joinpath('file_directory').joinpath(file_name)
If I upload the files when deploying the function app everything works as expected and I read the files from the function app storage. But if I try to save or cache a file, it breaks and gives me this error Error: [Errno 30] Read-only file system:
Any help is greatly appreciated
So after a year I discovered that Azure function apps can utilize the python os module to save files which will persist throughout calls to the function app. No need to implement any sort of caching logic. Simply use os.write() and it will work just fine.
I did have to implement a function to clear the cache after a certain period of time but that was a much better alternative to the verbose code I had previously.
Quite often I do an anlysis with certain settings and store the plots or results in a folder which is separated from the codebase. To keep track of chosen settings I save the script like so:
import MyClass as my
model = my(some_parameters)
model.run()
with open(os.path.join(save_path, 'used_script_for_docu.py'), 'w') as copied_script_file:
with open(os.path.abspath(__file__), 'r') as script_file:
script_content = script_file.read()
copied_script_file.write(script_content)
Is it somehow possible to add a function to MyClass which can save the script file like explained above? Can the instance of MyClass (model) somehow acces the script file with the current parameters settings? Or are there any other methods to save the script automatically without having to type/copy the lines from above from script to script?
EDIT: I would prefer to store the script file and not the states/parameters of the model because the script might contain settings/procedures which were not anticipated in beforehand and can threfore not be saved automatically from the namespace of e.g. model
I am trying to use the Process() robot framework library to launch and track processes.
https://robot-framework.readthedocs.io/en/v3.0.3/_modules/robot/libraries/Process.html
After I launch my process I am unable to use the get_process_id() method. I wrote a simple example using notepad.exe below
path = "C:\\WINDOWS\\system32"
Process().start_process('notepad.exe',shell=False, cwd=path)
var = Process().get_process_id()
BuiltIn().log_to_console(var)
This gives me the error of "No active process."
Alternatively, using handles as explained in the documentation
path = "C:\\WINDOWS\\system32"
handle = Process().start_process('notepad.exe',shell=False,cwd=path)
var = Process().get_process_id(handle)
BuiltIn().log_to_console(var)
I get the error "Non-existing index or alias '1'."
When you do Process().get_process_id(), you are creating a new instance of the library. This instance doesn't know about any processes started by the previous instance of the library.
You need to get a single instance of the library, and use that consistently.
processLib = Process()
processLib.start_process(...)
var = processLib.get_process_id()
The best thing to do is try to get a reference to an existing process library using BuiltIn().get_library_instance, and only create a new one if it doesn't exist.
I am a Python beginner and wrote some Python code that I want to run from my C# code.
In all the answers I have seen already, the way was to make a .exe file from the .py one and run it by system call.
However, I want it so that I do not need to make the .exe file and can write the commands with arguments as I could in the command line.
C:\Users\ntuser> python C:\Users\ntuser\Documents\run_python.py 3
Is there a way to do it?
I found a way to pass just one command—but I need to make two: 1. Go to "C:\Users\ntuser" 2. Run the Python code.
Thanks!
OK, so I found a solution.
Thanks to UnholySheep for the help.
What you need to do is:
Make the python as system variable
Go by code to your home directory:
Directory.SetCurrentDirectory(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));
Add this code for calling the python code:
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;//if you want to hide the window
startInfo.FileName = "cmd.exe";
startInfo.Arguments = "/C python pytonPath\\python_code.py";
process.StartInfo = startInfo;
process.Start();
process.WaitForExit();//if you want to wait