Create bower command line string
969747
def _construct_bower_command(bower_command):
    '''
    
    '''
    if not bower_command:
        raise CommandExecutionError(
            'bower_command, e.g. install, must be specified')

    cmd = ['bower'] + shlex.split(bower_command)
    cmd.extend(['--config.analytics', 'false',
                '--config.interactive', 'false',
                '--allow-root', '--json'])
    return cmd
1189458
def _make_line(self, uid, command=None):
        
        if command:
            return ":".join(("HRLD", command, uid))
        else:
            return ":".join(("HRLD", uid))
835629
def create_git_command(cmd, opts, redirect)
      opts = [opts].flatten.map { |s| escape(s) }.join(' ')
      return "git #{cmd} #{opts} #{redirect} 2>&1"
    end
85302
def make_parser():
    

    parser = argparse.ArgumentParser(description='BERNARD CLI utility')
    sp = parser.add_subparsers(help='Sub-command')

    parser_run = sp.add_parser('run', help='Run the BERNARD server')
    parser_run.set_defaults(action='run')

    parser_sheet = sp.add_parser('sheet', help='Import files from Google '
                                               'Sheets')
    parser_sheet.set_defaults(action='sheet')
    parser_sheet.add_argument(
        '--auth_host_name',
        default='localhost',
        help='Hostname when running a local web server.'
    )
    parser_sheet.add_argument(
        '--noauth_local_webserver',
        action='store_true',
        default=False,
        help='Do not run a local web server.'
    )
    parser_sheet.add_argument(
        '--auth_host_port',
        default=[8080, 8090],
        type=int,
        nargs='*',
        help='Port web server should listen on.'
    )
    parser_sheet.add_argument(
        '--logging_level',
        default='ERROR',
        choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'],
        help='Set the logging level of detail.'
    )

    parser_sp = sp.add_parser('start_project', help='Starts a project')
    parser_sp.set_defaults(action='start_project')
    parser_sp.add_argument(
        'project_name',
        help='A snake-case name for your project'
    )
    parser_sp.add_argument(
        'dir',
        help='Directory to store the project'
    )

    return parser
