import os import shutil from os import path from zipfile import ZipFile from shutil import make_archive import sys def main(): print ("Basename: " ,path.basename(__file__)) print (sys.argv[0]) print ("Basename: " ,path.realpath(__file__)) filename = "clipseg-master.zip" extract_dir = "clipseg" archive_format = "zip" if path.exists(filename): print ("yes zip location exists.") print ("filename :: ", filename) print ("extract_dir :: ", extract_dir) print ("archive_format :: ", archive_format) src=path.realpath(filename) print ("zip location:", src) root_dir,tail = path.split(src) print ("split- root_dir:", root_dir) print ("split- tail:", tail) extract_dir=root_dir+'/'+extract_dir print ("extract_dir:", "./clipseg") shutil.unpack_archive(filename, extract_dir, archive_format) #shutil.make_archive("test","zip",root_dir) print ("Archive file unpacked successfully.") else: print ("Archive file unpacked un-successfully.") if __name__=="__main__": main() #import gradio as gr #import git #import os #print('Get current working directory : ', os.getcwd()) #path=os.getcwd() #path=os.getcwd()+"clipseg/" #from pathlib import Path #print('working path', Path.cwd()) #git.Git(path).clone("https://github.com/git") #from zipfile import ZipFile #ZipFile("clipseg-master.zip").extractall(path) #import zipfile #def un_zipFiles(path): # files=os.listdir(path) # for file in files: # if file.endswith('.zip'): # filePath=path+'/'+file # zip_file = zipfile.ZipFile(filePath) # for names in zip_file.namelist(): # zip_file.extract(names,path) # zip_file.close() #download_and_extract_zip_file() #clone_github_repository() #with gr.Blocks() as demo: #demo.launch() """ import time import git git.Git("./clipseg").clone("https://github.com/git") """ #from git import RemoteProgress #class CloneProgress(RemoteProgress): # def update(self, op_code, cur_count, max_count=None, message=''): # if message: # print(message) #git_root='home/user/app/clipseg1' #print('Cloning into %s' % git_root) #git.Repo.clone_from('https://github.com/git', git_root, # branch='master', progress=CloneProgress()) #------------- """ import sys import os from zipfile import ZipFile zf = ZipFile('clipseg-master.zip', 'r') zf.extractall('./clipseg') zf.close() path = "./clipseg" clone = "git clone https://github.com/git" os.system("sshpass -p password ssh nightfury@localhost") os.chdir(path) # Specifying the path where the cloned project needs to be copied os.system(clone) # Cloning """ #from huggingface_hub import hf_hub_download #hf_hub_download(repo_id="ThereforeGames/txt2mask", filename="/repositories/clipseg/") #clone_from (str, optional) — Either a repository url or repo_id. Example: #api = HfApi() #from huggingface_hub import Repository #with Repository(local_dir="clipseg", clone_from="ThereforeGames/txt2mask/repositories/clipseg/") """ import sys import os from zipfile import ZipFile zf = ZipFile('clipseg-master.zip', 'r') zf.extractall('./clipseg') zf.close() from huggingface_hub import HfApi api = HfApi() api.upload_folder( folder_path="/", path_in_repo="ThereforeGames/txt2mask/repositories/clipseg/", repo_id="ThereforeGames/txt2mask", # repo_type="dataset", # ignore_patterns="**/logs/*.txt", ) """ #.commit(commit_message="clipseg uploaded...") # with open("file.txt", "w+") as f: # f.write(json.dumps({"hey": 8}))