aero aero - 1 year ago 90
Python Question

How do I connect to Python program from another Python program on another computer?

My question contains more details, but the bottom line is that I need a general idea of how to call my other Python program (or functions) from another program on another computer, what do i need (i.e. Sockets?)
What I'm doing is building a Python UI application, this application shall connect to a Raspberry Pi Python GPIO script running on the RPi to control pins (i.e LED's), I'm not sure if these details are relevant, but most importantly is how to basically make the two programs talk to each other?

Answer Source

Paramiko library could be one of the solutions here:

import paramiko

ssh = paramiko.SSHClient()
ssh.connect(host, username=username, password=password, port=port, timeout=30)  # setting up ssh connection 
ssh.exec_command('<Execute Your Remote Script here>')
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download