Python fabric.api.hide() Examples

The following are 30 code examples of fabric.api.hide(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module fabric.api , or try the search function .
Example #1
Source File: operations.py    From fabricio with MIT License 6 votes vote down vote up
def _command(
    fabric_method,
    command,
    ignore_errors=False,
    quiet=True,
    hide=('running', 'aborts'),
    show=(),
    abort_exception=Error,
    **kwargs
):
    if quiet:
        hide += ('output', 'warnings')
    log('{method}: {command}'.format(
        method=fabric_method.__name__,
        command=command,
    ))
    with fab.settings(
        fab.hide(*hide),
        fab.show(*show),
        abort_exception=abort_exception,
        warn_only=ignore_errors,
    ):
        return fabric_method(command, **kwargs) 
Example #2
Source File: commands.py    From rpl-attacks with GNU Affero General Public License v3.0 6 votes vote down vote up
def build(name, ask=True, **kwargs):
    """
    Build the malicious mote to its target hardware.

    :param name: experiment name (or absolute path to experiment)
    :param ask: ask confirmation
    :param path: expanded path of the experiment (dynamically filled in through 'command' decorator with 'expand')
    :param kwargs: simulation keyword arguments (see the documentation for more information)
    """
    def is_device_present():
        with settings(hide(*HIDDEN_ALL), warn_only=True):
            return local("if [ -c /dev/ttyUSB0 ]; then echo 'ok'; else echo 'nok'; fi", capture=True) == 'ok'

    console = kwargs.get('console')
    counter, interval = 0.0, 0.5
    while not is_device_present():
        sleep(interval)
        counter += interval
        if counter % 5 == 0:
            logger.warning("Waiting for mote to be detected...")
        elif counter >= 120:
            logger.error("Something failed with the mote ; check that it mounts to /dev/ttyUSB0")
            return
    remake(name, build=True, **kwargs) if console is None else console.do_remake(name, build=True, **kwargs)
    return "Mote built on /dev/ttyUSB0" 
Example #3
Source File: fabfile.py    From elijah-provisioning with Apache License 2.0 6 votes vote down vote up
def check_system_support():
    # check hardware support
    if run("egrep '^flags.*(vmx|svm)' /proc/cpuinfo > /dev/null").failed:
        abort("Need hardware VM support (vmx)")

    # check minimum kernel version:
    #   Linux kernel under 3.13.0 has a bug where the kernel crash 
    #   when EPT support enabled with FUSE+mmap.
    WORKING_KERNEL_VERSION = "3.13.0"
    kernel_version = platform.platform().split("-")[1]
    if LooseVersion(kernel_version) < LooseVersion(WORKING_KERNEL_VERSION):
        msg = "Linux Kernel lower than %s has a bug when using FUSE + mmap"\
            % WORKING_KERNEL_VERSION
        abort(msg)

    # check OS version
    cmd = "cat /etc/lsb-release | grep DISTRIB_CODENAME | awk -F'=' '{print $2}'"
    with settings(hide('everything'), warn_only=True):
        os_dist = run(cmd)
        if os_dist != 'trusty' and os_dist != "xenial":
            msg = "Support only Ubuntu Precise (14.04) or Ubuntu Trusty (16.04)"
            abort(msg)
        return os_dist
    return None 
Example #4
Source File: repository.py    From automation-tools with GNU General Public License v3.0 6 votes vote down vote up
def _silencer(func):
    """Decorator which runs the wrapped function with hide('stdout') if the
    ``silent`` keyword argument is provided.

    The ``silent`` keyword argument will be removed from the kwargs before
    calling the wrapped function.

    """
    @wraps(func)
    def wrapper(*args, **kwargs):
        silent = kwargs.pop('silent', False)
        if silent:
            with hide('stdout'):
                return func(*args, **kwargs)
        return func(*args, **kwargs)
    return wrapper 
Example #5
Source File: auto_deploy_app_remote.py    From python-auto-deploy with MIT License 6 votes vote down vote up
def shutdown_api():
    
    print green('Shutdown the mall api via the remote_shutdown.sh scripts.')
    print 'Logs output to the '+log_path+'/shutdown_api.log'

    os.system('mkdir -p '+log_path+' 2>/dev/null >/dev/null')
    os.system("echo '' > "+log_path+"/shutdown_api.log")
    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" shutdown_api > "+log_path+"/shutdown_api.log 2>/dev/null >/dev/null")

    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" shutdown_api > "+log_path+"/shutdown_api.log 2>/dev/null >/dev/null")

    print green('Shutdown the mall api finished!')

