def put(local_path, remote_path, use_sudo=False): use_sudo = parse_bool(use_sudo) if dconf.HOST_CONN == 'remote': res = _put(local_path, remote_path, use_sudo=use_sudo) elif dconf.HOST_CONN == 'local': pre_cmd = 'sudo ' if use_sudo else '' opts = '-r' if os.path.isdir(local_path) else '' res = local('{}cp {} {} {}'.format(pre_cmd, opts, local_path, remote_path)) else: # docker or remote_docker docker_cmd = 'docker cp -L {} {}:{}'.format(local_path, dconf.CONTAINER_NAME, remote_path) if dconf.HOST_CONN == 'docker': if dconf.DB_CONF_MOUNT is True: pre_cmd = 'sudo ' if use_sudo else '' opts = '-r' if os.path.isdir(local_path) else '' res = local('{}cp {} {} {}'.format(pre_cmd, opts, local_path, remote_path)) else: res = local(docker_cmd) elif dconf.HOST_CONN == 'remote_docker': if dconf.DB_CONF_MOUNT is True: res = _put(local_path, remote_path, use_sudo=use_sudo) else: res = _put(local_path, local_path, use_sudo=True) res = sudo(docker_cmd, remote_only=True) else: raise Exception('wrong HOST_CONN type {}'.format(dconf.HOST_CONN)) return res
def put(**kwargs): local_path = kwargs['local_path'] fd, fn = tempfile.mkstemp() if not env.is_local: os.remove(fn) #kwargs['remote_path'] = kwargs.get('remote_path', '/tmp/%s' % os.path.split(local_path)[-1]) kwargs['remote_path'] = kwargs.get('remote_path', fn) env.put_remote_path = kwargs['remote_path'] return _put(**kwargs)
def put(local_path, remote_path, use_sudo=False): use_sudo = parse_bool(use_sudo) if dconf.HOST_CONN == 'remote': res = _put(local_path, remote_path, use_sudo=use_sudo) elif dconf.HOST_CONN == 'local': pre_cmd = 'sudo ' if use_sudo else '' opts = '-r' if os.path.isdir(local_path) else '' res = local('{}cp {} {} {}'.format(pre_cmd, opts, local_path, remote_path)) else: # docker res = local('docker cp {} {}:{}'.format(local_path, dconf.CONTAINER_NAME, remote_path)) return res
def supervisor(): _put('config/supervisor.conf', '/etc/supervisor/conf.d/browser.conf')
def put(*args, **kwargs): with _ctx.unpatched_state(): return _put(*args, **kwargs)