get the default worker script
421593
function getDefaultWorker() {
  if (environment.platform == 'browser') {
    // test whether the browser supports all features that we need
    if (typeof Blob === 'undefined') {
      throw new Error('Blob not supported by the browser');
    }
    if (!window.URL || typeof window.URL.createObjectURL !== 'function') {
      throw new Error('URL.createObjectURL not supported by the browser');
    }

    // use embedded worker.js
    var blob = new Blob([require('./generated/embeddedWorker')], {type: 'text/javascript'});
    return window.URL.createObjectURL(blob);
  }
  else {
    // use external worker.js in current directory
    return __dirname + '/worker.js';
  }
}
874012
def get_script(script_name):
    '''
    '''
    install_dir = get_installdir()
    script_path = "%s/build/scripts/%s" %(install_dir,script_name)
    if os.path.exists(script_path):
        return script_path
    else:
        bot.error("Script %s is not included in singularity-python!" %script_path)
        return None
962449
def _WorkerCommand_executable(self):
        """"""
        worker = self.workersArguments

        c = []
        if worker.executable:
            c.append(worker.executable)
        # This trick is used to parse correctly quotes
        # (ie. myScript.py 'arg1 "arg2" arg3')
        # Because it is parsed by a shell, every quote gets re-interpreted.
        # It replaces simple quotation marks with \\\" which gets evaluated to
        # \" by the second shell which prints it out as a double quote.
        if worker.args:
            if self.isLocal():
                # If local, no shell is used so no escaping needed
                c.extend([
                    '{0}'.format(a) for a in worker.args
                ])
            else:
                c.extend([
                    '"{0}"'.format(a.replace('"', '\\\"')) for a in worker.args
                ])
        return c
610592
def main(event_loop=None):
    
    context, credentials = get_context_from_cmdln(sys.argv[1:])
    log.info("Scriptworker starting up at {} UTC".format(arrow.utcnow().format()))
    cleanup(context)
    context.event_loop = event_loop or asyncio.get_event_loop()

    done = False

    async def _handle_sigterm():
        log.info("SIGTERM received; shutting down")
        nonlocal done
        done = True
        if context.running_tasks is not None:
            await context.running_tasks.cancel()

    context.event_loop.add_signal_handler(signal.SIGTERM, lambda: asyncio.ensure_future(_handle_sigterm()))

    while not done:
        try:
            context.event_loop.run_until_complete(async_main(context, credentials))
        except Exception:
            log.critical("Fatal exception", exc_info=1)
            raise
2419
def _get_script_nflows(self):
        
        flows_torun = [f for f in self.flows if not f.all_ok]
        if not flows_torun:
            return "", 0

        executable = [
            'export _LOG=%s' % self.log_file.path,
            'date1=$(date +"%s")',
            'echo Running abirun.py in batch mode > ${_LOG}',
            " ",
        ]
        app = executable.append

        # Build list of abirun commands and save the name of the log files.
        self.sched_logs, num_flows = [], len(flows_torun)
        for i, flow in enumerate(flows_torun):

            logfile = os.path.join(self.workdir, "log_" + os.path.basename(flow.workdir))

            app("echo Starting flow %d/%d on: `date` >> ${LOG}" % (i+1, num_flows))
            app("\nabirun.py %s scheduler > %s" % (flow.workdir, logfile))
            app("echo Returning from abirun on `date` with retcode $? >> ${_LOG}")

            assert logfile not in self.sched_logs
            self.sched_logs.append(logfile)

        # Remove the batch pid_file and compute elapsed time.
        executable.extend([
            " ",
            "# Remove batch pid file",
            'rm %s' % self.batch_pidfile.path,
            " ",
            "# Compute elapsed time",
            'date2=$(date +"%s")',
            'diff=$(($date2-$date1))',
            'echo $(($diff / 60)) minutes and $(($diff % 60)) seconds elapsed. >> ${_LOG}'
        ])

        return self.qadapter.get_script_str(
            job_name=self.name,
            launch_dir=self.workdir,
            executable=executable,
            qout_path=self.qout_file.path,
            qerr_path=self.qerr_file.path,
        ), num_flows
766024
def get_default_config(self):
        
        config = super(cloudwatchHandler, self).get_default_config()

        config.update({
            'region': 'us-east-1',
            'collector': 'loadavg',
            'metric': '01',
            'namespace': 'MachineLoad',
            'name': 'Avg01',
            'unit': 'None',
            'collect_by_instance': True,
            'collect_without_dimension': False
        })

        return config
