Say I have the following open_calc.py
script on a machine that's on the network:
import subprocess
subprocess.call(['calc.exe'])
This simple script merely opens the Windows calculator and ends. Then, on a local machine, I have invoke_network_calc.py
script that contains:
import imp
lecroyModule = imp.load_source('module', r'\\network_machine\c$\open_calc.py')
If I run invoke_network_calc.py
from the local machine, the calulator opens on the local computer. My question is, is there a way to do this so that the calculator is open on the network computer? Or, more generally, is there somthing that can be done so that from that point on, when subprocess.call
is called, it starts the process in a different environment? I know this can be done if I simply invoke the network's Python engine with open_calc.py
, but is there a way to do this without starting a separate Python process?
EDIT: Perhaps a piece of wishful code will further specify what I'm looking for:
redirector = Redirector('network_machine')
redirector.start() # from here on, subprocesses are executed on the remote machine
lecroyModule = imp.load_source('module', r'\\network_machine\c$\open_calc.py') # calculator will be opened on remote computer
redirector.stop() # from here on, subprocesses are executed normally (on the local machine)
lecroyModule = imp.load_source('module', r'\\network_machine\c$\open_calc.py') # calculator will be opened on local computer
So basically, I'm asking if anyone knows of a way to implement the Redirector
class.