525749
function(options, opt_fileList, opt_dirList) {

  var cmd = '';

  // Detect if the tool file is a python script. If so we need to
  // prefix the exec command with 'python'.
  if (stringEndsWith(options.toolFile, '.py')) {
    cmd += 'python ';
  }

  // Normalize the folder path and join the tool file.
  cmd += path.join(path.resolve(options.closureLinterPath), options.toolFile) + ' ';

  // Set command flags
  cmd += (options.strict) ? '--strict ' : '';
  cmd += (options.maxLineLength) ? '--max_line_length ' + options.maxLineLength + ' ' : '';

  // Finally add files to be linted
  if (opt_dirList && opt_dirList.length > 0) {
    cmd += opt_dirList.map(function(value) {return '-r ' + value;}).join(' ') + ' ';
  }

  if (opt_fileList && opt_fileList.length > 0) {
    cmd += opt_fileList.join(' ');
  }

  return cmd;
}
1122854
function registerBower(pck) {
	var pd = pck.commit.versionPkg({
		replacer : pck.options.pkgJsonReplacer,
		space : pck.options.pkgJsonSpace,
		readOnly : true
	});
	if (!pd || !pd.pkgBower) {
		rbot.log.info('Skipping bower registration check (no bower package found)');
		return pck.rollCall.then(npmPub);
	}
	var path = pd.pkgBower.path;
	var name = pd.pkgBower.name;
	var ver = pd.pkgBower.ver;
	var url = pd.pkgBower.repository && pd.pkgBower.repository.url ? pd.pkgBower.repository.url : '';
	if (!name || !url) {
		rbot.log.info('Skipping bower registration check '
				+ (name || ver || url ? 'for "' + (name ? ':name:' + name : ':NO name:')
						+ (ver ? ':version:' + ver : ':NO version:') + (url ? ':url:' + url : ':NO repository.url:')
						+ '" ' : '') + (!path ? '("' + path + '" cannot be read)' : 'in: ' + path));
		return pck.rollCall.then(npmPub);
	}
	var bower = null;
	try {
		bower = require('bower');
	} catch (e) {
		rbot.log.info('Skipping bower registration (bower module not found)', e);
		return pck.rollCall.then(npmPub);
	}
	pck.rollCall.pause(function bowerLookup() {
		bower.commands.lookup(name).on('error', function(e) {
			pck.rollCall.error('bower lookup failed', e).resume();
		}).on('end', bowerLookupEnd);
	});
	function bowerLookupEnd(data) {
		if (data) {
			if (data.url !== url) {
				pck.rollCall.error(
						'bower lookup found "' + name + '", but the repository.url found "' + data.url
								+ '" does not match the expected "' + path + '" repository.url "' + url + '"').resume();
			} else {
				rbot.log.verbose('found existing bower package for "' + name + '" at "' + data.url
						+ '"... no need to perform bower register');
			}
		} else {
			rbot.log.info('registering bower package "' + name + '"');
			pck.rollCall.pause(function bowerReg() {
				bower.commands.lookup(name, url).on('error', function(e) {
					pck.rollCall.error('bower registration failed', e).resume();
				}).on('end', bowerRegEnd);
			});
		}
	}
	function bowerRegEnd(data) {
		if (data) {
			rbot.log.info('bower registration complete');
			rbot.log.dir(data);
			pck.rollCall.then(npmPub).resume();
		} else {
			pck.rollCall.error('bower registration failed (no data received)').resume();
		}
	}
	function npmPub() {
		publishNpm(pck);
	}
}
341940
function createVirtualLessFileFromBowerJson(bowerJsonPath) {
  return new PromiseConstructor(function(fullfill, reject) {
    bowerJson.read(bowerJsonPath, { validate: false }, function(err, bowerJsonData) {
      if (err) {
        return reject(err);
      }
      if (!bowerJsonData.main) {
        err = bowerJsonPath + ' has no "main" property.';
        return reject(new Error(err));
      }

      // convert bower json into less file
      var virtualLessFile = bowerJsonData.main.filter(function(filename) {
        return path.extname(filename) === '.less';
      }).map(function(filename) {
        return '@import "' + filename + '";';
      }).join('\n');

      if (virtualLessFile) {
        var file = {
          contents: virtualLessFile,
          filename: bowerJsonPath
        };
        return fullfill(file);
      } else {
        err = 'Couldn\'t find a less file in ' + bowerJsonPath + '.';
        return reject(new Error(err));
      }
    });
  });
}
592915
def _bowtie_args_from_config(data):
    
    config = data['config']
    qual_format = config["algorithm"].get("quality_format", "")
    if qual_format.lower() == "illumina":
        qual_flags = ["--phred64-quals"]
    else:
        qual_flags = []
    multi_mappers = config["algorithm"].get("multiple_mappers", True)
    multi_flags = ["-M", 1] if multi_mappers else ["-m", 1]
    multi_flags = [] if data["analysis"].lower().startswith("smallrna-seq") else multi_flags
    cores = config.get("resources", {}).get("bowtie", {}).get("cores", None)
    num_cores = config["algorithm"].get("num_cores", 1)
    core_flags = ["-p", str(num_cores)] if num_cores > 1 else []
    return core_flags + qual_flags + multi_flags
