Schedule Speed Tests [closed] - python

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
I want a way to test our network speed every 10 mins automatically and record the output, I found this python https://pypi.python.org/pypi/speedtest-cli and wanted to know if there is a way I could make a program that will run the command sleep for a few mins and then run it again capturing the output every time and logging it into a file.

The easiest way is to run a cronjob with also the date as name of the log file so after that you can analyse the logs.
Python logging:
python logging
You can also use greylog for logging in python, its simple and very useful:
greylog
Cronjob with date:
Cronjob

Related

How can I turn my python script into a web app? I have a scraper that takes an input and displays an output, so I'd like that to be the web app [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 1 year ago.
Improve this question
essentially i have a python script that takes an input from the user, and scrapes the relevant data and outputs it. I thought it'd be neat to turn this into a web app, where should i start?
You need to use some frameworks such as Flask or Django.
I wrote a small program which automates the process for simple scripts.
https://github.com/bkb3/py2webapp

Running a function with the different functionalities at different times in Python [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
I'm looking for a way to create a function that takes two args, time and operation and it does the operation at the given time as an argument. The script should be running on a server and it reads the data from a Redis-like database. I'm trying to find a way to do that avoid using any other frameworks or non-standard packages. Have any idea about that?
See the library https://github.com/dbader/schedule and this example https://github.com/dbader/schedule/blob/master/docs/examples.rst#run-a-job-once

Re-run a python script after a few days if it fails [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Assuming a script fails and it is captured in a try catch how to run a python script again after a few days?
I can use sleep on this problem, but I think it will not work due to the fact that the server restarts every day. What is the best solution on this problem?
Typically you want to address this with a cron job.
I would probably do the following:
When the python file runs, save a log file with the status date/time.
Set up a cron job on the server to check, say once every 24 hours, that checks that log file and either do nothing or runs the python file again.

Get last execution time of script python [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
Im writting a script in Python that takes as an input a timestamp. For the first execution, it should be something as the now() function. However, for further executions, the input parameter should be the last execution time of the same script. This is being done to avoid getting duplicates results.
Can anyone give me a clue please?
As far as I know, there is no "last executed" attribute for files. Some operating systems have a "last accessed" attribute, but even if that's updated on execution, it would also be updated any time the file was read, which is probably not what you want.
If you need to be able to store information between runs, you'll need to save that data somewhere. You could write it to a file, save it to a database, or write it to a caching service, such as memcached.

Can you view the history of what was printed out to the console in pycharm? [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 7 years ago.
Improve this question
Need to get a datetime string I printed out with datetime.now() a few days ago. Is there a file anywhere where this is stored?
Unfortunately no (or maybe fortunately, as it could grow in a massive unwanted file fairly quickly).
Python has excellent logging facility though. Look at the module logging. It is very easy to use. It is very good practice to replace your usual print statements by logging.debug, logging.info or whatever.
Using things like this:
logging.basicConfig(filename=my_filename,
format='%(message)s (%(asctime)-15s)',
level=level)
console = logging.StreamHandler()
logging.getLogger().addHandler(console)
you can have the output be printed on your console, but also saved in a file.

Categories

Resources