# Startup the mall api via the remote_startup.sh scripts function. 
Example #6
Source File: auto_deploy_app_v_final.py    From python-auto-deploy with MIT License 6 votes vote down vote up
def restart_auth():
    print green('Restart the core platform via the restart.sh scripts.')
    
    ret = run("ps -ef|grep cmms-auth|grep -v grep|cut -c 9-15")

    if ret:
        with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
            run("ps -ef|grep cmms-auth|grep -v grep|cut -c 9-15|xargs kill -9 2>/dev/null >/dev/null")
    else:
        print red("No such progress!")

    ret_new = run("ps -ef|grep cmms-auth|grep -v grep|cut -c 9-15")

    if ret_new:
        print red('Startup already!')
    else:
        with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
            run('cd '+auth_path+' && java -jar cmms-auth.jar 2>/dev/null >/dev/null')

    print green('Restart the core platform finished!')

# Deploy core platform via mvn function. 
Example #7
Source File: auto_deploy_app_remote.py    From python-auto-deploy with MIT License 6 votes vote down vote up
def shutdown_admin():
    
    print green('Shutdown the mall admin via the remote_shutdown.sh scripts.')
    print 'Logs output to the '+log_path+'/shutdown_admin.log'

    os.system('mkdir -p '+log_path+' 2>/dev/null >/dev/null')
    os.system("echo '' > "+log_path+"/shutdown_admin.log")
    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" shutdown_admin > "+log_path+"/shutdown_admin.log 2>/dev/null >/dev/null")

    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" shutdown_admin > "+log_path+"/shutdown_admin.log 2>/dev/null >/dev/null")

    print green('Shutdown the mall admin finished!')

# Startup the mall admin via the remote_startup.sh scripts function. 
Example #8
Source File: auto_deploy_app_remote.py    From python-auto-deploy with MIT License 6 votes vote down vote up
def shutdown_api():
    
    print green('Shutdown the mall api via the shutdown.sh scripts.')
    print 'Logs output to the '+log_path+'/shutdown_api.log'

    os.system('mkdir -p '+log_path+' 2>/dev/null >/dev/null')
    os.system("echo '' > "+log_path+"/shutdown_api.log")
    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" shutdown_api > "+log_path+"/shutdown_api.log 2>/dev/null >/dev/null")

    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" shutdown_api > "+log_path+"/shutdown_api.log 2>/dev/null >/dev/null")

    print green('Shutdown the mall api finished!')

# Startup the mall api via the startup.sh scripts function. 
Example #9
Source File: auto_deploy_app_remote.py    From python-auto-deploy with MIT License 6 votes vote down vote up
def shutdown_admin():
    
    print green('Shutdown the mall admin via the shutdown.sh scripts.')
    print 'Logs output to the '+log_path+'/shutdown_admin.log'

    os.system('mkdir -p '+log_path+' 2>/dev/null >/dev/null')
    os.system("echo '' > "+log_path+"/shutdown_admin.log")
    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" shutdown_admin > "+log_path+"/shutdown_admin.log 2>/dev/null >/dev/null")

    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" shutdown_admin > "+log_path+"/shutdown_admin.log 2>/dev/null >/dev/null")

    print green('Shutdown the mall admin finished!')

# Startup the mall admin via the startup.sh scripts function. 
Example #10
Source File: auto_deploy_app_remote.py    From python-auto-deploy with MIT License 6 votes vote down vote up
def shutdown_api():
    
    print green('Shutdown the mall api via the shutdown.sh scripts.')
    print 'Logs output to the '+log_path+'/shutdown_api.log'

    os.system('mkdir -p '+log_path+' 2>/dev/null >/dev/null')
    os.system("echo '' > "+log_path+"/shutdown_api.log")
    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" shutdown_api > "+log_path+"/shutdown_api.log 2>/dev/null >/dev/null")

    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" shutdown_api > "+log_path+"/shutdown_api.log 2>/dev/null >/dev/null")

    print green('Shutdown the mall api finished!')

