Tuesday, March 6, 2018

run a python script on windows 7 client from linux using python



I'm new in python so my sincere apologies if this is a dum question.



I want to trigger, using python, from a linux server a python script run on an windows 7 client. This script get's the mouse pointer position, makes a screenshot of the desktop and in this screenshot draws an ellipse at the position determine above. I've searched over the internet for a solution but so far I didn't find a method.
Is there a method to run the python script on the windows machine from linux?



Python script code that is on the windows machine:




    import win32api
import wx
from PIL import Image
from PIL import ImageDraw
from os import sys

print "Step 1: Get Mouse position"
x, y = win32api.GetCursorPos()


print "Step 2: Screenshot of the Desktop"
ff=wx.App()
screen = wx.ScreenDC()
size = screen.GetSize()
bmp = wx.EmptyBitmap(size[0], size[1])
mem = wx.MemoryDC(bmp)
mem.Blit(0, 0, size[0], size[1], screen, 0, 0)
del mem
bmp.SaveFile('screenshot.png', wx.BITMAP_TYPE_PNG)
im = bmp.ConvertToImage()


print "Step 3: Draw an ellipse on the mouse pointer position"
im2 = Image.open("screenshot_desktop.png")
draw = ImageDraw.Draw(im2)
r = 5
draw.ellipse((x-r, y-r, x+r, y+r), fill="yellow")

del draw
im2.save("screenshot_mouse_position.png", "PNG")



Thanks,
Dragos


Answer



If I understand you correctly, you want to start a python script on the windows machine whenever your linux's python script wants to.



To my knowledge, there is no easy way to do that.



One way would be to have a daemon listenning on a specific port on the windows machine that will trigger the script whenever it receive a certain command. This means you have to create a communication protocol over tcp/ip and watch for security.


No comments:

Post a Comment

plot explanation - Why did Peaches' mom hang on the tree? - Movies & TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...