试图用子进程模块克隆Gitlab repo的列表
我正在尝试从我的GitLab服务器中克服大量的GitLab存储库列表。但是,我很难让子进程模块工作。我已经尝试了这个问题的答案,但对我不起作用。
“
repo_list = [list_with_all_repository_names]
for repo_name in repo_list:
repo_url = f'https://url_to_my_gitlab_server/{repo_name}.git'
p = subprocess.run(["C:/Users/my_user_name/AppData/Local/Programs/Git/git-bash.exe",
"C:/Users/my_user_name/Documents/Gitlab Repos/git-clone-shell.sh",
f"git clone {repo_name}"],
bufsize=-1,
executable=None,
stdin=None,
stdout=None,
stderr=None,
preexec_fn=None,
close_fds=False,
shell=False,
cwd="C:/Users/my_user_name/Documents/Gitlab Repos")
time.sleep(20)
> f“ git clone {repo_name}”
subprocess.run 调用,因此它的内容不超过$ 1
git bash opens opens opens立即崩溃,我不知道为什么。我还试图在没有外壳脚本的情况下直接在bash中直接运行命令,但是这只是打开git bash,什么也不做:
p = subprocess.run(
[f'git clone {repo_url}'],
bufsize=-1,
executable='C:/Users/my_user_name/AppData/Local/Programs/Git/git-bash.exe',
capture_output=True,
cwd="C:/Users/my_user_name/Documents/Gitlab Repos"
)
我感觉自己接近解决方案,但我不明白它的问题在哪里。
I'm trying to clone a big list of GitLab repositories from my GitLab Server. However, I'm having trouble getting the subprocess module to work. I've tried the answer to this question but it won't work for me. Open Git Bash shell using a python script and then run a shell script in git bash shell
Here is my code:
repo_list = [list_with_all_repository_names]
for repo_name in repo_list:
repo_url = f'https://url_to_my_gitlab_server/{repo_name}.git'
p = subprocess.run(["C:/Users/my_user_name/AppData/Local/Programs/Git/git-bash.exe",
"C:/Users/my_user_name/Documents/Gitlab Repos/git-clone-shell.sh",
f"git clone {repo_name}"],
bufsize=-1,
executable=None,
stdin=None,
stdout=None,
stderr=None,
preexec_fn=None,
close_fds=False,
shell=False,
cwd="C:/Users/my_user_name/Documents/Gitlab Repos")
time.sleep(20)
My shell script is simply a placeholder for the f"git clone {repo_name}"
argument in the subprocess.run
call, and therefore it's contents are no more than $1
Git bash opens but immediatly crashes and I don't know why. I've also tried to run the command directly in bash without a shell script, but this simply opens git bash and does nothing:
p = subprocess.run(
[f'git clone {repo_url}'],
bufsize=-1,
executable='C:/Users/my_user_name/AppData/Local/Programs/Git/git-bash.exe',
capture_output=True,
cwd="C:/Users/my_user_name/Documents/Gitlab Repos"
)
I have the feeling that I'm close to a solution but I don't understand where it's going wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过在WSL环境中运行脚本来解决问题,并具有以下子过程设置:
I've solved the problem by running the script in a WSL-environment, with the following subprocess setting: