Returns a fabric task which executes the script in the Vagrant VM
428231
def fabric_task(self):
        
        from fabric import api

        @api.task
        def run_script(container_name, definition_filename, image_name, image_tag, repository, timeout):
            """ Sequence to run inside the VM.
                Starts up the container if the container is not running
                (and copies over the data and the runner script)
                Then the definition is copied over and the script launched.
                If the VM is gonna be shut down then kills the container as well.
            """
            workdir = str((Path("/srv/data") / self.cwd).resolve())
            cmd = "sh" if self.inherit_image else "bash"

            api.run(f"docker pull {image_name}:{image_tag}")

            container_running = int(api.run(f"docker ps --format '{{.Names}}' -f name={container_name} | wc -l"))
            container_stopped = int(api.run(f"docker ps -a --format '{{.Names}}' -f name={container_name} | wc -l"))

            if container_running == 0:
                if container_stopped:
                    api.run(f"docker rm -f {container_name}")

                api.run(f"docker run "
                        f"--name {container_name} "
                        f"--workdir \"{workdir}\" "
                        f"-dt {image_name}:{image_tag} "
                        f"{cmd} -i")

                api.run(f"docker exec {container_name} mkdir -p /srv/scripts")
                api.run(f"docker cp /srv/repos/{repository} {container_name}:/srv/branch")
                api.run(f"docker exec --user root {container_name} bash -c 'mv /srv/branch/* /srv/data'")
                api.run(f"docker exec --user root {container_name} rm -rf /srv/branch")
                api.run(f"docker cp /vagrant/runner.py {container_name}:/srv/scripts/")

            api.run(f"docker cp /vagrant/{definition_filename} {container_name}:/srv/scripts/")

            output = api.run(
                " ".join([
                    "docker", "exec", container_name,
                    "python", "/srv/scripts/runner.py", f"/srv/scripts/{definition_filename}",
                ]),
                timeout=math.ceil(timeout)
            )

            if not self.keep_container_running:
                api.run(f"docker kill {container_name}")

            return output

        return run_script
261319
function _client_compile_task(file) {

    var infile = amigo_js_dev_path + '/' +file;
    //var outfile = amigo_js_out_path + '/' +file;

    var b = browserify(infile);
    return b
    // not in npm, don't need in browser
	.exclude('ringo/httpclient')
	.bundle()
    // desired output filename to vinyl-source-stream
	.pipe(source(file))
	.pipe(gulp.dest(amigo_js_out_path));
}
1324224
def execute_script(self, name, keys, *args, **options):
        '''
        '''
        script = get_script(name)
        if not script:
            raise redis.RedisError('No such script "%s"' % name)
        address = self.address()
        if address not in all_loaded_scripts:
            all_loaded_scripts[address] = set()
        loaded = all_loaded_scripts[address]
        toload = script.required_scripts.difference(loaded)
        for name in toload:
            s = get_script(name)
            yield self.script_load(s.script)
        loaded.update(toload)
        yield script(self, keys, args, options)
1368083
def execute_prebuild_script(self):
        

        (pb_mod_path, pb_func) = self.prebuild_script.rsplit('.', 1)

        try:  # Prefer prebuild script in working directory
            if pb_mod_path.count('.') >= 1:  # Prebuild script func is nested in a folder
                (mod_folder_path, mod_name) = pb_mod_path.rsplit('.', 1)
                mod_folder_path_fragments = mod_folder_path.split('.')
                working_dir = os.path.join(os.getcwd(), *mod_folder_path_fragments)
            else:
                mod_name = pb_mod_path
                working_dir = os.getcwd()

            working_dir_importer = pkgutil.get_importer(working_dir)
            module_ = working_dir_importer.find_module(mod_name).load_module(mod_name)

        except (ImportError, AttributeError):

            try:  # Prebuild func might be in virtualenv
                module_ = importlib.import_module(pb_mod_path)
            except ImportError:  # pragma: no cover
                raise ClickException(click.style("Failed ", fg="red") + 'to ' + click.style(
                    "import prebuild script ", bold=True) + 'module: "{pb_mod_path}"'.format(
                    pb_mod_path=click.style(pb_mod_path, bold=True)))

        if not hasattr(module_, pb_func):  # pragma: no cover
            raise ClickException(click.style("Failed ", fg="red") + 'to ' + click.style(
                "find prebuild script ", bold=True) + 'function: "{pb_func}" '.format(
                pb_func=click.style(pb_func, bold=True)) + 'in module "{pb_mod_path}"'.format(
                pb_mod_path=pb_mod_path))

        prebuild_function = getattr(module_, pb_func)
        prebuild_function()
