Get Python script state from another script [closed] - python

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have a python3 program that does some stuff and a Pyramid app that allows users to interact with the program's database. Say, my program may be busy with 2 kinds of activity: 'Task1' and 'Task2'. I would like to be able to get the current activity (better with some other additional info) from my Pyramid app and show it to users. What is the best way to do that? If possible, I would prefer to avoid multithreading and all that stuff.
The only idea I have in mind is having a special file on disk where my program writes it's activity whenever it changes. But I guess that solution doesn't shine at performance, not to mention other drawbacks.

I think you have three options:
1 - As you said, use a special file .. (but that's not practical and kinda 1990 stuff ..)
2 - Use a special process for threads communication using multithreading .. (a complicated solution for a simple language)
3 - Use the database, and put a special key with a special value to indicate whether the value in the database key you choose to put your communications in have changed or not .. Better be json formatted .. (I think that's the most practical and the easiest solution)

Related

Could you check it's possible (Selenium python automation + PHP) [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Our system is developed with PHP and one of our coworkers developed Amazon automation program with Python.
I am wondering if it's possible to integrate together ?
if it is please recommend what ways i can do this
https://github.com/jasonminsookim/order_automation/blob/master/src/amzn.py
Here's code Amazon automation program
Thank you
There are lots of ways to do this, but I would weigh what you have available to you and go from there. The tempfile solution is the most general, and is a common interface pattern for any two or more languages, but you can get more exotic if performance is a major concern with pipes.
Temp-file
I guess the most rudimentary way to do this would be to have the python file output some data to a file that can be read in by php or vice versa.
Something like creating a directory called /orders where php put's in order.json files and python takes those in, reads them and gets the result, then puts it back as a order-result.json. Essentially a temp-file system to communicate between the two.
Pipes
Alternatively depending on your setup you could pipe results into php from python with something like the subprocessing module and a php CLI that interfaces with your DB.

Deploying python scripts [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am a python beginner and I am a little experienced in OO-programming in Java and PHP and also fucntional programming in R . Thus, my question is considering the general usage of python scripts in everyday use-cases.
I want to "learn" how to think/approach a problem that I do experience when facing a situation with my software where a "script" could help me out or improve something.
For instance, I've heard friends talking about their self-made python scripts to evenly mute the audio of movies to avoid loud outliers in explosive scenes, etc. Another example, in my case righ tnow, is to filter out certain pictures with no GPS-time meta information for the timezone in order to sort these fotos in accordance with the others.
I really want to get the essence and recipe based on the aforementioned examples to better integrate Python in my everyday life and get an intuitive feeling for it. (i.e. how would a simple script look like that takes a picture, filters out its meta data, and does something -> where do I have to run the script so I can call the function with these .JPG files as its arguments?).
I would also be glad if some of you could recommend some practical tutorials or literature.
Thank you in advance :)
P.S. I know it is not a concrete question but rather it is intended to get a glimpse on a wide field of usage and thinking - but I want to get this essential take away that motivates me and shows me the direction.

How to access all of a file's attributes through Python in Windows 7? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
In a Windows 7 system you can right-click the sort columns to look at the details you want to view for a file and you get the following:
Question: Is there a way to access all of the attributes on that list for a given file using Python?
This is a bit long for a comment.
You are not likely to get a good answer because Microsoft makes this way too complicated, and their documentation on this topic is some of the worst that they have.
Everything is wrapped up in COM interfaces, and you really need the SDK installed to get all of the headers file needed to access these interfaces from a C style API.
To understand how it really works, you really need to start the Property System Overview
You will also want to read Property System Developers Guid
There is one C language answer that I know of for this topic on S/O, though clearly there could be others.
I know it is not a real answer, and it is certainly not Python -- but if you have the real motivation to dig into this, hopefully this is at least a little helpful.
Also not that these extended properties are poorly supported, and tend to disappear under many common usage patterns since they are not really part of the file -- e.g., copy the file using ftp -- lose the extended file attributes.

Using Task Scheduler vs Multithreading [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I needed to perform a heavy operation while using a Tkinter GUI. So the GUI would stop responding as soon as the operation began. So, I had two choices(or that's what i think,as I'm new to python & programming as well): MultiThreading or Schtasks .
So, I chose the easier of the two,i.e Schtasks, as I'm working on a deadline(& I dont know much about Multithreading).
What I'm doing is accessing a python file from a different project.
I run batch files which is in this different project(which contains the desired python file that i need to run) to be run by Schtasks
Now the constraint is batch file can access only this python file & not a particular method present in that file(isn't it?) & I need to access only a particular method .
So, my question is:
Is the approach I'm using correct? If not what do you suggest would be better ? Or should I just switch to MultiThreading
Your question opens a huge topic - what you are trying to do is generally not simple and can have large problems which you cannot even foresee if you don't know the topic of multitasking very well. One issue, for example, is synchronizing the access to the file you mention from within different threads or processes or tasks.
However, if you want to start somewhere and just want to write something which separates your GUI code from your computation code, I recommend you start here: http://docs.python.org/2/library/multiprocessing.html .

Is python an ok language for a typing test sort of application as far as performance is concerned [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Want to write a typing test application (GUI, windows). Is simple terms. app shows text, user types text, user gets typing speed result. Example of an online one
Is python an ok language to use with such a project? Note that some people can type upto 200 word/minute . thats a lot of keys per second. Can python keep up? I ask this coz I have heard that python being interpreted in somewhat slower than C++
and I have always wanted to learn (go beyond the getting started tutorial) python, so if performance isn't an issue I would go with python.
If python isn't suitable, kindly suggest some other language. I am kind of ok in php and know a bit of C#. C I am not good at.
Thanks
Allow me to state this rather into the blue: Python is well up to the task of handling 200 words / minute input. Plus it's a nice language for rapid prototyping.
In short, yes, python is an acceptable choice. The application you are creating does not appear to be doing anything incredibly intensive, and even if it was, that doesn't mean python would be a poor choice. It is used in tons of reliable apps with great performance.

Categories

Resources