# Startup the mall api via the startup.sh scripts function. 
Example #11
Source File: auto_deploy_app_remote.py    From python-auto-deploy with MIT License 6 votes vote down vote up
def shutdown_admin():
    
    print green('Shutdown the mall admin via the shutdown.sh scripts.')
    print 'Logs output to the '+log_path+'/shutdown_admin.log'

    os.system('mkdir -p '+log_path+' 2>/dev/null >/dev/null')
    os.system("echo '' > "+log_path+"/shutdown_admin.log")
    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" shutdown_admin > "+log_path+"/shutdown_admin.log 2>/dev/null >/dev/null")

    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" shutdown_admin > "+log_path+"/shutdown_admin.log 2>/dev/null >/dev/null")

    print green('Shutdown the mall admin finished!')

# Startup the mall admin via the startup.sh scripts function. 
Example #12
Source File: auto_deploy_app_remote.py    From python-auto-deploy with MIT License 5 votes vote down vote up
def restart_nginx():

    print green('Restartup the shop via the nginx shutdown and startup scripts.')
    print 'Logs output to the '+log_path+'/restart_nginx.log'

    os.system('mkdir -p '+log_path+' 2>/dev/null >/dev/null')
    os.system("echo '' > "+log_path+"/restart_nginx.log")
    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" restart_nginx > "+log_path+"/restart_nginx.log 2>/dev/null >/dev/null")

    print green('Restart the shop finished!')

# Deploy shop repo to nginx server. 
Example #13
Source File: auto_deploy_app_remote.py    From python-auto-deploy with MIT License 5 votes vote down vote up
def startup_admin():

    print green('Startup the admin via the remote_startup.sh scripts.')
    print 'Logs output to the '+log_path+'/startup_admin.log'

    os.system('mkdir -p '+log_path+' 2>/dev/null >/dev/null')
    os.system("echo '' > "+log_path+"/startup_admin.log")
    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" startup_admin > "+log_path+"/startup_admin.log 2>/dev/null >/dev/null")

    print green('Startup the mall admin finished!')

# Restart the mall admin via the remote_restart.sh scripts function. 
Example #14
Source File: auto_deploy_app_remote.py    From python-auto-deploy with MIT License 5 votes vote down vote up
def shutdown_auth():

    print green('Shutdown the auth platform via the stop.sh scripts.')
    print 'Logs output to the '+log_path+'/shutdown_auth.log'

    os.system('mkdir -p '+log_path+' 2>/dev/null >/dev/null')
    os.system("echo '' > "+log_path+"/shutdown_auth.log")
    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" shutdown_auth > "+log_path+"/shutdown_auth.log 2>/dev/null >/dev/null")

    print green('Shutdown the auth platform finished!')

# Startup the auth platform via the startup.sh scripts function. 
Example #15
Source File: auto_deploy_app_v_final.py    From python-auto-deploy with MIT License 5 votes vote down vote up
def shutdown_core():
    print green('Shutdown the core platform via the stop.sh scripts.')
    
    ret = run("ps -ef|grep newark-core-platform|grep -v grep|cut -c 9-15")

    if ret:
        with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
            run("ps -ef|grep newark-core-platform|grep -v grep|cut -c 9-15|xargs kill -9 2>/dev/null >/dev/null")
    else:
        print red("No such progress!")

    print green('Shutdown the core platform finished!')

# Startup the core platform via the startup.sh scripts function. 
Example #16
Source File: auto_deploy_app_v_final.py    From python-auto-deploy with MIT License 5 votes vote down vote up
def startup_core():
    print green('Startup the core platform via the startup.sh scripts.')

    ret = run("ps -ef|grep newark-core-platform|grep -v grep|cut -c 9-15")

    if ret:
        print red("Startup already!")
    else:
        with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
            run('cd '+core_platform_path+' && java -jar newark-core-platform-'+core_version+'.jar 2>/dev/null >/dev/null')

    print green('Startup the core platform finished!')

# Restart the core platform via the startup.sh scripts function. 
Example #17
Source File: auto_deploy_app_v_final.py    From python-auto-deploy with MIT License 5 votes vote down vote up
def shutdown_auth():
    print green('Shutdown the auth platform via the stop.sh scripts.')

    ret = run("ps -ef|grep cmms-auth|grep -v grep|cut -c 9-15")

    if ret:
        with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
            run("ps -ef|grep cmms-auth|grep -v grep|cut -c 9-15|xargs kill -9 2>/dev/null >/dev/null")
    else:
        print red("No such progress!")

    print green('Shutdown the auth platform finished!')