930684
def select_idle_worker(self, ctrl, shift):
    """"""
    action = sc_pb.Action()
    mod = sc_ui.ActionSelectIdleWorker
    if ctrl:
      select_worker = mod.AddAll if shift else mod.All
    else:
      select_worker = mod.Add if shift else mod.Set
    action.action_ui.select_idle_worker.type = select_worker
    return action
1134389
function workerBoilerScript() {

	var postMessage = self.postMessage;
	var structuredCloningSupport = null;
	var toString = {}.toString;

	self.console = {};
	self.isWorker = true;

	// Provide basic console interface:
	['log', 'debug', 'error', 'info', 'warn', 'time', 'timeEnd'].forEach(function(meth) {
		self.console[meth] = function() {
			postMessage({
				cmd: 'console',
				method: meth,
				args: [].slice.call(arguments)
			});
		};
	});

	self.addEventListener('message', function(e) {

		var data = e.data;

		if (typeof data == 'string' && data.indexOf('EVAL|') === 0) {
			eval(data.substring(5));
			return;
		}

		if (structuredCloningSupport == null) {

			// e.data of ['PING'] (An array) indicates structuredCloning support
			// e.data of '"PING"' (A string) indicates no support (Array has been serialized)
			structuredCloningSupport = e.data[0] === 'PING';

			// Pingback to parent page:
			self.postMessage(
				structuredCloningSupport ?
					'pingback:structuredCloningSupport=YES' :
					'pingback:structuredCloningSupport=NO'
			);

			if (!structuredCloningSupport) {
				postMessage = function(msg) {
					// Marshal before sending
					return self.postMessage(JSON.stringify(msg));
				};
			}

			return;
		}

		if (!structuredCloningSupport) {
			// Demarshal:
			data = JSON.parse(data);
		}

		var defs = data.definitions;
		var isDeferred = false;
		var args = data.args;

		if (defs) {
			// Initial definitions:
			for (var i in defs) {
				self[i] = defs[i];
			}
			return;
		}

		function callback() {
			// Callback function to be passed to operative method
			returnResult({
				args: [].slice.call(arguments)
			});
		}

		callback.transfer = function() {
			var args = [].slice.call(arguments);
			var transfers = extractTransfers(args);
			// Callback function to be passed to operative method
			returnResult({
				args: args
			}, transfers);
		};

		args.push(callback);

		self.deferred = function() {
			isDeferred = true;
			var def = {};
			function resolve(r, transfers) {
				returnResult({
					isDeferred: true,
					action: 'resolve',
					args: [r]
				}, transfers);
				return def;
			}
			function reject(r, transfers) {
				if (r instanceof Error) {
					// Create an error object that can be cloned: (See #44/#45):
					var cloneableError = {
						message: r.message,
						stack: r.stack,
						name: r.name,
						code: r.code
					};
					for (var i in r) {
						if (r.hasOwnProperty(i)) {
							cloneableError[i] = r[i];
						}
					}
					postMessage({
						cmd: 'deferred_reject_error',
						token: data.token,
						error: cloneableError
					});
					return;
				}
				returnResult({
					isDeferred: true,
					action: 'reject',
					args: [r]
				}, transfers);
			}
			// Deprecated:
			def.fulfil = def.fulfill = def.resolve = function(value) {
				return resolve(value);
			};
			def.reject = function(value) {
				return reject(value);
			};
			def.transferResolve = function(value) {
				var transfers = extractTransfers(arguments);
				return resolve(value, transfers);
			};
			def.transferReject = function(value) {
				var transfers = extractTransfers(arguments);
				return reject(value, transfers);
			};
			return def;
		};

		// Call actual operative method:
		var result = self[data.method].apply(self, args);

		if (!isDeferred && result !== void 0) {
			// Deprecated direct-returning as of 0.2.0
			returnResult({
				args: [result]
			});
		}

		self.deferred = function() {
			throw new Error('Operative: deferred() called at odd time');
		};

		function returnResult(res, transfers) {
			postMessage({
				cmd: 'result',
				token: data.token,
				result: res
			}, self.hasTransferSupport && transfers || []);
		}

		function extractTransfers(args) {
			var transfers = args[args.length - 1];

			if (toString.call(transfers) !== '[object Array]') {
				throw new Error('Operative: callback.transfer() must be passed an Array of transfers as its last arguments');
			}

			return transfers;
		}
	});
}
779515
def script_start_type(script):
        """"""
        if script[0].type.text == 'when @greenFlag clicked':
            return HairballPlugin.HAT_GREEN_FLAG
        elif script[0].type.text == 'when I receive %s':
            return HairballPlugin.HAT_WHEN_I_RECEIVE
        elif script[0].type.text == 'when this sprite clicked':
            return HairballPlugin.HAT_MOUSE
        elif script[0].type.text == 'when %s key pressed':
            return HairballPlugin.HAT_KEY
        else:
            return HairballPlugin.NO_HAT
