Strategy to Implement Linked Processes in Python - python

Hey everyone I have a large scope type question that I'd really appriciate feedback/insight on.
I'm a newish programer and am Developing an 'Engine Development Enviorment' for fun at work. I have a program that makes alot of run files, and I have another program that manages batched/local multiprocessed simulations.
I want them to work seamlessly together, but I only want one instance of the 'BatchMaster' to run locally (from the taskbar). I also do alot of scripting type stuff for exploratory data analysis and would love the ability to launch simulations in a single line of code like the following.
import enginemodels
aetd = enginemodels.aetd(bleed='ON')
results = aetd.run(altitude=80000,mach=5,tempsls=60)
I'm would like to have my engine model run method send input to the 'BatchMaster' process.
My question is two parts:
1) How to do you find a multiprocessing instance in windows and send it information?
2) If there isn't an instance of that program, how do you launch it?
Thanks for any feedback or insight you can provide!
This will really help out alot of people at my workplace who aren't good at programming, and do most of their work making files via copy paste.

Related

How to create a TRUE Python program

So I have been studying Python for some time now, learned all the foundations.
With this knowledge I decided to create a project, right now I have written some code and some functionality, but everything is done by the terminal.
Does anybody know where I can find the resources to learn how to create a fully fleshed-out Python program? I want to convert the script to a true .exe, with a GUI , inputs outside the terminal, etc…
If anyone is interested here is the basic program: GitHub - pedrodeoliamarante/roadto10k. There isn’t much yet but the idea is to create a program where I can save data on what i have been studying, set goals, etc…
Thanks for reading!
Take a look at QT for Python.
https://www.qt.io/qt-for-python
I think this is what you are looking for.

How do I run Python scripts automatically, while my Flask website is running on a VPS?

Okay, so basically I am creating a website. The data I need to display on this website is delivered twice daily, where I need to read the delivered data from a file and store this new data in the database (instead of the old data).
I have created the python functions to do this. However, I would like to know, what would be the best way to run this script, while my flask application is running? This may be a very simple answer, but I have seen some answers saying to incorporate the script into the website design (however these answers didn't explain how), and others saying to run it separately. The script needs to run automatically throughout the day with no monitoring or input from me.
TIA
Generally it's a really bad idea to put a webserver to handle such tasks, that is the flask application in your case. There are many reasons for it so just to name a few:
Python's Achilles heel - GIL.
Sharing system resources of the application between users and other operations.
Crashes - it happens, it could be unlikely but it does. And if you are not careful, the web application goes down along with it.
So with that in mind I'd advise you to ditch this idea and use crontabs. Basically write a script that does whatever transformations or operations it needs to do and create a cron job at a desired time.

Utility to manage multiple python scripts

I saw this post on Medium, and wondered how one might go about managing multiple python scripts.
How I Hacked Amazon's Wifi Button
This describes a system where you need to run one or more scripts continuously to catch and react to events in your network.
My question: Let's say I had multiple python scripts that I wanted to do run while I work on other things. What approaches are available to manage these scripts? I have to imagine there is a better way than having a large number of terminal windows running each script individually.
I am coming back to python, and have no formal training in computer programming, so any guidance you can provide will be greatly appreciated.
Let's say I had multiple python scripts that I wanted to do run. What
approaches are available to manage these scripts? I have to imagine
there is a better way than having a large number of terminal windows
running each script individually.
If you have several .py files in a directory that you want to run, without having a specific order, you can do:
import glob
pyFiles = glob.glob('path/*.py')
for pyFile in pyFiles:
execfile(pyFile)
Your system already runs a large number of background processes, with output to the system log or occasionally to a service-specific log file.
A common arrangement for quick and dirty deployments -- where you don't necessarily want to invest in making the scripts robust and well-behaved enough to run as proper services -- is to start the script inside screen or tmux. You can detach when you don't need to be looking at it, and can reattach at any time -- even from a remote login -- to view the output, or to troubleshoot.
Take a look at luigi (I've not used it).
https://github.com/spotify/luigi
These days (five years after the question was asked) a lot of people use docker compose. But that's a little heavy weight depending on what you want to do.
I just saw today the script server of bugy. Maybe it might be a solution for you or somebody else.
(I am just trying to find a tampermonkey script structure for python..)

Best option for making a collection of python code portable?

Here are the facts:
I have a collection of python scripts that work together as part of a program
It takes a user input and outputs .docx and .excel files
Right now, only executable through command-line/editor (i.e. you call one script, it does the rest)
Non-CS people have difficulties downloading the necessary modules, and running the program
I want to make my program easily executable/portable to different OSs. So far, I have the following options:
Create a website that takes input visually, and does what it has to do. How do I get the website to refer to my code? Do I have to put it in some sort of web server?
Create an executable that others can simply run (Not sure if this is possible)
Create a GUI that does everything visually.
What are the pros and cons of each one of these options? Which one would you say is most feasible?
My apologies if I said something silly. I'm still learning most of this stuff.
Thank you!

Testing Apache/mod_jk/Tomcat configuration upgrade

We have begun upgrading hardware and software to a 64-bit architecture using Apache with mod_jk and four Tomcat servers (the new hardware). We need to be able to test this equipment with a large number of simultaneous connections while still actually doing things in the app (logging in, etc.)
I currently am using Python with the Mechanize library to do this, but it's just not cutting it. Threading is not "real" in Python, and multiprocessing makes the local box work harder than the machines we are trying to test since it has to load so much into memory for Mechanize.
The bottom line is that I need something that will really hammer this thing's connections and hold a session to make sure that the sticky sessions are working in mod_jk. I need to be able to code it quickly, it needs to be lightweight, and being able to do true multithreading would be a perk. Other than that, I am open-minded.
Any input will be greatly appreciated. Thanks.
Open Source Testing Tools
Not knowing the full requirements makes it difficult, however something from the list might fit the bill.
In order to accomplish what I wanted to do, I just went back to basics. Mechanize is somewhat bulky, and there was a lot of bloat involved in the main functionality tests I had before. So I started with a clean slate and just used cookielib.CookieJar and urllib2 to build a linear test and then run them in a while 1 loop. This provided enough strain on the Apache system to see how it would react in the new environment, and for the record, it did VERY well.

Categories

Resources