I'm trying to use Dronekit Python 2 for creating a minimalistic GCS (ground station). From the examples it looks like python scripts always finish and the connection with the vehicle is lost. That said, Is there any way to code a python script that works like a thread and only exit once it get's a command from Nodejs? Nodejs has the python-shell module that is supposed to send messages to python via STDIN. So my goal is to run python script from Nodejs python-shell, and then send commands to dronekit (connect, arm, takeoff, etc). Thanks for your help!
I believe you can build your GUI in nodejs and use UDP or websocket to communicate with python code, where you build a dronekit wrapped with UDP or websocket.
Related
I have a long-running server application written in Python 3, which I would like to interactively debug from time to time. For that I would like to run Python commands "within" the server application process, inspect the values of global variables etc., like in a REPL or the standardd Python console.
It seems the Python standard library's code module and its InteractiveConsole class seems to be what I am looking for. I was thinking of running that in a separate thread so that the main application is not blocked while I communicate with it.
However, it seems that class provides interaction via standard input and output. That might not be exactly what I need. Is there a way to make that interactive console listen / connect to a socket and send input and output through this socket, so that I can connect to the console via a TCP connection?
Or is there another, better way to implement my requirement without this code module?
I am fairly new to sockets in python and I want to know how i can remotely run commands to another computer. At the moment, I've looked a bit into sockets and I know how to send text messages across networks. And yes, I've port-forwarded my PC.
If this explanation is confusing, let me give examples:
When you
import os
in the python shell and use
os.system(<command>)
, it will run the specified command in your shell. I want to achieve that, but on a remote computer. I am able to establish a connection and I'm successfully able to transfer bytes over a WLAN.
Issue: I don't know how to send python commands via. sockets and I would like to learn how to do it. I know I could implement the code onto the client's connection side of things, but I don't want it hardcoded. I want something like a 'live terminal' of the client's computer allowing me to type commands in and watch them being performed remotely on the client's computer. I'd appreciate some help!
P.S. I'm using Python 3.7.4
You have to do roughly the same thing you were doing with sending text messages. You must have had a client running your python script and your own computer(the server) running a script as well. The only difference between you sending a text message to the client and you sending a command would be in the python script the client is running.
In that python script, instead of printing the command to the console, you can just execute that command using os.system()
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.
I am new to Python - and work on Slackware Linux with Python 3.4.3. I prefer simple no-dependency solutions within one single python script.
I am building a demonized server program (A) which I need to access through both a regular shell CLI and GUIs in my web browser: it serves various files, uses a corresponding database and updates a firefox tab through python's WEBBROWSER function. Currently, I access process (A) via the CLI or a threaded network socket. This all started to work in a localhost scenario with all processes running on one machine.
Now, it turns out that the WebSocket protocol would render my setup dramatically simpler and cut short on traditional flow protocols using Apache and complex frameworks as middlemen.
1st central question: How do I access daemon (A) with websockets from the CLI? I thought about firing up a non-daemon version of my server program, now called (B), and send a program call to its (A) counterpart via the WebSocket HTTP protocol. This would make process (B) a websocket CLIENT, and process (A) a websocket SERVER. Is such a communication at all possible today?
2nd question: Which is the best suited template solution for this scenario - that works with python 3.4.3 ?! I started to play with Pithikos' very sleek python-websocket-server template (see https://github.com/Pithikos/python-websocket-server) but I am unable to use it as CLIENT (initiating the network call) to call its SERVER equivalent (receiving the call while residing in a daemonized process).
Problem 'solved': I gave up on the zero-dependency zero-library idea :
pip install websockets
https://websockets.readthedocs.io
It works like a charm. The WebSocket server sits in the daemon process and receives and processes WebSocket client calls that come from the CLI processes and from the HTML GUIs.
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.