345604
def make_argparser():
    
    parser = argparse.ArgumentParser(prog='mypolr',
                                     description="Interacts with the Polr Project's API.\n\n"
                                                 "User Guide and documentation: https://mypolr.readthedocs.io",
                                     formatter_class=argparse.ArgumentDefaultsHelpFormatter,
                                     epilog="NOTE: if configurations are saved, they are stored as plain text on disk, "
                                            "and can be read by anyone with access to the file.")
    parser.add_argument("-v", "--version", action="store_true", help="Print version and exit.")

    parser.add_argument("url", nargs='?', default=None, help="The url to process.")

    api_group = parser.add_argument_group('API server arguments',
                                          'Use these for configure the API. Can be stored locally with --save.')

    api_group.add_argument("-s", "--server", default=None, help="Server hosting the API.")
    api_group.add_argument("-k", "--key", default=None, help="API_KEY to authenticate against server.")
    api_group.add_argument("--api-root", default=DEFAULT_API_ROOT,
                           help="API endpoint root.")

    option_group = parser.add_argument_group('Action options',
                                             'Configure the API action to use.')

    option_group.add_argument("-c", "--custom", default=None,
                              help="Custom short url ending.")
    option_group.add_argument("--secret", action="store_true",
                              help="Set option if using secret url.")
    option_group.add_argument("-l", "--lookup", action="store_true",
                              help="Perform lookup action instead of shorten action.")

    manage_group = parser.add_argument_group('Manage credentials',
                                             'Use these to save, delete or update SERVER, KEY and/or '
                                             'API_ROOT locally in ~/.mypolr/config.ini.')

    manage_group.add_argument("--save", action="store_true",
                              help="Save configuration (including credentials) in plaintext(!).")
    manage_group.add_argument("--clear", action="store_true",
                              help="Clear configuration.")
    return parser
1100651
function createBanner() {
  var today = gutil.date(new Date(), 'yyyy-mm-dd'); // today, formatted as yyyy-mm-dd
  var version = require('./package.json').version;

  return String(fs.readFileSync(HEADER))
      .replace('@@date', today)
      .replace('@@version', version);
}
1251938
function resolve(name, workdir) {
	workdir = workdir || process.cwd();
	var compName = componentName(name),
		subname = name.substring(compName.length + 1),
		basedir = path.join(componentsHome(workdir), compName),
		bowerJson = require(path.join(basedir, 'bower.json'));

	var mainfile = Array.isArray(bowerJson.main) 
		? bowerJson.main.filter(function(file) { return /\.js$/.test(file); })[0] 
		: bowerJson.main;

	if (subname && subname.length > 0) {
		var subpath = mainfile && path.join(basedir, mainfile, '..', subname);
		if (subpath && (fs.existsSync(subpath) || fs.existsSync(subpath + '.js'))) {
			return path.join(basedir, mainfile, '..', subname);
		} else {
			return path.join(basedir, subname);
		}
	} else {
		if (mainfile) {
			return path.join(basedir, mainfile);
		}	else {
			if (fs.existsSync(path.join(basedir, "index.js"))) {
				return path.join(basedir, "index.js");
			} else {
				return path.join(basedir, compName);
			}
		}
	}
}
1052468
def __create_header(self, command, command_string, session_id, reply_id):
        
        buf = pack('<4H', command, 0, session_id, reply_id) + command_string
        buf = unpack('8B' + '%sB' % len(command_string), buf)
        checksum = unpack('H', self.__create_checksum(buf))[0]
        reply_id += 1
        if reply_id >= const.USHRT_MAX:
            reply_id -= const.USHRT_MAX

        buf = pack('<4H', command, checksum, session_id, reply_id)
        return buf + command_string
170562
function(pjson, dir) {
    var main = pjson.main || '';
    var libDir = pjson.directories && (pjson.directories.dist || pjson.directories.lib) || '.';

    // convert to windows-style paths if necessary
    main = path.normalize(main);
    libDir = path.normalize(libDir);

    if (main.indexOf('!') !== -1) {
      return;
    }

    function checkMain(main, libDir) {
      if (!main) {
        return Promise.resolve(false);
      }

      if (main.substr(main.length - 3, 3) === '.js') {
        main = main.substr(0, main.length - 3);
      }

      return new Promise(function(resolve) {
        fs.exists(path.resolve(dir, libDir || '.', main) + '.js', function(exists) {
          resolve(exists);
        });
      });
    }

    return checkMain(main, libDir)
    .then(function(hasMain) {
      if (hasMain) {
        return;
      }

      return asp(fs.readFile)(path.resolve(dir, 'bower.json'))
      .then(function(bowerJson) {
        try {
          bowerJson = JSON.parse(bowerJson);
        } catch(e) {
          return;
        }

        main = bowerJson.main || '';
        if (main instanceof Array) {
          main = main[0];
        }

        return checkMain(main);
      }, function() {})
      .then(function(hasBowerMain) {
        if (!hasBowerMain) {
          return;
        }

        pjson.main = main;
      });
    });
  }
