com web/rmtools: More VC11 support and improve FTP uploads: client/include/Branch.php client/include/Tools.php client/script/snap.php
| From: | Stephen A. Zarkos | Date: | Fri, 01 Mar 2013 00:20:23 +0000 |
| Subject: | com web/rmtools: More VC11 support and improve FTP uploads: client/include/Branch.php client/include/Tools.php client/script/snap.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-15634@lists.php.net to get a copy of this message | ||
Commit: 1a3747fd3ece3af1770534fd2165102c33a03dab
Author: Stephen Zarkos <stephen.zarkos@microsoft.com> Thu, 28 Feb 2013 16:20:23
-0800
Parents: 7649f91593e216cf7eda35c66e7cc13267066d9a
Branches: master
Link: http://git.php.net/?p=web/rmtools.git;a=commitdiff;h=1a3747fd3ece3af1770534fd2165102c33a03dab
Log:
More VC11 support and improve FTP uploads
Changed paths:
M client/include/Branch.php
M client/include/Tools.php
M client/script/snap.php
Diff:
diff --git a/client/include/Branch.php b/client/include/Branch.php
index f9827e6..edd95f3 100644
--- a/client/include/Branch.php
+++ b/client/include/Branch.php
@@ -52,7 +52,7 @@ class Branch {
public function update()
{
- $last_id = $this->repo->getLastCommitId();
+ $last_id = $this->repo->getLastCommitId();
if (strcasecmp($last_id, (string)$this->data->revision_last) != 0 ||
strcasecmp($last_id, $this->data->revision_previous) != 0) {
$this->data->revision_previous = $this->data->revision_last;
@@ -158,6 +158,7 @@ class Branch {
$compiler = strtolower($build['compiler']);
switch ($compiler) {
+ case 'vc11':
case 'vc9':
case 'vc6':
$build = new BuildVC($this, $build_name);
diff --git a/client/include/Tools.php b/client/include/Tools.php
index 99ad895..765a339 100644
--- a/client/include/Tools.php
+++ b/client/include/Tools.php
@@ -125,6 +125,31 @@ function upload_file($src, $target)
return $res;
}
+function upload_file_curl($src, $target) // SAZ - Like upload_file(), but using curl
+{
+ include 'C:/php-sdk/rmtools-client/data/config/credentials_ftps.php';
+ $ftp_user = $user_snaps;
+ $ftp_password = $password;
+
+ $filename = basename($src);
+ $remoteurl = "ftps://${ftp_user}:${ftp_password}@${ftp_server}/${target}/${filename}";
+ $fp = fopen($src, "rb");
+
+ $ch = curl_init();
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
+ curl_setopt($ch, CURLOPT_URL, $remoteurl);
+ curl_setopt($ch, CURLOPT_UPLOAD, 1);
+ curl_setopt($ch, CURLOPT_INFILE, $fp);
+ curl_setopt($ch, CURLOPT_USERPWD, $ftp_user . ':' . $ftp_password);
+ if (curl_exec($ch) === false) {
+ echo "Error, upload_file_curl(): " . curl_error($ch) . "\n";
+ return false;
+ }
+ fclose($fp);
+
+ return true;
+}
+
function update_snapshot_page()
{
include __DIR__ . '/../data/config/credentials_ftps.php';
@@ -152,7 +177,12 @@ function upload_build_result_ftp_curl($src_dir, $target)
if (!$login_result) {
return false;
}
- ftp_make_directory($ftp, $target. '/logs');
+
+ $try = 0;
+ do {
+ $status = ftp_make_directory($ftp, $target. '/logs');
+ $try++;
+ } while ( $status === false && $try < 10 );
ftp_close($ftp);
$curl = array();
@@ -203,9 +233,24 @@ function upload_build_result_ftp_curl($src_dir, $target)
\curl_multi_add_handle ($mh, $ch);
}
+ $retry = 0;
do {
- \curl_multi_exec($mh,$active);
- } while ($active);
+ $err = 0;
+ do {
+ \curl_multi_exec($mh,$active);
+ $info = curl_multi_info_read($mh);
+ if ($info !== false) {
+ curl_multi_remove_handle($mh, $info['handle']);
+ if ($info['result'] != 0) {
+ $err = 1;
+// echo curl_getinfo($info['handle'], CURLINFO_EFFECTIVE_URL) . "\n";
+// echo curl_error($info['handle']) . "\n\n";
+ curl_multi_add_handle($mh, $info['handle']);
+ }
+ }
+ } while ($active);
+ $retry++;
+ } while ($err != 0 && $retry < 10);
foreach ($curl as $ch) {
\curl_multi_remove_handle($mh, $ch);
diff --git a/client/script/snap.php b/client/script/snap.php
index e3ab250..ee0bcbb 100644
--- a/client/script/snap.php
+++ b/client/script/snap.php
@@ -188,13 +188,17 @@ if (!$new_rev) {
}
/*Upload the branch DB */
-rm\upload_file($branch->db_path, $branch_name . '/' . basename($branch->db_path));
-
-if ($has_build_errors) {
- rm\send_error_notification($branch_name, $build_errors, $branch->getPreviousRevision(),
$last_rev, 'http://windows.php.net/downloads/snaps/'
. $branch_name . '/r' . $last_rev);
-} else {
+$try = 0;
+do {
+ $status = rm\upload_file_curl($branch->db_path, $branch_name . '/' .
basename($branch->db_path));
+ $try++;
+} while ( $status === false && $try < 10 );
+
+//if ($has_build_errors) {
+// rm\send_error_notification($branch_name, $build_errors, $branch->getPreviousRevision(),
$last_rev, 'http://windows.php.net/downloads/snaps/'
. $branch_name . '/r' . $last_rev);
+//} else {
/* if no error, let update the snapshot page */
// rm\update_snapshot_page();
-}
+//}
echo "Done.\n";