# Startup the auth platform via the startup.sh scripts function. 
Example #18
Source File: auto_deploy_app_v_final.py    From python-auto-deploy with MIT License 5 votes vote down vote up
def startup_auth():
    print green('Startup the auth platform via the startup.sh scripts.')

    ret = run("ps -ef|grep cmms-auth|grep -v grep|cut -c 9-15")

    if ret:
        print red('Startup already!')
    else:
        with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
            run('cd '+auth_path+' && java -jar cmms-auth.jar 2>/dev/null >/dev/null')

    print green('Startup the authplatform finished!')

# Restart the auth platform via the startup.sh scripts function. 
Example #19
Source File: auto_deploy_app_remote.py    From python-auto-deploy with MIT License 5 votes vote down vote up
def startup_core():

    print green('Startup the core platform via the startup.sh scripts.')
    print 'Logs output to the '+log_path+'/startup_core.log'

    os.system('mkdir -p '+log_path+' 2>/dev/null >/dev/null')
    os.system("echo '' > "+log_path+"/startup_core.log")
    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" startup_core > "+log_path+"/startup_core.log & 2>/dev/null >/dev/null")

    print green('Startup the core platform finished!')

# Restart the core platform via the restart.sh scripts function. 
Example #20
Source File: auto_deploy_app_remote.py    From python-auto-deploy with MIT License 5 votes vote down vote up
def restart_api():

    print green('Restart the mall api via the remote_restart.sh scripts.')
    print 'Logs output to the '+log_path+'/restart_api.log'

    os.system('mkdir -p '+log_path+' 2>/dev/null >/dev/null')
    os.system("echo '' > "+log_path+"/restart_api.log")
    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" restart_api > "+log_path+"/restart_api.log 2>/dev/null >/dev/null")

    print green('Restart the mall api finished!')

# Deploy mall admin via ant function. 
Example #21
Source File: auto_deploy_app_remote.py    From python-auto-deploy with MIT License 5 votes vote down vote up
def shutdown_nginx():
    
    print green('Shutdown the shop via the nginx shutdown and startup scripts.')
    print 'Logs output to the '+log_path+'/shutdown_nginx.log'

    os.system('mkdir -p '+log_path+' 2>/dev/null >/dev/null')
    os.system("echo '' > "+log_path+"/shutdown_nginx.log")

    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" shutdown_nginx > "+log_path+"/shutdown_nginx.log 2>/dev/null >/dev/null")

    print green('Shutdown the shop finished!')

# Startup the shop via the nginx shutdown and startup scripts funtion. 
Example #22
Source File: auto_deploy_app_remote.py    From python-auto-deploy with MIT License 5 votes vote down vote up
def startup_api():

    print green('Startup the mall api via the startup.sh scripts.')
    print 'Logs output to the '+log_path+'/startup_api.log'

    os.system('mkdir -p '+log_path+' 2>/dev/null >/dev/null')
    os.system("echo '' > "+log_path+"/startup_api.log")
    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" startup_api > "+log_path+"/startup_api.log 2>/dev/null >/dev/null")

    print green('Startup the mall api finished!')

# Restart the mall api via the restart.sh scripts function. 
Example #23
Source File: auto_deploy_app_remote.py    From python-auto-deploy with MIT License 5 votes vote down vote up
def startup_auth():

    print green('Startup the auth platform via the startup.sh scripts.')
    print 'Logs output to the '+log_path+'/startup_auth.log'

    os.system('mkdir -p '+log_path+' 2>/dev/null >/dev/null')
    os.system("echo '' > "+log_path+"/startup_auth.log")

    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" startup_auth > "+log_path+"/startup_auth.log & 2>/dev/null >/dev/null")

    print green('Startup the authplatform finished!')

