Reputation: 1846
I am using Pylint, I am new to this tool, so to count the quality of my python project (test automation). I know that if I want to test the quality of one file I have to execute the following command (for Windows10):
pylint name_of_file.py
If I want to execute the whole directory, I need to create a python file named __init__.py
in the above directory and then to execute this command:
pylint name_of_the_directory
Also, as I mentioned above, I also use PyCharm. Through the interface of this IDE, Pylint has a button named as Check Project
which is validating the whole project. Please take a look on the screenshot of this interface:
An output from any of the above executions, would be like this:
something.py:12:4: C0111: Missing method docstring (missing-docstring)
something.py:16:4: C0111: Missing method docstring (missing-docstring)
something.py:20:4: C0111: Missing method docstring (missing-docstring)
something.py:25:4: C0111: Missing method docstring (missing-docstring)
something.py:31:4: C0111: Missing method docstring (missing-docstring)
something.py:35:4: C0111: Missing method docstring (missing-docstring)
something.py:39:4: C0111: Missing method docstring (missing-docstring)
What do I need: I want every after new build, the Pylint results to be saved in a specific directory under a .txt
format file, having as a name the current timestamp followed by the current's project version (stored into a property file). To me (if I am not wrong), it's like keeping the log output fo Pylint execution. How can this happen?
In case is needed:
System information
Upvotes: 2
Views: 2106
Reputation:
Working in the Windows command line, you can redirect output to the filename you need, and then display the contents of the file you just wrote.
pylint name_of_directory > <filename> 2>&1 | type <filename>
You can use slices of the %DATE%
and %TIME%
variables to get a unique filename with the timestamp.
>echo %DATE%
Thu 02/21/2019
>echo %DATE:~0,1%
T
>echo %DATE:~1,2%
hu
>echo %TIME%
7:54:17.74
You'll have to figure out what parts you want and slice/append them into your desired name. Just trying to concatenate %DATE% and %TIME% will give you an invalid pathname. This question discussses formatting a filename with a timestamp.
Once you have the timestamp format you want, you can save your filename to a a variable to reference it just once:
set FILENAME="example.txt"; pylint <name_of_directory> > %FILENAME% 2>&1 | type %FILENAME%
Of course, this will just save it for the current command. See this question if you want to save it globally.
I assume there's a way to get PyCharm to run this command for you, but I cannot tell you how to do that.
Upvotes: 2