I am trying to run pylint with jenkins with following command:
pylint -f parseable -d I0011,R0801 "mypath\highLevel" | tee.exe pylint.out
The process looks run fine, pylint.out created with a lot of information inside but during pylint report creation I get following error:
13:38:27 ERROR: Publisher hudson.plugins.violations.ViolationsPublisher aborted due to exception
13:38:27 java.io.FileNotFoundException: C:\Users\DMD\.jenkins\jobs\Diamond - Run Coverage\builds\2015-07-26_13-34-30\violations\file\A:\highLevel\Monitor\InitialBootAdapter.py.xml (The filename, directory name, or volume label syntax is incorrect)
It's creates very strange path:
C:\Users\DMD\.jenkins\jobs\Diamond - Run Coverage\builds\2015-07-26_13-34-30\violations\file\A:\highLevel\Monitor\InitialBootAdapter.py.xml
I don't really understand what happens.
Why pylint is interested in file InitialBootAdapter.py? Why it's looks for file InitialBootAdapter.py.xml? Who should create it and why? I searched for this file over all the environment and didn't find. But I did'nt find any xml for my other py files?
Maybe you have experience with pylint and can help?
Thank you.
I have experience with pylint in jenkins. And here is how I use it, hope it will help someone.
Step 1
Add a "Execute Shell" step and execute the pylint command to generate the pylint.out. Please note
/usr/local/bin/pylint -f parseable -d I0011,R0801 my-python-project-folder | tee pylint.out
Step 2
Make sure you have the Violation Report Plugin, after that , click Add post-build action-->Report Violation, put the pylint.out in the corresponding field.
And after the successful run, the pylint report looks like this:
I fixed the problem, it took time and DevOps help but it worked and is described in my own blog (it's more my online notebook than blog) in very small details.
The most important point in this post is small utility
import fileinput, sys
if __name__ == "__main__":
for line in fileinput.FileInput(sys.argv[1], inplace=True):
if ".cs" in line:
line = line.replace("\\", "/")
print line,
Here sys.argv[1] should be path to your violations.xml file.
You have to move the path as a command line argument to the utility as path to your violations.xml file is dynamic and depends on build id.
Related
I am trying to make a python script that runs the command line for turning a file into a .zip using python3 on my Mac.
However, whenever I run: os.system('zip -er file.zip /Users/mymac/Desktop/file.py') in python3, I get the error:
zip I/O error: Read-only file system
zip error: Could not create output file (file.zip)
I have tried disabling SIP on my Mac, as well as trying to use subprocess but I get the same message every time. I am really unsure why this happens... Is anyone able to help out?
i will suggest 3 steps !
first run :
fsck -n -f
then reboot !
make sure to run the python file as root
import os
try:
os.system('zip mag.zip mag.ppk')
print ('success')
except:
print ('problem')
screnshoot for my test
I am trying to learn chef and very new at it.
I have a requirements.txt file which I'm trying to execute through a chef recipe to install some Python modules. I have tried different variations of the code, however I feel like I'm missing something. I have tried writing the following code in the chef recipe:
template '/etc' do
source 'requirements.txt.erb'
owner 'root'
group 'root'
mode '0644'
end
execute 'requirements.txt' do
command 'pip install -r requirements.txt'
action 'run'
end
I was expecting that the requirements file will be called when I run vagrant up and the modules/dependencies of the app will be installed. However, I get this error:
Error executing action run on resource 'execute[requirements.txt]'
Check this example from https://docs.chef.io/resource_execute.html
execute 'upgrade script' do
command 'php upgrade-application.php && touch /var/application/.upgraded'
creates '/var/application/.upgraded'
action :run
end
You need to specify the run action as shown above (:run) rather than with single quotes as shown in your posted example.
if i am not mistaken, i think that coderanger developed a cookbook named python-poise, which has pip_requirements chef resource. it looks like:
pip_requirements '/opt/myapp/requirements.txt'
I get this weird error:
$ epylint .
*************
mysubdir/__init__.py:1: fatal (F0010, parse-error, ) error while code parsing: Unable to load file 'mysubdir/__init__.py' ([Errno 2] No such file or directory: 'mysubdir/__init__.py')
Note that mysubdir/__init__.py does exist and contains a single empty line.
Note that
$ epylint mysubdir
works just fine and produces no messages.
What am I doing wrong?
The problem is you're running pylint in your workdir (pylint .). Pylint will expect an init.py file there.
Take a look at this discussion.
Your best shot is to select the directories you want to lint. If you can't do so (ie: Django project). You'll have to make a custom workaround like in the thread.
I'm pretty new to git, but I'm trying to use python to check if a git repository has any uncommitted changes. I seem to get the same error no matter what command I try to run using python. Here's my code:
from git import *
repo = Repo("path\to\my\repo")
lastCommit = repo.head.commit.committed_date
uncommitted = repo.is_dirty()
Everything works as expected until I run the last line which is when I get the error:
Traceback (most recent call last):
.
.
.
raise GitCommandNotFound: [Error 2] The system cannot find the file specified
I've tried this with other commands too and I get the same error. For example, repo.index.diff(repo.head.commit). I've also tried running repo.index.diff(None) and repo.index.diff('HEAD') which give the same error. What I really want is to essentially run $ git status for the repository I've named repo. I'm using Python 2.7.9 and gitpython 1.0.1 on Windows 7. Any help would be appreciated!
In your particular example (which is only for illustration purposes), your "path\to\my\repo" would be understood as 'path\to\\my\repo'. Use a double backslash between the components of your path ("path\\to\\my\\repo"). \t is understood as a tab, and \r is understood as a carriage return. Alternatively, you can put a r in front of your path like so: r"path\to\my\repo"
Look like GitPython can't find git.exe.
Try setting the environment variable GIT_PYTHON_GIT_EXECUTABLE.
It's should most likely be "C:\Program Files (x86)\Git\bin\git.exe" if using Git for Windows with defaults
at command line (cmd.exe)
set GIT_PYTHON_GIT_EXECUTABLE="C:\Program Files (x86)\Git\bin\git.exe"
Thanks for your suggestions, but implementing them did not actually solve my problem. I did develop a work-around with the following code:
def statusChecker(repo, lastCommit):
uncommittedFiles = []
files = os.listdir(repo)
for file in files:
if os.path.getmtime(repo + "\\\\" + file) > lastCommit:
uncommittedFiles.append(file)
uncommittedFiles = uncommittedFiles.remove(".git")
return uncommittedFiles
As long as you use something like lastCommit = repo.head.commit.committed_date for the lastCommit argument this should work well.
I'm facing of a strange issue, and after a couple of hour of research I'm looking for help / explanation about the issue.
It's quite simple, I wrote a cgi server in python and I'm working with some libs including pynetlinux for instance.
When I'm starting the script from terminal with any user, it works fine, no bug, no dependency issue. But when I'm trying to start it using a script in rc.local, the following code produce an error.
import sys, cgi, pynetlinux, logging
it produce the following error :
Traceback (most recent call last):
File "/var/simkiosk/cgi-bin/load_config.py", line 3, in
import cgi, sys, json, pynetlinux, loggin
ImportError: No module named pynetlinux
Other dependencies produce similar issue.I suspect some few things like user who executing the script in rc.local (root normaly) and trying some stuff found on the web without success.
Somebody can help me ?
Thanx in advance.
Regards.
Ollie314
First of all, you need to make sure if the module you want to import is installed properly. You can check if the name of the module exists in pip list
Then, in a python shell, check what the paths are where Python is looking for modules:
import sys
sys.path
In my case, the output is:
['', '/usr/lib/python3.4', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/usr/lib/python3.4/lib-dynload', '/usr/local/lib/python3.4/dist-packages', '/usr/lib/python3/dist-packages']
Finally, append those paths to $PATH variable in /etc/rc.local. Here is an example of my rc.local:
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing
export PATH="$PATH:/usr/lib/python3.4:/usr/lib/python3.4/plat-x86_64-linux-gnu:/usr/lib/python3.4/lib-dynload:/usr/local/lib/python3.4/dist-packages:/usr/lib/python3/dist-packages"
# Do stuff
exit 0
The path where your modules are install is probably normally sourced by .bashrc or something similar. .bashrc doesn't get sourced when it's not an interactive shell. /etc/profile is one place that you can put system wide path changes. Depending on what Linux version/distro it may use /etc/profile.d/ in which case /etc/profile runs all the scripts in /etc/profile.d, add a new shell script there with execute permissions and a .sh extention.