806711
function client (root) {
	return {

		tasks: {

			// Create a new task
			create: function (task, done) {
				post(root + 'tasks', task, done);
			},

			// Get all tasks
			get: function (query, done) {
				get(root + 'tasks', query, done);
			},

			// Get results for all tasks
			results: function (query, done) {
				get(root + 'tasks/results', query, done);
			}

		},

		task: function (id) {
			return {

				// Get a task
				get: function (query, done) {
					get(root + 'tasks/' + id, query, done);
				},

				// Edit a task
				edit: function (edits, done) {
					patch(root + 'tasks/' + id, edits, done);
				},

				// Remove a task
				remove: function (done) {
					del(root + 'tasks/' + id, null, done);
				},

				// Run a task
				run: function (done) {
					post(root + 'tasks/' + id + '/run', null, done);
				},

				// Get results for a task
				results: function (query, done) {
					get(root + 'tasks/' + id + '/results', query, done);
				},

				result: function (rid) {
					return {

						// Get a result
						get: function (query, done) {
							get(root + 'tasks/' + id + '/results/' + rid, query, done);
						}

					};
				}

			};
		}

	};
}
477904
def execute(args):
    
    task_family = None
    error = None

    # try to infer the task module from the passed task family and import it
    parts = args.task_family.rsplit(".", 1)
    if len(parts) == 2:
        modid, cls_name = parts
        try:
            mod = __import__(modid, globals(), locals(), [cls_name])
            if hasattr(mod, cls_name):
                task_cls = getattr(mod, cls_name)
                if not issubclass(task_cls, Task):
                    abort("object '{}' is not a Task".format(args.task_family))
                task_family = task_cls.task_family
        except ImportError as e:
            logger.warning("import error in module {}: {}".format(modid, e))
            error = e

    # read task info from the index file and import it
    if task_family is None:
        index_file = Config.instance().get_expanded("core", "index_file")
        if os.path.exists(index_file):
            info = read_task_from_index(args.task_family, index_file)
            if not info:
                abort("task family '{}' not found in index".format(args.task_family))
            modid, task_family, _ = info
            __import__(modid, globals(), locals())

    # complain when no task could be found
    if task_family is None:
        if error:
            raise error
        else:
            abort("task '{}' not found".format(args.task_family))

    # import the module and run luigi
    luigi_run([task_family] + sys.argv[3:])
318836
function task(app, name, pattern) {
  app.task(name, function() {
    return app.src(pattern, {cwd: __dirname})
      .pipe(app.renderFile('*'))
      .pipe(app.conflicts(app.cwd))
      .pipe(app.dest(app.cwd));
  });
}
164771
def invoke(tasks)
      remote_shell do |shell|
        # setup the deployment repository
        invoke_task(:setup,shell) if tasks.include?(:setup)

        # cd into the deployment repository
        shell.cd(shell.uri.path)

        # update the deployment repository
        invoke_task(:update,shell) if tasks.include?(:update)

        # framework tasks
        invoke_task(:install,shell) if tasks.include?(:install)
        invoke_task(:migrate,shell) if tasks.include?(:migrate)

        # server tasks
        if tasks.include?(:config)
          invoke_task(:config,shell)
        elsif tasks.include?(:start)
          invoke_task(:start,shell)
        elsif tasks.include?(:stop)
          invoke_task(:stop,shell)
        elsif tasks.include?(:restart)
          invoke_task(:restart,shell)
        end
      end

      return true
    end
801560
def exec_task(task_path, data):
    
    if not data:
        data = {'data': None, 'path': task_path}

    elif not isinstance(data, (str, bytes)):
        data = {'data': json.dumps(data, cls=RequestJSONEncoder),
                'path': task_path}

    else:
        # Open the data from file, if necessary.
        if data is not None and data.startswith("file://"):
            with open(data[len("file://"):]) as f:
                data = f.read()

        data = {'data': data, 'path': task_path}

    # Prepare the task.
    job = Job(data)
    (task, task_callable) = create_task(task_path)

    with delegating_job_context(job, task, task_callable) as jc:
        return jc.task_callable(jc.task_data)
411876
def ssh_to_task(task) -> paramiko.SSHClient:
  

  username = task.ssh_username
  hostname = task.public_ip
  ssh_key_fn = get_keypair_fn()
  print(f"ssh -i {ssh_key_fn} {username}@{hostname}")
  pkey = paramiko.RSAKey.from_private_key_file(ssh_key_fn)

  ssh_client = paramiko.SSHClient()
  ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  assert ssh_client

  counter = 1
  while True:
    try:
      ssh_client.connect(hostname=hostname, username=username, pkey=pkey)
      if counter % 11 == 0:  # occasionally re-obtain public ip, machine could've gotten restarted
        hostname = task.public_ip
      break
    except Exception as e:
      print(
        f'{task.name}: Exception connecting to {hostname} via ssh (could be a timeout): {e}')
      time.sleep(RETRY_INTERVAL_SEC)

  return ssh_client
