Commit 7e4bc468 authored by maruel@google.com's avatar maruel@google.com

Remove wget.exe and use a small javascript instead. Had issues with some AV...

Actually, the get_file.js code was written by B.J. I have no merit.
Review URL: http://codereview.chromium.org/93139

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@14457 0039d316-1c4b-4281-b951-d872f2087c98
parent 820410ca
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function download(sURL, sPath, verbose) {
if (verbose) {
WScript.StdOut.Write(" * GET " + sURL + "...");
}
var oResponseBody = null;
try {
oXMLHTTP = new ActiveXObject("MSXML2.ServerXMLHTTP");
} catch (e) {
WScript.StdOut.WriteLine("[-] XMLHTTP " + new Number(e.number).toHex() +
": Cannot create Active-X object (" + e.description) + ").";
WScript.Quit(1);
}
try {
oXMLHTTP.open("GET", sURL, false);
} catch (e) {
WScript.StdOut.WriteLine("[-] XMLHTTP " + new Number(e.number).toHex() +
": invalid URL.");
WScript.Quit(1);
}
var sSize = "?";
var iSize
try {
oXMLHTTP.send(null);
if (oXMLHTTP.status != 200) {
WScript.StdOut.WriteLine("[-] HTTP " + oXMLHTTP.status + " " +
oXMLHTTP.statusText);
WScript.Quit(1);
}
oResponseBody = oXMLHTTP.responseBody;
sSize = oXMLHTTP.getResponseHeader("Content-Length");
if (sSize != "") {
iSize = parseInt(sSize)
sSize = iSize.toBytes();
} else {
try {
iSize = new Number(oXMLHTTP.responseText.length)
sSize = iSize.toBytes();
} catch(e) {
sSize = "unknown size";
}
}
} catch (e) {
WScript.StdOut.WriteLine("[-] XMLHTTP " + new Number(e.number).toHex() +
": Cannot make HTTP request (" + e.description) + ")";
WScript.Quit(1);
}
if (verbose) {
WScript.StdOut.WriteLine("ok (" + sSize + ").");
WScript.StdOut.Write(" * Save " + sPath + "...");
}
try {
var oAS = new ActiveXObject("ADODB.Stream");
oAS.Mode = 3; // ReadWrite
oAS.Type = 1; // 1= Binary
oAS.Open(); // Open the stream
oAS.Write(oResponseBody); // Write the data
oAS.SaveToFile(sPath, 2); // Save to our destination
oAS.Close();
} catch(e) {
WScript.StdOut.WriteLine("[-] ADODB.Stream " + new Number(e.number).toHex() +
": Cannot save file (" + e.description + ")");
WScript.Quit(1);
}
if (typeof(iSize) != undefined) {
oFSO = WScript.CreateObject("Scripting.FileSystemObject")
oFile = oFSO.GetFile(sPath)
if (oFile.Size < iSize) {
WScript.StdOut.WriteLine("[-] File only partially downloaded.");
WScript.Quit(1);
}
}
if (verbose) {
WScript.StdOut.WriteLine("ok.");
}
}
Number.prototype.isInt = function Number_isInt() {
return this % 1 == 0;
};
Number.prototype.toBytes = function Number_toBytes() {
// Returns a "pretty" string representation of a number of bytes:
var aUnits = ["KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
var sUnit = "bytes";
var iLimit = 1;
while(this > iLimit * 1100 && aUnits.length > 0) {
iLimit *= 1024;
sUnit = aUnits.shift();
}
return (Math.round(this * 100 / iLimit) / 100).toString() + " " + sUnit;
};
Number.prototype.toHex = function Number_toHex(nLength) {
if (arguments.length == 0) nLength = 1;
if (typeof(nLength) != "number" && !(nLength instanceof Number)) {
throw Exception("Length must be a positive integer larger than 0.", TypeError, 0);
}
if (nLength < 1 || !nLength.isInt()) {
throw Exception("Length must be a positive integer larger than 0.", "RangeError", 0);
}
var sResult = (this + (this < 0 ? 0x100000000 : 0)).toString(16);
while (sResult.length < nLength) sResult = "0" + sResult;
return sResult;
};
if (WScript.Arguments.length != 2) {
WScript.StdOut.Write("Incorrect arguments to download.js")
} else {
download(WScript.Arguments(0), WScript.Arguments(1), false);
}
...@@ -24,7 +24,7 @@ goto :PYTHON_CHECK ...@@ -24,7 +24,7 @@ goto :PYTHON_CHECK
echo Installing subversion ... echo Installing subversion ...
:: svn is not accessible; check it out and create 'proxy' files. :: svn is not accessible; check it out and create 'proxy' files.
if exist "%~dp0svn.7z" del "%~dp0svn.7z" if exist "%~dp0svn.7z" del "%~dp0svn.7z"
call "%~dp0wget" -q %WIN_TOOLS_ROOT_URL%/third_party/svn_win_client.7z -O "%~dp0svn.7z" cscript //nologo //e:jscript "%~dp0get_file.js" %WIN_TOOLS_ROOT_URL%/third_party/svn_win_client.7z "%~dp0svn.7z"
if errorlevel 1 goto :SVN_FAIL if errorlevel 1 goto :SVN_FAIL
echo call "%~dp07za" x -y "%~dp0svn.7z" -o"%WIN_TOOLS_ROOT_DIR%" 1>nul echo call "%~dp07za" x -y "%~dp0svn.7z" -o"%WIN_TOOLS_ROOT_DIR%" 1>nul
call "%~dp07za" x -y "%~dp0svn.7z" -o"%WIN_TOOLS_ROOT_DIR%" 1>nul call "%~dp07za" x -y "%~dp0svn.7z" -o"%WIN_TOOLS_ROOT_DIR%" 1>nul
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment