当前位置: 首页>>代码示例>>PHP>>正文


PHP Updater::main方法代码示例

本文整理汇总了PHP中Updater::main方法的典型用法代码示例。如果您正苦于以下问题:PHP Updater::main方法的具体用法?PHP Updater::main怎么用?PHP Updater::main使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Updater的用法示例。


在下文中一共展示了Updater::main方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: main

    public function main()
    {
        $list = array('StopLocation' => array('period' => 86400), 'CarUnusual' => array('period' => 0), 'Parameter' => array('period' => 86400), 'IStop' => array('period' => 86400), 'IStopPath' => array('period' => 86400), 'Stop' => array('period' => 86400), 'Provider' => array('period' => 86400), 'OrgPathAttribute' => array('period' => 86400), 'EstimateTime' => array('period' => 0), 'BusEvent' => array('period' => 0), 'BusData' => array('period' => 0), 'SemiTimeTable' => array('period' => 86400), 'TimeTable' => array('period' => 86400), 'CarInfo' => array('period' => 86400), 'PathDetail' => array('period' => 86400), 'Route' => array('period' => 86400));
        foreach ($list as $type => $config) {
            if (!($fetched_time = $this->getSheetHubInfo($type)->sheet->meta->fetched_time)) {
                //throw new Exception("找不到原來的更新時間");
            }
            if (time() - strtotime($fetched_time) < $config['period']) {
                continue;
            }
            $time = microtime(true);
            error_log("Type={$type} downloading");
            list($fp, $updatetime) = $this->getFileFrom5284($type);
            $delta = microtime(true) - $time;
            $time = microtime(true);
            error_log("Type={$type} downloaded, spent {$delta}, uploading");
            $upload_id = $this->uploadToSheetHub($fp);
            $delta = microtime(true) - $time;
            $time = microtime(true);
            error_log("Type={$type} uploaded, spent {$delta}, updating");
            $ret = $this->updateFile($type, $upload_id);
            $delta = microtime(true) - $time;
            $time = microtime(true);
            error_log("Type={$type} updated, spent {$delta}, insert: " . count($ret->insert) . ', update: ' . count($ret->update) . ', delete: ' . count($ret->delete));
            $this->setMeta($type, array('updated_time' => $updatetime, 'fetched_time' => date('c', time()), 'period' => $config['period'] == 86400 ? '每日' : '每分鐘', 'source' => 'http://www.dot.gov.taipei/', 'update_code' => 'https://github.com/sheethub/data-import-script/blob/master/5284.taipei.gov.tw/update.php'));
        }
    }
}
$u = new Updater();
$u->main();
开发者ID:ls-wang,项目名称:data-import-script,代码行数:30,代码来源:update.php

示例2: main

                rename(stream_get_meta_data($download_fp)['uri'], $target_file);
            }
            $cmd = "node " . escapeshellarg(__DIR__ . '/geojson_parse.js') . " get_type " . escapeshellarg($target_file);
            exec($cmd, $outputs, $ret);
            if ($ret) {
                throw new Exception("取得 {$file_url} JSON 格式錯誤: " . $ret->message);
            }
        }
    }
    public function main($argv)
    {
        $fp = fopen(__DIR__ . '/../geo.csv', 'r');
        $fp_new = fopen(__DIR__ . '/../geo_new.csv', 'w');
        $columns = fgetcsv($fp);
        fputcsv($fp_new, $columns);
        while ($row = fgetcsv($fp)) {
            list($folder, $name, $url, $srs, $origin_encoding, $updated_at) = $row;
            $info = $this->getInfoFromURL($url);
            if ($updated_at != $info->updated_at) {
                $this->downloadFromURL($info->link, $folder, $srs, $origin_encoding);
                $updated_at = $info->updated_at;
            }
            fputcsv($fp_new, array($folder, $name, $url, $srs, $origin_encoding, $updated_at));
        }
        fclose($fp_new);
        rename(__DIR__ . '/../geo_new.csv', __DIR__ . '/../geo.csv');
    }
}
$u = new Updater();
$u->main($_SERVER['argv']);
开发者ID:kurotanshi,项目名称:data.taipei.gov.tw,代码行数:30,代码来源:geo_updater.php


注:本文中的Updater::main方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。