run python commands remotely

For general automation, I’m looking for a python-based solution to execute python commands for the Editor from Maya/Blender/etc. Basically, just operate the output log from an external application. This is for automating the work of transferring animation and assets into the Engine. If it can be run from the output log, it should be executable remotely, yeah?

I’ve found some partial results on Github and around the web but it’s incomplete and too esoteric for me. Previous versions of unreal had a remote_execute.py module, but I guess that’s gone in UE5.

def remoteCommand(commandString):
‘’‘remote access Unreal engine somehow’‘’
[what code goes here?]
‘’‘run commandString (as if it were run from the output log in the Editor…)’‘’
try:
[what code goes here?]
except:
print('command failed : ’ + commandString)

commandString= ‘import someModule\nsomeModule.runThis(’ +args+ ‘)’
remoteCommand(commandString)

examples:

remoteCommand( ‘import unrealShortcuts as us’)

levelName= ‘abc_shot0010_level’
levelTemplate = ‘Content/abc/abc_masterLevel
destPath = ‘Content/abc/shot0010/’
commandString= ‘us.createLevelFromTemplate(’ + levelName+’,‘+ ‘,’+templateLevel+’,’ +destPath+ ‘)’
remoteCommand(commandString)

destPath = ‘Content/abc/shot0010/animation/’
for fbxFile in fbxFileList:
commandString= ‘us.importAnimation(’ + fbxFile+‘,’+ destPath+ ‘)’
remoteCommand(commandString)