490287
def provision(self, vm_name=None, provision_with=None):
        '''
        
        '''
        prov_with_arg = None if provision_with is None else '--provision-with'
        providers_arg = None if provision_with is None else ','.join(provision_with)
        self._call_vagrant_command(['provision', vm_name, prov_with_arg,
                                   providers_arg])
239793
def batch(parallel=true)
      parallel = false if ENV["VAGRANT_NO_PARALLEL"]

      @batch_lock.synchronize do
        BatchAction.new(parallel).tap do |b|
          # Yield it so that the caller can setup actions
          yield b

          # And run it!
          b.run
        end
      end
    end
1014348
def make_task(name='',
              run_name='',
              **kwargs) -> Task:
  """"""
  ncluster_globals.task_launched = True

  name = ncluster_globals.auto_assign_task_name_if_needed(name)

  # tmux can't use . for session names
  tmux_session = name.replace('.', '=')
  tmux_window_id = 0
  util.log(f'killing session {tmux_session}')

  if not util.is_set("NCLUSTER_NOKILL_TMUX"):
    os.system(f'tmux kill-session -t {tmux_session}')
  os.system(f'tmux new-session -s {tmux_session} -n {tmux_window_id} -d')

  task = Task(name,
              tmux_session=tmux_session,  # propagate optional args
              run_name=run_name,
              **kwargs)
  ncluster_globals.register_task(task, run_name)
  return task
237776
def write(self, cmd_args):
	
		
		
		args = [
			"vagrant"
		]
		args.extend(cmd_args)
		subprocess.call(args)
161238
function loadScript(src) {
    src = path.normalize(src);
    var contents = fs.readFileSync(src, 'utf8');
    vm.runInContext(contents, closure, src);
  }
1248825
def _run_configure_script(self, script):
        

        _, tmpFile = tempfile.mkstemp()
        with open(tmpFile, 'w') as f:
            f.write(script)

        try:
            # get ssh client
            ssh = self._get_ssh_client(
                self.host,
                "ubuntu",
                self.private_key_path,
            )

            # copy the local copy of the script to the remote machine
            sftp = paramiko.SFTPClient.from_transport(ssh.get_transport())
            sftp.put(
                tmpFile,
                tmpFile,
            )

            # run the provisioning script
            stdout, stderr = self._run_command(
                ssh,
                "sudo /bin/bash {}".format(tmpFile),
            )

        except paramiko.ssh_exception.AuthenticationException as e:
            raise e
        finally:
            os.remove(tmpFile)
            ssh.close()
190420
def execute(call, out_file, prefix: ' ')
      rakefile = call.path
      
      profile = *call.profile.map(&:to_s)

      if Grably.export_path
        data = [ rakefile, out_file, { 'target' => call.task, 'profile' => profile, 'params' => params } ]
        puts "remote_grably_request:#{JSON.generate(data)}"
        $stdout.flush
        $stdin.each do |l|
          raise "error in remote (slave) grably" unless l.strip == 'remote_grab_finished'
          break
        end
      else
        key = { rakefile: rakefile, profile: profile }
        
        process = @child_processes[key]
        
        unless process
          env = { 'config' => nil }
          cmd = [
            RbConfig.ruby,
            File.expand_path(File.join(__dir__, 'runner.rb')),
            '-f',
            File.basename(rakefile),
            "mp=#{profile.join(',')}"
          ]
          cmd << "--trace" if Rake.application.options.trace
          
          stdin, stdout, thread = Open3.popen2(*[env, cmd, { :err => [ :child, :out], :chdir => File.dirname(rakefile) }].flatten)
          stdout.sync = true
          stdin.sync = true
          
          process = { stdin: stdin, stdout: stdout, thread: thread }
          @child_processes[key] = process
        end
        
        process[:stdin].puts("build|#{out_file}|#{[call.task].flatten.join('|')}")
        
        ok = false
        process[:stdout].each do |l|
          ls = l.strip
          if ls == 'remote_grab_finished'
            ok = true
            break
          end
          
          if ls.start_with?('remote_grab_request:')
            data = JSON.parse(ls['remote_grab_request:'.size..-1])
            execute(data[0], data[1], "#{prefix}  ", { target: data[2]['target'], profile: data[2]['profile'], params: data[2]['params']})
            process[:stdin].puts('remote_grab_finished')
          else
            log_msg "#{prefix}#{l}"
          end
        end
        
        raise 'error in remote grab' unless ok
      end
    end