# Restart the auth platform via the restart.sh scripts function. 
Example #24
Source File: auto_deploy_app_remote.py    From python-auto-deploy with MIT License 5 votes vote down vote up
def restart_admin():

    print green('Restart the mall admin via the restart.sh scripts.')
    print 'Logs output to the '+log_path+'/restart_admin.log'

    os.system('mkdir -p '+log_path+' 2>/dev/null >/dev/null')
    os.system("echo '' > "+log_path+"/restart_admin.log")
    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" restart_admin > "+log_path+"/restart_admin.log 2>/dev/null >/dev/null")

    print green('Restart the mall admin finished!')

# Shutdown the mall api via the shutdown.sh scripts function. 
Example #25
Source File: auto_deploy_app_remote.py    From python-auto-deploy with MIT License 5 votes vote down vote up
def startup_admin():

    print green('Startup the admin via the startup.sh scripts.')
    print 'Logs output to the '+log_path+'/startup_admin.log'

    os.system('mkdir -p '+log_path+' 2>/dev/null >/dev/null')
    os.system("echo '' > "+log_path+"/startup_admin.log")
    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" startup_admin > "+log_path+"/startup_admin.log 2>/dev/null >/dev/null")

    print green('Startup the mall admin finished!')

# Restart the mall admin via the restart.sh scripts function. 
Example #26
Source File: auto_deploy_app_remote.py    From python-auto-deploy with MIT License 5 votes vote down vote up
def restart_auth():
    print green('Restart the core platform via the restart.sh scripts.')
    print 'Logs output to the '+log_path+'/restart_auth.log'

    os.system('mkdir -p '+log_path+' 2>/dev/null >/dev/null')
    os.system("echo '' > "+log_path+"/restart_auth.log")
    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" restart_auth> "+log_path+"/restart_auth.log & 2>/dev/null >/dev/null")

    print green('Restart the core platform finished!')

# Deploy core platform via mvn function. 
Example #27
Source File: auto_deploy_app_remote.py    From python-auto-deploy with MIT License 5 votes vote down vote up
def startup_api():

    print green('Startup the mall api via the startup.sh scripts.')
    print 'Logs output to the '+log_path+'/startup_api.log'

    os.system('mkdir -p '+log_path+' 2>/dev/null >/dev/null')
    os.system("echo '' > "+log_path+"/startup_api.log")
    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" startup_api > "+log_path+"/startup_api.log 2>/dev/null >/dev/null")

    print green('Startup the mall api finished!')

# Restart the mall api via the restart.sh scripts function. 
Example #28
Source File: auto_deploy_app_remote.py    From python-auto-deploy with MIT License 5 votes vote down vote up
def restart_admin():

    print green('Restart the mall admin via the restart.sh scripts.')
    print 'Logs output to the '+log_path+'/restart_admin.log'

    os.system('mkdir -p '+log_path+' 2>/dev/null >/dev/null')
    os.system("echo '' > "+log_path+"/restart_admin.log")
    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" restart_admin > "+log_path+"/restart_admin.log 2>/dev/null >/dev/null")

    print green('Restart the mall admin finished!')

# Shutdown the mall api via the shutdown.sh scripts function. 
Example #29
Source File: auto_deploy_app_remote.py    From python-auto-deploy with MIT License 5 votes vote down vote up
def startup_admin():

    print green('Startup the admin via the startup.sh scripts.')
    print 'Logs output to the '+log_path+'/startup_admin.log'

    os.system('mkdir -p '+log_path+' 2>/dev/null >/dev/null')
    os.system("echo '' > "+log_path+"/startup_admin.log")
    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" startup_admin > "+log_path+"/startup_admin.log 2>/dev/null >/dev/null")

    print green('Startup the mall admin finished!')

# Restart the mall admin via the restart.sh scripts function. 
Example #30
Source File: auto_deploy_app_remote.py    From python-auto-deploy with MIT License 5 votes vote down vote up
def startup_nginx():

    print green('Startup the shop via the nginx shutdown and startup scripts.')
    print 'Logs output to the '+log_path+'/startup_nginx.log'

    os.system('mkdir -p '+log_path+' 2>/dev/null >/dev/null')
    os.system("echo '' > "+log_path+"/startup_nginx.log")

    with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
        os.system("fab -f "+script_name+" startup_nginx > "+log_path+"/startup_nginx.log 2>/dev/null >/dev/null")

    print green('Startup the shop finished!')

# Restartup the shop via the nginx shutdown and startup scripts funtion.