Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

python subprocess.check_call

def update():
    """Update to the latest pages."""
    repo_directory = get_config()['repo_directory']
    os.chdir(repo_directory)
    click.echo("Check for updates...")

    local = subprocess.check_output('git rev-parse master'.split()).strip()
    remote = subprocess.check_output(
        'git ls-remote https://github.com/tldr-pages/tldr/ HEAD'.split()
    ).split()[0]
    if local != remote:
        click.echo("Updating...")
        subprocess.check_call('git checkout master'.split())
        subprocess.check_call('git pull --rebase'.split())
        build_index()
        click.echo("Update to the latest and rebuild the index.")
    else:
        click.echo("No need for updates.")
Comment

python subprocess.check_call

def mpi_fork(n, bind_to_core=False):
    """Re-launches the current script with workers
    Returns "parent" for original parent, "child" for MPI children
    """
    if n<=1: 
        return "child"
    if os.getenv("IN_MPI") is None:
        env = os.environ.copy()
        env.update(
            MKL_NUM_THREADS="1",
            OMP_NUM_THREADS="1",
            IN_MPI="1"
        )
        args = ["mpirun", "-np", str(n)]
        if bind_to_core:
            args += ["-bind-to", "core"]
        args += [sys.executable] + sys.argv
        subprocess.check_call(args, env=env)
        return "parent"
    else:
        return "child"
Comment

PREVIOUS NEXT
Code Example
Shell :: bash tab adds backslash before dollar sign 
Shell :: what is -e flag for in bash sed? 
Shell :: cmd if compare more than 
Shell :: tag stale git branches to remove them but be able to restore them if necessary 
Shell :: docker cleanup - Remove Docker Images, Containers, Networks & Volumes 
Shell :: personal - git config user 
Shell :: how to install pm2 in obunto without npm 
Shell :: fedora netflix 
Shell :: deleting when you terminate it 
Shell :: set the environment path variable for ffmpeg by running the following command: 
Shell :: CMake 3.16.0 or higher is required. You are running version 3.10.2 
Shell :: stash recrusive submodules 
Shell :: fish function to change php version .env 
Shell :: openssl cannot gen key 
Shell :: How to install google consent script for CMP banner 
Shell :: xargs column cut linux 
Shell :: linux text shortcut 
Shell :: Fedora RPM Fusion with dnf 
Shell :: sort specific extension by date 
Shell :: how to create a new branch in git 
Shell :: docker pull 
Shell :: microk8s port forward 
Shell :: how to get device name in lsusb 
Shell :: how to create new repository in github via powershell 
Shell :: zsh: permiso denegado: /home/sebastian/.bash_aliases 
Shell :: composer preferred-install dist and source 
Shell :: ERR_DEVICE_LOCKED: Device still locked after 1 minute. 
Shell :: linux mint suspend keybinding cli 
Shell :: Remove Lock with folder & sub directory 
Shell :: linux for loop 1 to 100 odd 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =