11import github
22from github import Github
3- import os ,sys ,platform ,base64
3+ import os ,sys ,platform ,base64 , time
44
55# Intializing the Variables
66# Hashed token
@@ -85,6 +85,7 @@ def printPRStatus(upstream_repo):
8585 max_num = max (max_num ,i .number )
8686 for i in pulls :
8787 max_num = max (max_num ,i .number )
88+ time .sleep (4 )
8889 print (f'Check your example here https://github.com/{ UPSTREAM_ACCOUNT } /{ REPO_NAME } /pulls/{ max_num + 1 } ' ,end = "" )
8990 except Exception as e :
9091 print ("Your example successfully uploaded but unable to fetch status.Please try again" )
@@ -94,6 +95,11 @@ def isImageFile(filename):
9495 image_extensions = ['.jpeg' , '.jpg' , '.png' ,'.gif' ]
9596 return any (filename .endswith (ext ) for ext in image_extensions )
9697
98+ def remove_prefix (text , prefix ):
99+ if text .startswith (prefix ):
100+ return text [len (prefix ):]
101+ return text
102+
97103
98104# Decode Github Token
99105def decode_token (encoded_token ):
@@ -154,7 +160,7 @@ def decode_token(encoded_token):
154160 else :
155161 with open (path , 'r' ) as file :
156162 content = file .read ()
157- file_path = f'{ DIR_PATH + path . removeprefix ( STUDY_NAME_PATH )} '
163+ file_path = f'{ DIR_PATH + remove_prefix ( path , STUDY_NAME_PATH )} '
158164 if (platform .uname ()[0 ]== 'Windows' ): file_path = file_path .replace ("\\ " ,"/" )
159165 appendBlobInTree (repo ,content ,file_path ,tree_content )
160166 commitAndUpdateRef (repo ,tree_content ,base_ref .commit ,branch )
0 commit comments