How to do git checkout -q --archive with Python? - python

I'm trying build an code in python using git.Is there any command to do git checkout -q --dir on python?
Now I'm using Python 3 and git package to do this, but i don't found command to this.
I'm running a git pull before (and the command exists), there is a file that can not be deleted and only the git checkout can restore it. Anyone know if this is possible?

Related

How to install package dependencies for a custom Airbyte connector?

I'm developing a custom connector for Airbyte, and it involves extracting files from different compressed formats, like .zip or .7z. My plan was to use patool for this, and indeed it works in local tests, running:
python main.py read --config valid_config.json --catalog configured_catalog_old.json
However, since Airbyte runs in docker containers, I need those containers to have packages like p7zip installed. So my question is, what is the proper way to do that?
I just downloaded and deployed Airbyte Open Source in my own machine using the recommended commands listed on Airbyte documentation:
git clone https://github.com/airbytehq/airbyte.git
cd airbyte
docker compose up
I tried using docker exec -it CONTAINER_ID bash into airbyte/worker and airbyte/connector-builder-server, to install p7zip directly, but it's not working yet. My connector calls patoolib from a Python script, but it is unable to process the given file, because it fails to find a program to extract it. This is the log output:
> patool: Extracting /tmp/tmpan2mjkmn ...
> unknown archive format for file `/tmp/tmpan2mjkmn'
It turns out I completely ignored that the connector template comes with a Dockerfile, which is used precisely to configure the container that is supposed to run the connector code. So all I had to do was to add this line do Dockerfile:
RUN apt-get update && apt-get install -y file p7zip p7zip-full lzma lzma-dev
Specifically, to use patoolib, I had to install the file package, so it could detect the mime type of archive files.

git commit is not working with "python was not found..." warning [duplicate]

This question already has an answer here:
Git commit returns error docker/error response from deamon on windows
(1 answer)
Closed 4 months ago.
I am trying to commit a couple of files using git bash on windows 10. After doing git add, the file get staged and appear in green. Next when I run git commit , there is below message and nothing happens
"Python was not found but can be installed from the Microsoft Store: ms-windows-store://pdp/?productid=9NJ46SX7X90P"
I checked the python version by running python --version is git bash and it displays Python 2.7.2
Can someone please help me fix the issue with git commit ?
You can figure out if it is caused by a git hook using the following command:
strace git commit | grep access
If the reason for the error is a git hook, in the output, you'll be able to see that last accessed file like .git/hooks/pre-commit.

git bash freezes when I run "python manage.py runserver"

I'm trying to learn django and have already created my project using startproject. Now I want to run the server but it won't work in git bash. It works if I use powershell or cmd but it just freezes in git bash. It says "Watching for file changes with StatReloader" but does nothing. Please help I want to use git bash to run my commands. Thanks
The Django auto reloading feature is recent: make sure to use the latest Git for Windows (v2.25.0-rc0.windows.1) to see if the issue persists in a git bash session.
If this is based on inotify to do file watching... that might not be compatible with mingw.

How to ignore generated cpp files (from swig/python) in Coverity Scan?

I've got a C++ project with Python bindings generated by SWIG. I get a generated file python/libproj_wrap.cpp from SWIG. This file is listed in .gitignore.
I'm running Coverity Scan through Travis. It seems like Coverity Scan tries to run git blame on this, which fails:
fatal: no such path 'python/libproj_wrap.cpp' in HEAD
[WARNING] An error occurred while executing command at '/home/travis/build/unhammer/proj/python':
COMMAND: '/usr/bin/git blame -p proj_wrap.cpp' failed. Error code 128. Proceeding...
and I get no scan results. Is there a way to tell Coverity Scan to ignore .gitignore'd stuff, or should I just run the scan on a build configured without SWIG bindings?
That would happen if python/libproj_wrap.cpp was tracked before being added to the .gitignore.
Just to be sure, try and untrack it:
git rm --cached python/libproj_wrap.cpp
git commit -m "untrack python/libproj_wrap.cpp"
git push
And see if Travis is still trying a git blame on that file.

git-clean with GitPython

Is there any way to do something like git clean -d -x -f using GitPython?
I need to reset working directories and want to get rid of all unversioned files without deleting the whole folder (except for .git) and checking out again.
You can work around by using the git command directly, from gitpython
git = repo.git
git.clean('-xdf')

Categories