I've had a look around here for multiprocessing, for the most part, I've gotten it narrowed down but the last bit fails for some reason.
Context
I have a remote webserver that I connect to that I have port forwarded the HTTP page to a local port. I need to connect to the remote host, while I'm connected, I need to open up the HTTP page on my local machine and capture the page.
Code
from selenium import webdriver
from pyvirtualdisplay import Display
import paramiko
import multiprocessing
import time
def grabscreendisplay():
time.sleep(10)
print('running display code now... ')
display = Display(size=(1024, 768), visible=0)
display.start()
driver=webdriver.Chrome('/usr/local/bin/chromedriver')
URL="http://localhost:9012"
driver.get(URL)
screenshot=driver.save_screenshot('my_screenshot.png')
driver.quit()
def getserver():
SERV = raw_input('Please enter the server you would like to connect to: ')
return SERV
def connect_to_server(SERV):
print(SERV)
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
print('Connecting to ' + SERV)
ssh.connect(SERV, username='root', key_filename='...')
connected = True
print('Connected to ' + SERV)
time.sleep(30)
def main():
SERV = getserver()
p1 = multiprocessing.Process(name='p1', target=connect_to_server(SERV))
p2 = multiprocessing.Process(name='p2', target=grabscreendisplay())
p2.start()
p1.start()
if __name__ == "__main__":
main()
Problem faced
The .png just displays a failed connection to the port ('localhost refused to connect')