Changeset 2390


Ignore:
Timestamp:
11/26/2011 4:26:52 AM (3 years ago)
Author:
lowjoel
Message:

Implemented a HTTP request function to inform the server that a new build is available, since the build server is now different from the web server.

Location:
trunk/website/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/website/scripts/BuildPublish.php

    r2389 r2390  
    4444     
    4545    //Then update our website builds information 
    46      
     46    $serverResponse = fopen('php://temp', 'rw'); 
     47    try 
     48    { 
     49        Download(sprintf('http://eraser.heidi.ie/scripts/BuildServer.php?branch=%s&revision=%d&filesize=%d&url=%s', 
     50            $argv[1], $argv[2], filesize($argv[3]), urlencode(HTTP_WEB_ROOT . $installerPath)), 
     51            $serverResponse, $build_username, $build_password); 
     52        fseek($serverResponse, 0); 
     53        while (($line = fgets($handle, 4096)) !== false) 
     54            echo $line; 
     55        if (!feof($handle)) 
     56            throw new Exception('Unexpected fgets() failure'); 
     57        fclose($serverResponse); 
     58    } 
     59    catch (Exception $e) 
     60    { 
     61        fclose($serverResponse); 
     62        Delete(SHELL_WEB_ROOT . $installerPath, $sftp_username, $sftp_password); 
     63        throw $e; 
     64    } 
    4765} 
    4866catch (Exception $e) 
  • trunk/website/scripts/BuildUtil.php

    r2386 r2390  
    2222 
    2323    printf("File uploaded.\n"); 
     24} 
     25 
     26/** 
     27 * Downloads the contents of a particular URL to a stream. 
     28 *  
     29 * @param string $url      The URL to download. 
     30 * @param string $stream   The stream to save to. 
     31 * @param string $username The username of the user, if required. 
     32 * @param string $password The password of the user, if required. 
     33 */ 
     34function Download($url, $stream, $username = '', $password = '') 
     35{ 
     36    printf('Downloading %s... ', $url); 
     37 
     38    $curl = curl_init($url); 
     39    curl_setopt($curl, CURLOPT_USERPWD, sprintf('%s:%s', $username, $password)); 
     40    curl_setopt($curl, CURLOPT_FILE, $stream); 
     41 
     42    if (curl_exec($curl) === false) 
     43        throw new Exception('cURL Error: ' . curl_error($curl)); 
     44    curl_close($curl); 
     45 
     46    printf("File downloaded.\n"); 
    2447} 
    2548 
Note: See TracChangeset for help on using the changeset viewer.