本文整理汇总了PHP中parse_args函数的典型用法代码示例。如果您正苦于以下问题:PHP parse_args函数的具体用法?PHP parse_args怎么用?PHP parse_args使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parse_args函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: date_default_timezone_set
date_default_timezone_set('Europe/London');
ob_implicit_flush();
set_time_limit(0);
// signal handling
declare (ticks=1);
$must_exit = 0;
pcntl_signal(SIGTERM, "signal_handler");
pcntl_signal(SIGINT, "signal_handler");
$argc = $_SERVER["argc"];
$argv = $_SERVER["argv"];
//$argv is an array
if ($argc == 0) {
error(usage());
}
$args = parse_args($argc, $argv);
if (isset($args['d'])) {
$debug = $args['d'];
} elseif (isset($args['debug'])) {
$debug = $args['debug'];
} else {
$debug = 0;
}
function signal_handler($signo)
{
global $must_exit;
switch ($signo) {
case SIGTERM:
$must_exit = 'SIGTERM';
break;
case SIGINT:
示例2: parse_args
/**
* returns a BenchmarkArchiver object based on command line arguments
* @return BenchmarkArchiver
*/
public static function &getArchiver()
{
$archiver = NULL;
$options = parse_args(array('store:', 'store_container:', 'store_endpoint:', 'store_insecure', 'store_key:', 'store_prefix:', 'store_public', 'store_region:', 'store_secret:', 'v' => 'verbose'), NULL, 'save_');
merge_options_with_config($options, BenchmarkDb::BENCHMARK_DB_CONFIG_FILE);
$impl = 'BenchmarkArchiver';
switch ($options['store']) {
case 'azure':
$impl .= 'Azure';
break;
case 'google':
$impl .= 'Google';
break;
case 's3':
$impl .= 'S3';
break;
default:
$err = '--store ' . $options['store'] . ' is not valid';
break;
}
// invalid --store argument
if (isset($err)) {
print_msg($err, isset($options['verbose']), __FILE__, __LINE__, TRUE);
return $archiver;
}
require_once sprintf('%s/%s.php', dirname(__FILE__), $impl);
$archiver = new $impl($options);
$archiver->options = $options;
if (!$archiver->validate()) {
$archiver = NULL;
}
return $archiver;
}
示例3: parse_args
/**
* Parse the given input into an array, and then backfill
* with the contents of $defaults, if given.
* @param mixed $in Accepts querystrings, arrays, and objects
* @param mixed $defaults Accepts querystrings, arrays, and objects, or simply null
* @return array Hashmap of input
*/
function parse_args($in, $defaults = null)
{
if (!$in && !$defaults) {
return array();
} else {
if (!$in) {
return $defaults;
}
}
if (is_array($in)) {
$in_arr = $in;
} else {
if (is_object($in)) {
$in_arr = get_object_vars($in);
} else {
parse_str($in, $in_arr);
}
}
if (!is_array($in_arr)) {
throw new Exception("Failed to parse String input into an array: " . $in);
}
if (!is_null($defaults)) {
$defaults = parse_args($defaults);
}
return $defaults && count($defaults) ? array_merge($defaults, $in_arr) : $in_arr;
}
示例4: __construct
/**
* Constructor
*
* @param $path
* @param $controller_root
* @param $view_root
* @param $use_routes
* @param $force_routes
*/
public function __construct($path = null, $controller_root = null, $view_root = null, $use_routes = true, $force_routes = false)
{
$args = parse_args();
$switches = parse_switches();
$path = $path ? $path : $args[0];
array_shift($args);
$controller_root = $controller_root ? $controller_root : PATH_APP . 'shell/controller/';
$view_root = $view_root ? $view_root : PATH_APP . 'shell/view/';
parent::__construct($path, $controller_root, $view_root, $use_routes, $force_routes);
$this->segments = $args;
}
示例5: selectmarkedhash
function selectmarkedhash($name, $hash, $options = "")
{
$opts = array_merge(parse_args("salt=NaCl"), parse_args($options));
$result = "<select name=\"{$name}\" {$hash['extra']}>\n";
while (list($key, $val) = each($hash)) {
$selected = $key == $opts[marked] ? "selected" : "";
$result = $result . "<option value=\"{$key}\" {$selected}>{$val}\n";
}
$result = $result . "</select>\n";
# the array keys as a CSV
$keys = implode(",", array_keys($hash));
# determine salted encrypt hash + BASE64 encode it
# @ suppresses the "empty IV" error
// $encrypt = @mcrypt_ecb(MCRYPT_RIJNDAEL_256,$opts[salt],$keys,MCRYPT_ENCRYPT);
// $encrypt = base64_encode($encrypt);
# and return a hidden field for it
// $result=$result."<input type='hidden' name='salt[$name]' value='$encrypt'>";
return $result;
}
示例6: parse_args
function parse_args($args)
{
$result = [];
foreach ($args as $key => $item) {
switch (true) {
case is_object($item):
$value = sprintf('<em>object</em>(%s)', parse_class(get_class($item)));
break;
case is_array($item):
if (count($item) > 3) {
$value = sprintf('[%s, ...]', parse_args(array_slice($item, 0, 3)));
} else {
$value = sprintf('[%s]', parse_args($item));
}
break;
case is_string($item):
if (strlen($item) > 20) {
$value = sprintf('\'<a class="toggle" title="%s">%s...</a>\'', htmlentities($item), htmlentities(substr($item, 0, 20)));
} else {
$value = sprintf("'%s'", htmlentities($item));
}
break;
case is_int($item):
case is_float($item):
$value = $item;
break;
case is_null($item):
$value = '<em>null</em>';
break;
case is_bool($item):
$value = '<em>' . ($item ? 'true' : 'false') . '</em>';
break;
case is_resource($item):
$value = '<em>resource</em>';
break;
default:
$value = htmlentities(str_replace("\n", '', var_export(strval($item), true)));
break;
}
$result[] = is_int($key) ? $value : "'{$key}' => {$value}";
}
return implode(', ', $result);
}
示例7: message
}
if (!defined('MODX_CORE_PATH') || !defined('MODX_CONFIG_KEY')) {
print message("Could not load MODX.\n" . "MODX_CORE_PATH or MODX_CONFIG_KEY undefined in\n" . "{$dir}/config.core.php", 'ERROR');
die(2);
}
if (!file_exists(MODX_CORE_PATH . 'model/modx/modx.class.php')) {
print message("modx.class.php not found at " . MODX_CORE_PATH . 'model/modx/modx.class.php', 'ERROR');
die(3);
}
// fire up MODX
require_once MODX_CORE_PATH . 'config/' . MODX_CONFIG_KEY . '.inc.php';
require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
$modx = new modX();
$modx->initialize('mgr');
// get args from cli
$params = parse_args($argv);
if ($params['help']) {
show_help();
exit;
}
// Validate the args:
if ($params['count'] <= 0) {
print message("--count must be greater than 0", 'ERROR');
die;
}
if (!$params['remove'] && !$params['classname']) {
print message("--classname is required for insert operations.", 'ERROR');
die;
}
if ($params['classname'] && !in_array($params['classname'], array_keys($supported_classnames))) {
print message("Unsupported classname.", 'ERROR');
示例8: main
/**
* Our main entry point.
*/
function main($argv)
{
$params = parse_args($argv);
if (!sort($params["files"])) {
$error = "sort() failed";
throw new Exception($error);
}
$hashes = "";
foreach ($params["files"] as $key => $value) {
$sha1 = get_sha1($value);
$hashes .= $sha1 . "\n";
printf("SHA1 of %40s: %s\n", $value, $sha1);
debug("");
debug("---");
debug("");
}
$sha1 = sha1($hashes);
printf("SHA1 of %40s: %s\n", "ALL OF THE ABOVE", $sha1);
}
示例9: ch_curl
/**
* Invokes an http request and returns the status code (or response body if
* $retBody is TRUE) on success, NULL on failure or FALSE if the response code
* is not within the $success range
* @param string $url the target url
* @param string $method the http method
* @param array $headers optional request headers to include (hash or array)
* @param string $file optional file to pipe into the curl process as the
* body
* @param string $auth optional [user]:[pswd] to use for http authentication
* @param string $success the http response code/range that consistitutes
* a successful request. defaults to 200 to 299. This parameter may be a comma
* separated list of values or ranges (e.g. "200,404" or "200-299,404")
* @param boolean $retBody whether or not to return the response body. If
* FALSE (default), the status code is returned
* @return mixed
*/
function ch_curl($url, $method = 'HEAD', $headers = NULL, $file = NULL, $auth = NULL, $success = '200-299', $retBody = FALSE)
{
global $ch_curl_options;
if (!isset($ch_curl_options)) {
$ch_curl_options = parse_args(array('v' => 'verbose'));
}
if (!is_array($headers)) {
$headers = array();
}
$ofile = $retBody ? '/tmp/' . rand() : '/dev/null';
$curl = sprintf('curl -s -X %s%s -w "%s\\n" -o %s', $method, $method == 'HEAD' ? ' -I' : '', '%{http_code}', $ofile);
if ($auth) {
$curl .= sprintf(' -u "%s"', $auth);
}
if (is_array($headers)) {
foreach ($headers as $header => $val) {
$curl .= sprintf(' -H "%s%s"', is_numeric($header) ? '' : $header . ':', $val);
}
}
// input file
if (($method == 'POST' || $method == 'PUT') && file_exists($file)) {
$curl .= sprintf(' --data-binary @%s', $file);
if (!isset($headers['Content-Length']) && !isset($headers['content-length'])) {
$curl .= sprintf(' -H "Content-Length:%d"', filesize($file));
}
if (!isset($headers['Content-Type']) && !isset($headers['content-type'])) {
$curl .= sprintf(' -H "Content-Type:%d"', get_mime_type($file));
}
}
$curl .= sprintf(' "%s"', $url);
$ok = array();
foreach (explode(',', $success) as $range) {
if (is_numeric($range)) {
$ok[$range * 1] = TRUE;
} else {
if (preg_match('/^([0-9]+)\\s*\\-\\s*([0-9]+)$/', $range, $m) && $m[1] <= $m[2]) {
for ($i = $m[1]; $i <= $m[2]; $i++) {
$ok[$i] = TRUE;
}
}
}
}
$ok = array_keys($ok);
sort($ok);
$cmd = sprintf('%s 2>/dev/null;echo $?', $curl);
print_msg(sprintf('Invoking curl request: %s (expecting response %s)', $curl, $success), isset($ch_curl_options['verbose']), __FILE__, __LINE__);
// execute curl
$result = shell_exec($cmd);
$output = explode("\n", trim($result));
$response = NULL;
// interpret callback response
if (count($output) == 2) {
$status = $output[0] * 1;
$ecode = $output[1] * 1;
if ($ecode) {
print_msg(sprintf('curl failed with exit code %d', $ecode), isset($ch_curl_options['verbose']), __FILE__, __LINE__, TRUE);
} else {
if (in_array($status, $ok)) {
print_msg(sprintf('curl successful with status code %d', $status), isset($ch_curl_options['verbose']), __FILE__, __LINE__);
$response = $retBody && file_exists($ofile) ? file_get_contents($ofile) : $status;
} else {
$response = FALSE;
print_msg(sprintf('curl failed because to status code %d in not in allowed range %s', $status, $success), isset($ch_curl_options['verbose']), __FILE__, __LINE__, TRUE);
}
}
}
if ($retBody && file_exists($ofile)) {
unlink($ofile);
}
return $response;
}
示例10: getRunOptions
/**
* returns run options represents as a hash
* @return array
*/
public static function getRunOptions()
{
// default run argument values
$sysInfo = get_sys_info();
$ini = get_benchmark_ini();
$defaults = array('active_range' => 100, 'collectd_rrd_dir' => '/var/lib/collectd/rrd', 'fio' => 'fio', 'fio_options' => array('direct' => TRUE, 'ioengine' => 'libaio', 'refill_buffers' => FALSE, 'scramble_buffers' => TRUE), 'font_size' => 9, 'highcharts_js_url' => 'http://code.highcharts.com/highcharts.js', 'highcharts3d_js_url' => 'http://code.highcharts.com/highcharts-3d.js', 'jquery_url' => 'http://code.jquery.com/jquery-2.1.0.min.js', 'meta_compute_service' => 'Not Specified', 'meta_cpu' => $sysInfo['cpu'], 'meta_instance_id' => 'Not Specified', 'meta_memory' => $sysInfo['memory_gb'] > 0 ? $sysInfo['memory_gb'] . ' GB' : $sysInfo['memory_mb'] . ' MB', 'meta_os' => $sysInfo['os_info'], 'meta_provider' => 'Not Specified', 'meta_storage_config' => 'Not Specified', 'meta_test_sw' => isset($ini['meta-id']) ? 'ch-' . $ini['meta-id'] . (isset($ini['meta-version']) ? ' ' . $ini['meta-version'] : '') : '', 'oio_per_thread' => 64, 'output' => trim(shell_exec('pwd')), 'precondition_passes' => 2, 'ss_max_rounds' => 25, 'ss_verification' => 10, 'test' => array('iops'), 'threads' => '{cpus}', 'threads_per_core_max' => 2, 'threads_per_target_max' => 8, 'timeout' => 86400, 'wd_test_duration' => 60);
$opts = array('active_range:', 'collectd_rrd', 'collectd_rrd_dir:', 'fio:', 'font_size:', 'highcharts_js_url:', 'highcharts3d_js_url:', 'jquery_url:', 'meta_compute_service:', 'meta_compute_service_id:', 'meta_cpu:', 'meta_drive_interface:', 'meta_drive_model:', 'meta_drive_type:', 'meta_instance_id:', 'meta_memory:', 'meta_os:', 'meta_notes_storage:', 'meta_notes_test:', 'meta_provider:', 'meta_provider_id:', 'meta_region:', 'meta_resource_id:', 'meta_run_id:', 'meta_storage_config:', 'meta_storage_vol_info:', 'meta_test_id:', 'meta_test_sw:', 'no3dcharts', 'nojson', 'nopdfreport', 'noprecondition', 'nopurge', 'norandom', 'noreport', 'nosecureerase', 'notrim', 'nozerofill', 'oio_per_thread:', 'output:', 'precondition_passes:', 'randommap', 'savefio', 'secureerase_pswd:', 'sequential_only', 'skip_blocksize:', 'skip_workload:', 'ss_max_rounds:', 'ss_verification:', 'target:', 'target_skip_not_present', 'test:', 'threads:', 'threads_per_core_max:', 'threads_per_target_max:', 'timeout:', 'trim_offset_end:', 'v' => 'verbose', 'wd_test_duration:', 'wd_sleep_between:');
$options = parse_args($opts, array('skip_blocksize', 'skip_workload', 'target', 'test'));
$verbose = isset($options['verbose']) && $options['verbose'];
// explicit fio command
foreach ($defaults as $key => $val) {
if (!isset($options[$key])) {
$options[$key] = $val;
}
}
// target/test argument (expand comma separated values)
foreach (array('target', 'test') as $key) {
if (isset($options[$key])) {
$targets = array();
foreach ($options[$key] as $temp) {
foreach (explode(',', $temp) as $target) {
$targets[] = trim($target);
}
}
$options[$key] = $targets;
}
}
foreach (get_prefixed_params('fio_') as $key => $val) {
$options['fio_options'][$key] = $val;
}
// don't use random IO
if (isset($options['norandom']) && $options['norandom']) {
if (isset($options['fio']['refill_buffers'])) {
unset($options['fio']['refill_buffers']);
}
if (isset($options['fio']['scramble_buffers'])) {
unset($options['fio']['scramble_buffers']);
}
}
// implicit nosecureerase
if (!isset($options['secureerase_pswd'])) {
$options['nosecureerase'] = TRUE;
}
// implicit nopurge
if (isset($options['nosecureerase']) && $options['nosecureerase'] && isset($options['notrim']) && $options['notrim'] && isset($options['nozerofill']) && $options['nozerofill']) {
$options['nopurge'] = TRUE;
}
// threads is based on number of CPUs
if (isset($options['threads']) && preg_match('/{cpus}/', $options['threads'])) {
$options['threads'] = str_replace(' ', '', str_replace('{cpus}', BlockStorageTest::getCpuCount(), $options['threads']));
// expression
if (preg_match('/[\\*\\+\\-\\/]/', $options['threads'])) {
eval(sprintf('$options["threads"]=%s;', $options['threads']));
}
$options['threads'] *= 1;
if ($options['threads'] <= 0) {
$options['threads'] = 1;
}
}
// remove targets that are not present
if (isset($options['target_skip_not_present']) && isset($options['target']) && count($options['target']) > 1) {
print_msg(sprintf('Checking targets %s because --target_skip_not_present argument was set', implode(', ', $options['target'])), $verbose, __FILE__, __LINE__);
$targets = array();
foreach ($options['target'] as $i => $target) {
if (!is_dir($target) && !file_exists($target)) {
print_msg(sprintf('Skipped test target %s because it does not exist and the --target_skip_not_present argument was set', $target), $verbose, __FILE__, __LINE__);
} else {
$targets[] = $target;
}
}
$options['target'] = $targets;
print_msg(sprintf('Adjusted test targets is %s', implode(', ', $options['target'])), $verbose, __FILE__, __LINE__);
}
// adjust threads for number of targets
if (isset($options['target']) && count($options['target']) > 1) {
$options['threads'] = round($options['threads'] / count($options['target']));
if ($options['threads'] == 0) {
$options['threads'] = 1;
}
}
// adjust for threads_per_target_max
if (isset($options['threads_per_target_max']) && $options['threads'] > $options['threads_per_target_max']) {
$threads = $options['threads'];
$options['threads'] = $options['threads_per_target_max'];
print_msg(sprintf('Reduced threads from %d to %d for threads_per_target_max constraint %d', $threads, $options['threads'], $options['threads_per_target_max']), $verbose, __FILE__, __LINE__);
}
$options['threads_total'] = $options['threads'] * count($options['target']);
// adjust for threads_per_core_max
if (isset($options['threads_per_core_max']) && $options['threads_total'] > $options['threads_per_core_max'] * BlockStorageTest::getCpuCount()) {
$threads_total = $options['threads_total'];
$threads = $options['threads'];
$options['threads'] = round($options['threads_per_core_max'] * BlockStorageTest::getCpuCount() / count($options['target']));
if (!$options['threads']) {
$options['threads'] = 1;
}
$options['threads_total'] = round($options['threads'] * count($options['target']));
//.........这里部分代码省略.........
示例11: getRunOptions
/**
* returns run options represents as a hash
* @return array
*/
public function getRunOptions()
{
if (!isset($this->options)) {
if ($this->dir) {
$this->options = self::getSerializedOptions($this->dir);
$this->verbose = isset($this->options['verbose']);
} else {
// default run argument values
$sysInfo = get_sys_info();
$defaults = array('collectd_rrd_dir' => '/var/lib/collectd/rrd', 'dns_retry' => 2, 'dns_samples' => 10, 'dns_timeout' => 5, 'geo_regions' => 'us_west us_central us_east canada eu_west eu_central eu_east oceania asia america_south africa', 'latency_interval' => 0.2, 'latency_samples' => 100, 'latency_timeout' => 3, 'meta_cpu' => $sysInfo['cpu'], 'meta_memory' => $sysInfo['memory_gb'] > 0 ? $sysInfo['memory_gb'] . ' GB' : $sysInfo['memory_mb'] . ' MB', 'meta_os' => $sysInfo['os_info'], 'output' => trim(shell_exec('pwd')), 'spacing' => 200, 'test' => 'latency', 'throughput_size' => 5, 'throughput_threads' => 2, 'throughput_uri' => '/web-probe');
$opts = array('abort_threshold:', 'collectd_rrd', 'collectd_rrd_dir:', 'discard_fastest:', 'discard_slowest:', 'dns_one_server', 'dns_retry:', 'dns_samples:', 'dns_tcp', 'dns_timeout:', 'geoiplookup', 'geo_regions:', 'latency_interval:', 'latency_samples:', 'latency_skip:', 'latency_timeout:', 'max_runtime:', 'max_tests:', 'meta_compute_service:', 'meta_compute_service_id:', 'meta_cpu:', 'meta_instance_id:', 'meta_location:', 'meta_memory:', 'meta_os:', 'meta_provider:', 'meta_provider_id:', 'meta_region:', 'meta_resource_id:', 'meta_run_id:', 'meta_test_id:', 'min_runtime:', 'min_runtime_in_save', 'output:', 'params_url:', 'params_url_service_type:', 'params_url_header:', 'randomize', 'same_continent_only', 'same_country_only', 'same_geo_region', 'same_provider_only', 'same_region_only', 'same_service_only', 'same_state_only', 'service_lookup', 'sleep_before_start:', 'spacing:', 'suppress_failed', 'test:', 'test_endpoint:', 'test_instance_id:', 'test_location:', 'test_private_network_type:', 'test_provider:', 'test_provider_id:', 'test_region:', 'test_service:', 'test_service_id:', 'test_service_type:', 'throughput_header:', 'throughput_https', 'throughput_inverse', 'throughput_keepalive', 'throughput_same_continent:', 'throughput_same_country:', 'throughput_same_geo_region:', 'throughput_same_provider:', 'throughput_same_region:', 'throughput_same_service:', 'throughput_same_state:', 'throughput_samples:', 'throughput_size:', 'throughput_slowest_thread', 'throughput_small_file', 'throughput_threads:', 'throughput_time', 'throughput_timeout:', 'throughput_uri:', 'throughput_use_mean', 'throughput_webpage:', 'throughput_webpage_check', 'traceroute', 'v' => 'verbose');
$this->options = parse_args($opts, array('latency_skip', 'params_url_service_type', 'params_url_header', 'test', 'test_endpoint', 'test_instance_id', 'test_location', 'test_provider', 'test_provider_id', 'test_region', 'test_service', 'test_service_id', 'test_service_type', 'throughput_header', 'throughput_webpage'));
$this->options['run_start'] = time();
$this->verbose = isset($this->options['verbose']);
// set default same size constraints if --throughput_size is not set
if (!isset($this->options['throughput_size'])) {
foreach (array('throughput_same_continent' => 10, 'throughput_same_country' => 20, 'throughput_same_geo_region' => 30, 'throughput_same_provider' => 10, 'throughput_same_region' => 100, 'throughput_same_state' => 50) as $k => $v) {
$defaults[$k] = $v;
}
}
foreach ($defaults as $key => $val) {
if (!isset($this->options[$key])) {
$this->options[$key] = $val;
$this->defaultsSet[] = $key;
}
}
if (isset($this->options['throughput_size']) && $this->options['throughput_size'] == 0) {
$this->options['throughput_time'] = TRUE;
}
if (!isset($this->options['throughput_samples'])) {
$this->options['throughput_samples'] = isset($this->options['throughput_small_file']) || isset($this->options['throughput_time']) ? 10 : 5;
}
if (!isset($this->options['throughput_timeout'])) {
$this->options['throughput_timeout'] = isset($this->options['throughput_small_file']) || isset($this->options['throughput_time']) ? 5 : 180;
}
// expand geo_regions
if (isset($this->options['geo_regions'])) {
$geoRegions = array();
foreach (explode(',', $this->options['geo_regions']) as $r1) {
foreach (explode(' ', $r1) as $r2) {
$r2 = strtolower(trim($r2));
if ($r2 && !in_array($r2, $geoRegions)) {
$geoRegions[] = $r2;
}
}
}
if ($geoRegions) {
$this->options['geo_regions'] = $geoRegions;
}
}
// expand tests
if (!is_array($this->options['test'])) {
$this->options['test'] = array($this->options['test']);
}
foreach ($this->options['test'] as $i => $test) {
$tests = array();
foreach (explode(',', $test) as $t1) {
foreach (explode(' ', $t1) as $t2) {
$t2 = strtolower(trim($t2));
if ($t2 && !in_array($t2, $tests)) {
$tests[] = $t2;
}
}
}
if ($tests) {
$this->options['test'][$i] = $tests;
} else {
unset($this->options['test'][$i]);
}
}
// get parameters from a URL
if (isset($this->options['params_url'])) {
$headers = array();
if (isset($this->options['params_url_header'])) {
foreach ($this->options['params_url_header'] as $header) {
if (preg_match('/^(.*):(.*)$/', $header, $m)) {
$headers[trim($m[1])] = trim($m[2]);
} else {
print_msg(sprintf('Skipping header %s because it is not properly formatted ([key]:[val])', $header), $this->verbose, __FILE__, __LINE__, TRUE);
}
}
}
if ($params = json_decode($json = ch_curl($this->options['params_url'], 'GET', $headers, NULL, NULL, '200-299', TRUE), TRUE)) {
print_msg(sprintf('Successfully retrieved %d runtime parameters from the URL %s', count($params), $this->options['params_url']), $this->verbose, __FILE__, __LINE__);
foreach ($params as $key => $val) {
if (!isset($this->options[$key]) || in_array($key, $this->defaultsSet)) {
print_msg(sprintf('Added runtime parameter %s=%s from --params_url', $key, is_array($val) ? implode(',', $val) : $val), $this->verbose, __FILE__, __LINE__);
$this->options[$key] = $val;
} else {
print_msg(sprintf('Skipping runtime parameter %s=%s from --params_url because it was set on the command line', $key, $val), $this->verbose, __FILE__, __LINE__);
}
}
// remove test endpoints that are not of the --params_url_service_type
// specified
if (isset($this->options['params_url_service_type'])) {
foreach ($this->options['test_endpoint'] as $i => $endpoint) {
//.........这里部分代码省略.........
示例12: define
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define('INSTALLDIR', realpath(dirname(__FILE__) . '/..'));
$shortoptions = 'f:d:u:';
$helptext = <<<END_OF_SITEMAP_HELP
Script for creating sitemaps files per http://sitemaps.org/
-f <indexfile> Use <indexfile> as output file
-d <outputdir> Use <outputdir> for new sitemaps
-u <outputurl> Use <outputurl> as root for URLs
END_OF_SITEMAP_HELP;
require_once INSTALLDIR . '/scripts/commandline.inc';
$output_paths = parse_args();
standard_map();
notices_map();
user_map();
index_map();
// ------------------------------------------------------------------------------
// Main functions: get data out and turn them into sitemaps
// ------------------------------------------------------------------------------
// Generate index sitemap of all other sitemaps.
function index_map()
{
global $output_paths;
$output_dir = $output_paths['output_dir'];
$output_url = $output_paths['output_url'];
foreach (glob("{$output_dir}*.xml") as $file_name) {
// Just the file name please.
示例13: initialise_opt
<?php
/* This is a script which generates simple PHPT test cases from the name of the function.
* It works using the {{{ proto for the function PHP source code. The test cases that it generates
* are simple, however you can also give it the name of a file with PHP code in and it will turn this
* into the right format for a PHPT test.
* This script will not generate expected output.
* Further quidance on how to use it can be found on qa.php.net, or by using the -h command line option.
*/
//read the command line input and parse it, do some basic checks to make sure that it's correct
$opt = initialise_opt();
$opt = parse_args($argv, $opt);
check_source($opt['source_loc']);
check_fname($opt['name']);
check_testcase($opt['error_gen'], $opt['basic_gen'], $opt['variation_gen']);
if ($opt['include_block'] != NULL) {
check_file($opt['include_block']);
}
//Get a list of all the c funtions in the source tree
$all_c = array();
$c_file_count = 0;
dirlist($opt['source_loc'], $c_file_count, $all_c);
//Search the list of c functions for the function prototype, quit if can't find it or if the function is an alias
$test_info = get_loc_proto($all_c, $opt['name'], $opt['source_loc']);
if (!$test_info['found']) {
echo "\nExiting: Unable to find implementation of {$opt['name']} in {$opt['source_loc']}\n";
if ($test_info['falias']) {
//But it may be aliased to something else
echo "\n{$test_info['name']}() is an alias of {$test_info['alias']}() --- Write test cases for this instead \n";
}
exit;
示例14: dirname
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
* saves results based on the arguments defined in ../run.sh
*/
require_once dirname(__FILE__) . '/NetworkTest.php';
require_once dirname(__FILE__) . '/benchmark/save/BenchmarkDb.php';
$status = 1;
$args = parse_args(array('iteration:', 'nostore_rrd', 'nostore_traceroute', 'params_file:', 'recursive_order:', 'recursive_count:', 'v' => 'verbose'), array('params_file'), 'save_');
$verbose = isset($args['verbose']);
print_msg(sprintf('Initiating save with arguments [%s]', implode(', ', array_keys($args))), $verbose, __FILE__, __LINE__);
// save to multiple repositories (multiple --params_file parameters)
if (isset($args['params_file']) && count($args['params_file']) > 1) {
$cmd = __FILE__;
for ($i = 1; $i < count($argv); $i++) {
if ($argv[$i] != '--params_file' && !in_array($argv[$i], $args['params_file'])) {
$cmd .= ' ' . $argv[$i];
}
}
foreach ($args['params_file'] as $i => $pfile) {
$pcmd = sprintf('%s --params_file %s --recursive_order %d --recursive_count %d', $cmd, $pfile, $i + 1, count($args['params_file']));
print $pcmd . "\n\n";
passthru($pcmd);
}
示例15: parse_args
/**
* returns a BenchmarkDb object based on command line arguments. returns NULL
* if there are any problems with the command line arguments
* @return BenchmarkDb
*/
public static function &getDb()
{
$db = NULL;
$options = parse_args(array('db:', 'db_and_csv:', 'db_callback_header:', 'db_host:', 'db_librato_aggregate', 'db_librato_color:', 'db_librato_count:', 'db_librato_description:', 'db_librato_display_max:', 'db_librato_display_min:', 'db_librato_display_name:', 'db_librato_display_units_long:', 'db_librato_display_units_short:', 'db_librato_display_stacked', 'db_librato_display_transform:', 'db_librato_max:', 'db_librato_min:', 'db_librato_measure_time:', 'db_librato_name:', 'db_librato_period:', 'db_librato_source:', 'db_librato_sum:', 'db_librato_summarize_function:', 'db_librato_sum_squares:', 'db_librato_type:', 'db_librato_value:', 'db_mysql_engine:', 'db_name:', 'db_port:', 'db_pswd:', 'db_prefix:', 'db_suffix:', 'db_user:', 'output:', 'params_file:', 'remove:', 'skip_validations', 'store:', 'v' => 'verbose'), $aparams = array('db_librato_aggregate', 'db_librato_color', 'db_librato_count', 'db_librato_description', 'db_librato_display_max', 'db_librato_display_min', 'db_librato_display_name', 'db_librato_display_units_long', 'db_librato_display_units_short', 'db_librato_display_stacked', 'db_librato_display_transform', 'db_librato_max', 'db_librato_min', 'db_librato_measure_time', 'db_librato_name', 'db_librato_period', 'db_librato_source', 'db_librato_sum', 'db_librato_summarize_function', 'db_librato_sum_squares', 'db_librato_type', 'db_librato_value', 'remove'), 'save_');
// merge settings with config file
$cfile = BenchmarkDb::BENCHMARK_DB_CONFIG_FILE;
if (isset($options['params_file']) && !file_exists($options['params_file']) && !file_exists($options['params_file'] = trim(shell_exec('pwd')) . '/' . $options['params_file'])) {
print_msg(sprintf('--params_file %s is not a valid file', $options['params_file']), TRUE, __FILE__, __LINE__, TRUE);
} else {
if (isset($options['params_file'])) {
$cfile = $options['params_file'];
}
}
merge_options_with_config($options, $cfile);
// convert array parameters found in config file
foreach ($aparams as $aparam) {
if (isset($options[$aparam]) && !is_array($options[$aparam])) {
$p = array();
foreach (explode(',', $options[$aparam]) as $v) {
if (preg_match('/^"(.*)"$/', $v) || preg_match("/^'(.*)'\$/", $v)) {
$p[] = strip_quotes($v);
} else {
foreach (explode(' ', trim($v)) as $v) {
$p[] = trim($v);
}
}
}
$options[$aparam] = $p;
}
}
if (!isset($options['remove'])) {
$options['remove'] = array();
}
// output directory
if (!isset($options['output'])) {
$options['output'] = trim(shell_exec('pwd'));
}
// default table suffix
if (!isset($options['db_suffix']) && ($ini = get_benchmark_ini()) && isset($ini['meta-version'])) {
$options['db_suffix'] = '_' . str_replace('.', '_', $ini['meta-version']);
}
$impl = 'BenchmarkDb';
if (isset($options['db'])) {
switch ($options['db']) {
case 'bigquery':
$impl .= 'BigQuery';
break;
case 'callback':
$impl .= 'Callback';
break;
case 'librato':
$impl .= 'Librato';
break;
case 'mysql':
$impl .= 'MySql';
break;
case 'postgresql':
$impl .= 'PostgreSql';
break;
default:
$err = '--db ' . $options['db'] . ' is not valid';
break;
}
// invalid --db argument
if (isset($err)) {
print_msg($err, isset($options['verbose']), __FILE__, __LINE__, TRUE);
return $db;
}
}
if ($impl != 'BenchmarkDb') {
require_once sprintf('%s/%s.php', dirname(__FILE__), $impl);
}
$db = new $impl($options);
$db->options = $options;
$db->dir = $options['output'];
if (!$db->validateDependencies()) {
$db = NULL;
} else {
if (!isset($options['skip_validations']) && !$db->validate()) {
$db = NULL;
}
}
if ($db && isset($options['store'])) {
require_once 'BenchmarkArchiver.php';
$db->archiver =& BenchmarkArchiver::getArchiver();
if (!$db->archiver) {
$db = NULL;
}
}
return $db;
}