Created
August 19, 2019 13:19
-
-
Save MathiasSeguy-Android2EE/714f804e8f1a29d0491c030fcbc1b3bf to your computer and use it in GitHub Desktop.
Github: Pushing with fallback when id_rsa failed (asking for credential again) in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Import dependencies | |
from subprocess import call | |
from os import path | |
from ownStyle import GREEN,BLUE,BOLD,GREEN,RED,RESET,CYAN | |
#Push the new or update files | |
# call('git push origin master', shell = True) | |
#The command line will prompt you | |
def runGitPushInCommandLine(repository): | |
# print(repository) | |
absRepo=path.abspath(repository) | |
try: | |
# print(absRepo) | |
toto=call('git push --force', cwd=absRepo, shell = True) | |
# print(toto) | |
if toto != 0: | |
doitagain=input(RED+"try again ? [y (for yes) else ==no]\n") | |
if doitagain in "y" or doitagain in "Y": | |
runGitPushInCommandLine(repository) | |
print(BLUE+"ok") | |
else: | |
print(GREEN+"Project has been pushed on GitHub, congrats.") | |
except: | |
doitagain=input("try aggain ? [y (for yes) else ==no]\n") | |
if doitagain in "y" or doitagain in "Y": | |
runGitPushInCommandLine(repository) | |
print(BLUE+"ok") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment