-
-
Notifications
You must be signed in to change notification settings - Fork 954
-
The command gh auth login --with-token<ghKeysconfig
in the terminal works fine.
Here, ghKeysconfig
is the file.
But when I use my python script with GitPython as follows
gLocal = git.Git("ansible")
authenticate_gh = gLocal.execute(["gh","auth","login","--with-token","<ghKeysconfig"])
It shows this error -
Cmd('gh') failed due to: exit code(1)
cmdline: gh auth login --with-token <ghKeysconfig
stderr: 'accepts 0 arg(s), received 1'
Beta Was this translation helpful? Give feedback.
All reactions
It's not easly possible to pass standard input, i.e. the <ghKeysconfig
part via the git
command in GitPython
.
Instead I recommend using a standard Popen
call to wire up standard input to pass the contents of the token file to the gh
process.
Replies: 1 comment 3 replies
-
It's not easly possible to pass standard input, i.e. the <ghKeysconfig
part via the git
command in GitPython
.
Instead I recommend using a standard Popen
call to wire up standard input to pass the contents of the token file to the gh
process.
Beta Was this translation helpful? Give feedback.
All reactions
-
Popen did not work as well -
process = subprocess.Popen(["gh","auth","login","--with-token","<ghKeysconfig"], stdout=PIPE, stderr=PIPE, cwd='ansible')
pull_changedFilesOriginal, stderroutput = process.communicate()
It shows
stderroutput = "b'accepts 0 arg(s), received 1\n'"
Beta Was this translation helpful? Give feedback.
All reactions
-
The call presented here is the same as above and thus doesn't try to pipe the token file gh
via stdin
. Something like this could work, and if not please consult the documentation of popen
on how to pass things via stdin
process = subprocess.Popen(["gh","auth","login","--with-token"], stdin=os.open("ghKeysconfig", "r"), cwd='ansible') pull_changedFilesOriginal, stderroutput = process.communicate()
Beta Was this translation helpful? Give feedback.
All reactions
-
Yes, a little bit of change working fine for me. Thanks @Byron
process = subprocess.Popen(["gh","auth","login","--with-token"], stdin=open("ghKeysconfig", "r"), cwd='ansible')
pull_changedFilesOriginal, stderroutput = process.communicate()
Beta Was this translation helpful? Give feedback.