Self executable python file [duplicate] - python

This question already has answers here:
How to run a python script at a specific time(s)
(4 answers)
Closed 6 years ago.
Actually, I am new to python and I want to download some content from a website daily. So what can I use to run that file each day?
Any help would be appreciated!

If you use Unix based system, you may put daily cronjob.
Also there are some alternatives for Windows :
What is the Windows version of cron?
In this way script that you want will be automatic executed.

Related

Using pytest from a BAT file [duplicate]

This question already has answers here:
How to start Python virtual environment in .bat batch file?
(2 answers)
Closed 2 years ago.
I am trying to using pytest from a BAT file. I have tried something like this
..\venv\Scripts\activate.bat
pytest -v src/datasets_test.py::TestDatasetsOperations::test_dataset_add
But it seems to do nothing. How can I make it work?
EDIT: the question is similar, but no one will go to other question if he thinks the error is with pytest
In order to call another script from a batch script, you need to use call.
call ..\venv\Scripts\activate.bat
pytest -v src/datasets_test.py::TestDatasetsOperations::test_dataset_add

How to keep a terminal opened by Python alive? [duplicate]

This question already has answers here:
How to keep a Python script output window open?
(27 answers)
Closed 3 years ago.
In my Python script, I create a .bat file (many actually), and I run them via
os.startfile(blah)
Everything works like expected, however, those terminals die after finishing. I want to keep them open, so that I can type more commands manually in those opened terminals.
How?
You could try using the cmd command to run the batch file, and then use command line arguments for cmd to modify its behavior. For example:
os.startfile("cmd.exe /k blah.bat")
Documentation of the available command line arguments can be found here:
https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/cmd

How to run vbs from Python? [duplicate]

This question already has answers here:
How do I execute a program or call a system command?
(65 answers)
Closed 5 years ago.
I'm working on a GitHub project. It's a text editor built in Python. I need to be able to run error.vbs from test.py.
How or is this possible?
Nevermind.
I just found it out:
import os
os.system("filename.vbs 1")

Pydoc won't run on command prompt [duplicate]

This question already has answers here:
Pydoc is not working (Windows XP)
(8 answers)
Closed 8 years ago.
I'm working through this "Learn python the Hard Way" book and the book is now saying to run
'pydoc open'
I do this and get the response that pydoc is not an internal or external command etc.
I've trying adding 'C:\Python27\lib\pydoc.py' to PATH and restarting my computer but it still hasn't worked.
Python is probably not in your path. you must add it in your path either by using the GUI or something like this:
set PATH = PATH;/path/to/pydoc/
This is a windows example, but it should not be hard to convert to a *nix version. The export command can be used in that case.

Hide console from Python script? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to hide console window in python?
I have a simple script with one messagedialog only...
how can I hide the console from it when I execute the app?
Execute the script using pythonw.exe rather than python.exe. You can set that up to happen automatically by giving the script the extension .pyw rather than .py.

Categories