1201310
def _cmd(self, *nargs):
        """"""
        cmd_str = ' '.join(map(quote, nargs))

        if self.package.config.debug("package_release"):
            print_debug("Running command: %s" % cmd_str)

        p = popen(nargs, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                  cwd=self.pkg_root)
        out, err = p.communicate()

        if p.returncode:
            print_debug("command stdout:")
            print_debug(out)
            print_debug("command stderr:")
            print_debug(err)
            raise ReleaseVCSError("command failed: %s\n%s" % (cmd_str, err))
        out = out.strip()
        if out:
            return [x.rstrip() for x in out.split('\n')]
        else:
            return []
274410
function execList(options) {
  const deferred = Q.defer();

  const json = options.json !== false;
  const offline = options.offline !== false;
  const cwd = options.cwd || process.cwd();
  const config = {json, offline, cwd};

  bower.commands.list(undefined, config)
      .on('end', (conf) => {
        deferred.resolve(flatten(conf));
      })
      .on('error', (error) => {
        deferred.reject(error);
      });

  return deferred.promise;
}
167650
def create_arg_parser(parent):
    

    arg1 = parent.add_subparsers(dest='command')

    arg2 = arg1.add_parser('create')
    arg2.add_argument('-P', '--progress',
                      action='store_true',
                      help='show progress bar')
    arg2.add_argument('-s', '--settings',
                      type=FileType('r'), default=None,
                      help='settings json file')
    arg2.add_argument('-o', '--output',
                      default=None,
                      help='output file (default: stdout)')
    arg2.add_argument('input', nargs='*',
                      help='input file (default: stdin)')

    arg2 = arg1.add_parser('update')
    arg2.add_argument('-P', '--progress',
                      action='store_true',
                      help='show progress bar')
    arg2.add_argument('-s', '--settings',
                      type=FileType('r'), default=None,
                      help='settings json file')
    arg2.add_argument('-o', '--output',
                      default=None,
                      help='output file (default: rewrite state file)')
    arg2.add_argument('state',
                      help='state file')
    arg2.add_argument('input', nargs='*',
                      help='input file (default: stdin)')

    arg2 = arg1.add_parser('settings')
    arg2.add_argument('state',
                      help='state file')

    arg2 = arg1.add_parser('generate')
    arg2.add_argument('-P', '--progress',
                      action='store_true',
                      help='show progress bar')
    arg2.add_argument('-nf', '--no-format',
                      dest='format',
                      action='store_false',
                      help='do not format text')
    arg2.add_argument('-s', '--settings',
                      type=FileType('r'), default=None,
                      help='settings json file')
    arg2.add_argument('-ss', '--state-size',
                      type=int, default=None,
                      help='generator state size')
    arg2.add_argument('-S', '--start',
                      default=None,
                      help='text start')
    arg2.add_argument('-E', '--end',
                      default=None,
                      help='text end')
    arg2.add_argument('-R', '--reply',
                      default=None,
                      help='reply to text')
    arg2.add_argument('-w', '--words',
                      type=int, default=256,
                      help='max text size (default: %(default)s)')
    arg2.add_argument('-c', '--count',
                      type=int, default=1,
                      help='number of generated texts (default: %(default)s)')
    arg2.add_argument('-o', '--output',
                      type=FileType('w'), default=None,
                      help='output file (default: stdout)')
    arg2.add_argument('state',
                      help='state file')

    arg2.set_defaults(format=True)
228649
function(callback) {

            var binary = binaries.bower;
            binary.command = 'bower --allow-root install';

            helper.runCommand(
                binary, path,
                'bower binary is not ready to use, fix this (npm install -g bower)  and retry ' +
                'installation of frontend dependencies manually'.grey,
                callback
            );
        }