From 49f668a24782542dfe30b4a67278f45becd3d602 Mon Sep 17 00:00:00 2001 From: Parteek Goyal Date: Sat, 5 Aug 2023 11:36:40 +0530 Subject: [PATCH 1/4] Update contribute.py --- contribute.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/contribute.py b/contribute.py index aa81f27..86a730f 100644 --- a/contribute.py +++ b/contribute.py @@ -165,9 +165,13 @@ def decode_token(encoded_token): content = file.read() file_path = f'{DIR_PATH+remove_prefix(path,STUDY_NAME_PATH)}' if(platform.uname()[0]=='Windows'): file_path=file_path.replace("\\","/") + print(path) appendBlobInTree(repo,content,file_path,tree_content) + print('append comp') commitAndUpdateRef(repo,tree_content,base_ref.commit,branch) + print('comit comp') runWorkflow(repo,upstream_repo) + print('work comp') except Exception as e: print(e) print("Some error Occured.Please try again after some time.",end="") From b5fc368ed7cd9c277517dfadeafda76fd4827acd Mon Sep 17 00:00:00 2001 From: Parteek Goyal Date: Sun, 6 Aug 2023 07:52:54 +0530 Subject: [PATCH 2/4] Update contribute.py --- contribute.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/contribute.py b/contribute.py index 86a730f..227b4d8 100644 --- a/contribute.py +++ b/contribute.py @@ -59,7 +59,7 @@ def commitAndUpdateRef(repo,tree_content,commit,branch): def appendBlobInTree(repo,content,file_path,tree_content): - blob = repo.create_git_blob(content,'utf-8') + blob = repo.create_git_blob(content,'ascii') tree_content.append( github.InputGitTreeElement(path=file_path,mode="100644",type="blob",sha=blob.sha)) @@ -106,7 +106,6 @@ def decode_token(encoded_token): decoded_bytes = encoded_token.encode("ascii") convertedbytes = base64.b64decode(decoded_bytes) decoded_token = convertedbytes.decode("ascii") - print('token decoded successfully') return decoded_token @@ -155,23 +154,20 @@ def decode_token(encoded_token): for root, dirs, files in os.walk(STUDY_NAME_PATH): for filename in files: path = f"{root}/{filename}" + print(path) if isImageFile(filename): - with open(path, 'rb') as file: + with open(file=path, mode='rb', encoding='ascii') as file: image = file.read() - print('image processing') content = base64.b64encode(image).decode('utf-8') else: - with open(path, 'r') as file: + with open(file=path, mode='r',encoding='ascii') as file: content = file.read() file_path = f'{DIR_PATH+remove_prefix(path,STUDY_NAME_PATH)}' if(platform.uname()[0]=='Windows'): file_path=file_path.replace("\\","/") - print(path) + print('d',end="") appendBlobInTree(repo,content,file_path,tree_content) - print('append comp') commitAndUpdateRef(repo,tree_content,base_ref.commit,branch) - print('comit comp') runWorkflow(repo,upstream_repo) - print('work comp') except Exception as e: print(e) print("Some error Occured.Please try again after some time.",end="") From 438d328978634f461a017f63eef5c35542d0d06b Mon Sep 17 00:00:00 2001 From: Parteek Goyal Date: Sun, 6 Aug 2023 07:56:57 +0530 Subject: [PATCH 3/4] Update contribute.py --- contribute.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contribute.py b/contribute.py index 227b4d8..bb70f7b 100644 --- a/contribute.py +++ b/contribute.py @@ -156,7 +156,7 @@ def decode_token(encoded_token): path = f"{root}/{filename}" print(path) if isImageFile(filename): - with open(file=path, mode='rb', encoding='ascii') as file: + with open(file=path, mode='rb') as file: image = file.read() content = base64.b64encode(image).decode('utf-8') else: From 27d5998a678bf86651a0dcbb6353ba1f7786c4ab Mon Sep 17 00:00:00 2001 From: Parteek Goyal Date: Sun, 6 Aug 2023 21:12:24 +0530 Subject: [PATCH 4/4] Update contribute.py --- contribute.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/contribute.py b/contribute.py index bb70f7b..c648261 100644 --- a/contribute.py +++ b/contribute.py @@ -59,7 +59,7 @@ def commitAndUpdateRef(repo,tree_content,commit,branch): def appendBlobInTree(repo,content,file_path,tree_content): - blob = repo.create_git_blob(content,'ascii') + blob = repo.create_git_blob(content,'utf-8') tree_content.append( github.InputGitTreeElement(path=file_path,mode="100644",type="blob",sha=blob.sha)) @@ -152,6 +152,7 @@ def decode_token(encoded_token): try: for root, dirs, files in os.walk(STUDY_NAME_PATH): + files = [f for f in files if not f[0] == '.'] for filename in files: path = f"{root}/{filename}" print(path) @@ -160,7 +161,7 @@ def decode_token(encoded_token): image = file.read() content = base64.b64encode(image).decode('utf-8') else: - with open(file=path, mode='r',encoding='ascii') as file: + with open(file=path, mode='r') as file: content = file.read() file_path = f'{DIR_PATH+remove_prefix(path,STUDY_NAME_PATH)}' if(platform.uname()[0]=='Windows'): file_path=file_path.replace("\\","/")