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
示例#2
0
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)
示例#3
0
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')
示例#4
0
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))
示例#5
0
 def run_bash(self, cmd):
     run_params = [
         "run", "--rm", "--entrypoint", "bash", self.docker_image, "-c", cmd
     ]
     return Process.run("docker", run_params)
示例#6
0
 def process_run(executable, params=None, cwd='.'):
     return Process.run(executable,params, cwd)
示例#7
0
def an_method(params):
    return Process.run('echo', [params])
示例#8
0
def list_notebooks():
    return Process.run('find', ["-type", "f", "-name", "*.ipynb"],
                       cwd='../../..').get('stdout').split('\n')