def lambda_status(team_id, channel, params): text = "Here are the current status of the `graph` lambda function" attachments = [{ 'title': 'Processes', 'text': Process.run("ps", ["-A"]).get('stdout') }, { 'title': 'Temp Files', 'text': Process.run("ls", ["-ls", '/tmp']).get('stdout') }] return text, attachments
def pip_install_dependency(target): path_lambda_dependencies = Files.path_combine('.', '../../../_lambda_dependencies/') folder_create(path_lambda_dependencies) path_install = Files.path_combine(path_lambda_dependencies, target) if folder_not_exists(path_install): return Process.run('pip3', ['install','-t',path_install,target]) return folder_exists(path_install)
def run(event, context): port = event.get('port') count = event.get('count') if port and count: for i in range(0, count): subprocess.Popen( ["python", "-m", "http.server", str(port + i), "&"], cwd='/tmp') return Process.run('ps', ['-aux']).get('stdout')
def hook(os_path, model, contents_manager): git_dir = os.environ.get('CODEBUILD_SRC_DIR') if git_dir is None: git_dir = '/home/jovyan/work' Process.run('git', cwd=git_dir, params=['add', '-A']) git_status = Process.run('git', cwd=git_dir, params=['status']).get('stdout') Process.run('git', cwd=git_dir, params=['commit', '-m', 'auto saved (changes in notebook)']) Process.run('git', cwd=git_dir, params=['pull', '--no-edit', 'origin', 'master']) git_result = Process.run('git', cwd=git_dir, params=['push', 'origin', 'master']).get('stderr') if 'rejected' in git_result: log_message( ':red_circle: on `{0}`, saved to git\n```{1}```\n{2}'.format( os.environ['repo_name'], git_status, git_result))
def run_bash(self, cmd): run_params = [ "run", "--rm", "--entrypoint", "bash", self.docker_image, "-c", cmd ] return Process.run("docker", run_params)
def process_run(executable, params=None, cwd='.'): return Process.run(executable,params, cwd)
def an_method(params): return Process.run('echo', [params])
def list_notebooks(): return Process.run('find', ["-type", "f", "-name", "*.ipynb"], cwd='../../..').get('stdout').split('\n')