def _record_ipython(file, func, startup=None): call_echo( ["powershell", "-command", "Set-WinUserLanguageList -Force 'en-US'"]) open_wt_ipython(startup=startup) recorder.rect = (0, 0, 1920, 1080) recorder.file = file recorder.start_record() func() sleep(2) recorder.stop_record() send_hotkey("alt", "f4") sleep(1) call_echo([ "powershell", "-command", "Set-WinUserLanguageList -Force 'zh-CN', 'en-US'" ]) return file
def install_package(name): # choco list -lo lines = proc_lines(["choco", "list", "-lo"]) lines = [x for x in lines if x.startswith(name)] if len(lines) > 0: print("Upgrade `%s`..." % name) call_echo(["choco", "upgrade", name, "-y"]) else: print("Install `%s`..." % name) call_echo(["choco", "install", name, "-y"])
def show_git_log(): call_echo( [ "git", "log", "--date=relative", "--pretty=format:%C(yellow)%h %Cblue%ad %Cgreen%aN%Cred%d %Creset%s", "--graph", "-10", ], check=False, )
def commit(dry_run=False, amend=False): if dry_run: call_echo("git status --short") else: if get_output("git diff --shortstat"): call_echo("git add -A") if amend: call_echo("git commit --amend --no-edit --quiet") else: message = input("commit message: ") if not message: message = "Temporary commit @ %s" % get_time_str() call_echo(["git", "commit", "-m", message])
def install_glslang(): assert sys.platform == "win32" path = os.path.abspath("/tools/glslang") if not os.path.exists(path): cd(gettempdir()) f = download( "https://github.com/KhronosGroup/glslang/releases/download/master-tot/glslang-master-windows-x64-Release.zip" ) unzip(f, to=path) return os.path.abspath("/tools/glslang/bin/glslangValidator.exe") if __name__ == "__main__": call_echo([sys.executable, "-m", "pip", "install", "pylint"]) call_echo([sys.executable, "-m", "pip", "install", "autopep8"]) print2("Update key bindings...") with open(os.path.expandvars(DATA_DIR + "/User/keybindings.json"), "w") as f: json.dump( [ { "key": "ctrl+shift+v", "command": "markdown.showPreviewToSide", "when": "!notebookEditorFocused && editorLangId == 'markdown'", }, { "key": "shift+alt+r",
else: print("Install `%s`..." % name) call_echo(["choco", "install", name, "-y"]) if __name__ == "__main__": pkg_list = [cate for cate in PKGS if cate.startswith("@")] + sorted( set([app for cate in PKGS.values() for app in cate]) ) idx = Menu(items=pkg_list).get_selected_index() if idx < 0: sys.exit(1) call_echo( [ "choco", "source", "add", "--name=chocolatey", "--priority=-1", '-s="https://chocolatey.org/api/v2/"', ] ) if pkg_list[idx].startswith("@"): for pkg in PKGS[pkg_list[idx]]: install_package(pkg) else: install_package(pkg_list[idx])
import os cd("c:/Users/Ross/Google Drive/KidslogicVideo/ep35/animation/icons") for f in get_files(cd=True): mkdir("shadow") out_file = os.path.join("shadow", os.path.basename(f)) call_echo( [ "magick", f, "(", "-clone", "0", "-background", "black", "-shadow", "80x5+0+0", ")", "-reverse", "-background", "none", "-layers", "merge", "+repage", out_file, ] )
def git_push(): call_echo("git push -u origin master --force")
def revert(): call_echo("git status --short") if not yes("Revert all files?"): return call_echo("git reset HEAD --hard")
def switch_branch(): call_echo(["git", "branch"]) name = input("Switch to branch [master]: ") if not name: name = "master" call_echo(["git", "checkout", name])
def create_bundle(): if bundle_file is not None: print2("Create bundle: %s" % bundle_file) call_echo(["git", "bundle", "create", bundle_file, "master"])
if __name__ == "__main__": repo_dir = r"{{GIT_REPO}}" repo_name = os.path.basename(repo_dir) if sync_github: FNULL = fnull() ret = subprocess.call("gh repo view rossning92/%s" % repo_name, shell=True, stdout=FNULL) if ret == 1: cd(os.path.dirname(repo_dir)) if not yes('Create "%s" on GitHub?' % repo_name): sys.exit(1) call_echo("gh repo create %s" % repo_name) # Init repo cd(repo_dir) if not os.path.exists(".git"): call_echo("git init") call_echo( "git remote add origin https://github.com/rossning92/%s.git" % repo_name) # Add .gitignore add_gitignore() # .gitattribute if not os.path.exists(".gitattributes"): with open(".gitattributes", "w") as f: