def publish(): entity_location = os.getcwd() if check_for_cor(): username = gc.github_login().get_user().login sync_backend() remote = gc.getremote() localindex = gc.get_cor_index() if localindex is None: localindex = gc.fork_on_github("bahusvel/COR-Index") if not os.path.exists(STORAGE_LOCAL_INDEX): os.chdir(CORCLISTORAGE) gc.gitclone(localindex.clone_url, aspath="localindex") os.chdir(STORAGE_LOCAL_INDEX) gc.gitpull() # create corfile here local_cordict = read_corfile(entity_location + "/.cor/corfile.json") local_cordict["repo"] = remote if local_cordict["type"] == "MODULE": prefix = "modules" elif local_cordict["type"] == "FRAMEWORK": prefix = "frameworks" else: raise Exception(local_cordict["type"] + "is an invalid type") public_name = local_cordict["name"].lower() public_corfile_path = STORAGE_LOCAL_INDEX+"/" + prefix + "/" + public_name + ".json" write_corfile(local_cordict, public_corfile_path) gc.gitadd(public_corfile_path) gc.gitcommit("Added " + public_name) gc.gitpush() try: gc.github_pull_request(localindex.full_name, username, "COR-Index", "Add " + public_name) except Exception: click.secho("Pull request failed, please create one manualy", err=True) else: click.secho("Not a COR-Entity (Framework, Module, Recipe)", err=True)
def get_module(name, url): if name is None and url is None: name = click.prompt("Enter the module name") if name is not None and url is None: file = STORAGEINDEX+"/modules/"+name+".json" if os.path.exists(file): cordict = read_corfile(file) url = cordict["repo"] else: click.secho("The module you requested is not in the index", err=True) url = click.prompt("Please enter the url for the module") if url is not None: gc.gitclone(url)
def upgrade(local): if not os.path.exists(CORCLISTORAGE): os.mkdir(CORCLISTORAGE) if not local: if not os.path.exists(CORCLISTORAGE+"/cli"): os.chdir(CORCLISTORAGE) gc.gitclone(CORCLI, aspath="cli") os.chdir(CORCLISTORAGE+"/cli") gc.gitpull() if not local: os.system("pip install --upgrade .") else: os.system("pip install --upgrade --editable .")
def update(new_index): if new_index is not None: shutil.rmtree(STORAGEINDEX) if not os.path.exists(CORCLISTORAGE): os.mkdir(CORCLISTORAGE) if not os.path.exists(STORAGEINDEX): os.chdir(CORCLISTORAGE) if new_index is not None: gc.gitclone(new_index, aspath="index") else: gc.gitclone(CORINDEX, aspath="index") else: os.chdir(STORAGEINDEX) gc.gitpull()
def get_module(url): #if get_type() == TYPE.RECIPE: # add module to recipe correctly # pass gc.gitclone(url)