sending mouse/keyboard events on remote desktop - python

So I am trying to set up a Continuous integration environment using Jenkins.
One of the build step requires a series of mouse actions/movements to accomplish a task in Excel. I have already written a python script using the ctypes library to do this.
The script works perfectly fine if I run it either through Jenkins or on the server itself when I am actively logged in to the server using remote desktop connection, but as soon as I minimize/close the connection and then run the script from Jenkins, it seems the mouse events never get executed. Is there something I can add to the script to make this work? Thanks for any help you can provide.

Related

Is there a way to stop and restart a self hosted Python script using Github Actions?

I have a project in which one of the tests consists of running a process indefinitely in order to collect data on the program execution.
It's a Python script that runs locally on a Linux machine, but I'd like for other people in my team to have access to it as well because there are specific moments where the process needs to be restarted.
Is there a way to set up a workflow on this machine that when dispatched, stops and restarts the process?
You can execute commands on your Linux host via GH Actions and SSH. Take a look at this action.

How to access terminal Python process running on server from other script

Consider situation:
I have an Ubuntu server with installed Python, tensorflow and other libs.
My code is python script, that load several models, some of them pretrained vectors .bin, some files from server folders, etc.
When i run script in terminal it launch interactive session, where i input some text and script output me back (like chatbot). During answer it call my Ai models (Tensorflow, keras).
Question: how do i access this running session from other python script? I mean i want use it as a function: to send text and receive answer back.
And of course i need to run this terminal session in background for long time.
I read this and similar answers, but not sure is that right solution (seems not a full):
In Linux, how to prevent a background process from being stopped after closing SSH client
What i am asking, commonly is done by REST server with API that expose and then this api is called from a external code. But there is no API wotking: Tensorflow throw errors when run via Flask (was not able to fix).
If you want your script stays up after closing ssh session, add & disown at the end of your execution command and it will run in background.

Run a script located on remote server using python

I have a python script located on a remote server with SSH enabled. That script displays a lot of debug messages displayed while executing. I want to trigger this script using another python script which is on my local system and depending on the output of the earlier script, I want to proceed further. While doing all this, I want the display messages on the remote server to be displayed on my local system as well. Basically, I want to view whatever output is thrown by the remote script during the course of the script, on my local system. I am able to trigger the script using paramiko but I am neither able to check whether the script on the remote server is running nor am I able to view it's output. Is there any way to do it? Already tried conn.recv(65535) but to no avail.
In my experience I found python fabric module easier than using paramiko. If you want to execute local script on remote machine using fabric. You just need to upload them using put() and then call run() api.
http://docs.fabfile.org/en/1.14/api/core/operations.html#fabric.operations.put

Sikuli Scripts not running if RDC is minimized

I have a sikuli script which does the Siebel Tools incremental Compilation Task on a Windows Box from Jenkins.
The problem is: When i run the task i always have to open the RDC window open for the task to be executed.As soon i minimize the window the script fails.
Hence if the Sikuli script is running i will not able to use my local system for any other task.
I found some posts on launchpad.net.
this is one reference: https://answers.launchpad.net/sikuli/+question/213636
But it did not work.
Can anyone help on this.
This solution has helped me out:
Close all open Remote Desktop sessions.
Launch the Registry editor (regedit.exe).
Navigate to one of the following Registry keys, depending on whether you wish to modify the Remote Desktop settings only for the current user or for all users on the computer:
HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client
HKEY_LOCAL_MACHINE\Software\Microsoft\Terminal Server Client
Create a DWORD value named RemoteDesktop_SuppressWhenMinimized and set it to 2.
Close the Registry Editor.
After these steps are done RDC when minimized will not be suppressed and sikuli will work.
Answer taken from:
https://support.smartbear.com/testcomplete/docs/testing-with/running/via-rdp/in-minimized-window.html
Other solution is to use VNC connection instead of RDC. RealVNC for example.
You setup VNC server on machine that sikuli scripts are running on and connect from your other machine. You should even be able to close the connection window and scripts should still be able to run.
You could just keep the RDC session running in the background. Just don't minimize it. I am doing the same with my tests.

Batch execution of SAS using a Telnet connection in Python

I have been interested in finding an alternative to the UI in SAS for quite some time now. We license SAS on our server instead of our desktops, so furthermore we have to launch a remote desktop application to execute code.
I was able to use a Telnet connection instead to remotely connect to the server, and batch execute SAS programs. Then I was interested in whether a python script could be made to connect remotely, and batch execute code, and this script could be executed in jEdit as a BeanShell script.
So far, I have Python code which successfully opens and closes the Telnet connection. It can do basic shell functions like call "dir". However, when I pass the exact same line that I use to execute SAS from command prompt on the remote server with a telnet connection in Python, nothing happens.
Is it possible the server is preventing me from executing code from a script? I use a "read_until" statement for the prompt before running any code.
Here's a few ideas...
The issue you are having above may be related to Local Security Policy settings in Windows (if it is running on a windows server). I'm far from an expert on that stuff but I remember older SAS/Intranet installations required some rumaging around in there to get them working.
As an alternative to the approach you are trying above you could also setup a SAS session on the server that listens for incoming socket requests as per this article:
http://analytics.ncsu.edu/sesug/2000/p-1003.pdf
And finally... Not sure if this helps or not by I remotely execute SAS jobs using PSEXEC. A description of how I set it all up can be found here:
http://www.runsubmit.com/questions/260/hide-sas-batch-jobs-winxp
Good luck
This paper outlines how you can use a Python script to connect to a Unix server using SSH, copy the SAS program written locally onto the server, batch submit it, and download the results back to your local machine, all using a BeanShell macro script for jEdit.

Categories

Resources