354605
function getScripts({ specialMark, defaultObjectId } = {}){

  const packageFilename = path.join(process.cwd(), 'package.json');

  defaultObjectId = defaultObjectId || '__default__';

  specialMark = specialMark || '--';
  specialMark = specialMark.replace(/[[]().*^$]/g, '\\$1');
  const specialEchoRegexp = new RegExp('^echo ' + specialMark + '(.*?)' + specialMark);

  // M.b. error thrown...
  const project = require(packageFilename) || {};

  // Data from `npm-package-user-scripts` section
  const userScriptsData = project['npm-package-user-scripts'] || {};

  // Default object properties
  const userScriptsDefaultObject = userScriptsData[defaultObjectId] || {};

  // Data from `scripts` section
  const scriptsData = project['scripts'] || {};

  const scriptCommands = Object.keys(scriptsData)
    .filter((id) => !id.endsWith('UNUSED') && !id.endsWith('SAMPLE'))
    .reduce((scriptCommands, id) => {
      // Default object: from `npm-package-user-scripts` section or empty object
      const obj = userScriptsData[id] || {};
      // Command from `scripts` section (required!)
      const cmd = obj.cmd || scriptsData[id];
      // Match for special `echo --*--`
      const reg = cmd && cmd.match(specialEchoRegexp);
      // Title form special echo or default object
      const title = (reg && reg[1]) ? reg[1]: obj.title;
      // Title exists?
      if (title && cmd) {
        // ...then append to resulting object
        scriptCommands[id] = Object.assign({}, userScriptsDefaultObject, obj, { title, cmd });
      }
      return scriptCommands;
    }, {})
  ;

  return scriptCommands;

}
946296
def default_subprocess_runner(cmd, cwd=None, extra_environ=None):
    """"""
    env = os.environ.copy()
    if extra_environ:
        env.update(extra_environ)

    check_call(cmd, cwd=cwd, env=env)
1299858
def create_process_worker(self, cmd_list, environ=None):
        """"""
        worker = ProcessWorker(cmd_list, environ=environ)
        self._create_worker(worker)
        return worker
928982
def worker(data):
    """"""
    creator = get_creator_by_name(data['creator'])
    shell = creator(data['entry'],
                    ShellConfig(script=data['entry']['script'],
                                title=data['entry']['title'] if 'title' in data['entry'] else '',
                                model=data['model'], env=data['env'], item=data['item'],
                                dry_run=data['dry_run'], debug=data['debug'], strict=data['strict'],
                                variables=data['variables'],
                                temporary_scripts_path=data['temporary_scripts_path']))
    output = []
    for line in shell.process():
        output.append(line)
        Logger.get_logger(__name__ + '.worker').info(" | %s", line)
    return {'id': data['id'], 'success': shell.success, 'output': output}
241644
def get_default_config(self):
        
        config = super(StatsiteHandler, self).get_default_config()

        config.update({
            'host': '',
            'tcpport': 1234,
            'udpport': 1234,
            'timeout': 5,
        })

        return config
1151754
def getworker():
        '''
        
        '''
        if not Configuration.worker_initialized:
            Configuration._initconf()
            Configuration.worker_settings = Configuration.settings['worker']
            Configuration.worker_initialized = True
        return Configuration.worker_settings
189907
def get_default_config(self):
        
        config = super(NullHandler, self).get_default_config()

        config.update({
        })

        return config
300935
def get_default_config(self):
        
        config = super(PostqueueCollector, self).get_default_config()
        config.update({
            'path':             'postqueue',
            'bin':              '/usr/bin/postqueue',
            'use_sudo':         False,
            'sudo_cmd':         '/usr/bin/sudo',
        })
        return config