ENH: Cleanup the output
This commit is contained in:
parent
0b0a732f26
commit
d9cb234d98
|
@ -1,17 +1,17 @@
|
||||||
/*=========================================================================
|
/*=========================================================================
|
||||||
|
|
||||||
Program: CMake - Cross-Platform Makefile Generator
|
Program: CMake - Cross-Platform Makefile Generator
|
||||||
Module: $RCSfile$
|
Module: $RCSfile$
|
||||||
Language: C++
|
Language: C++
|
||||||
Date: $Date$
|
Date: $Date$
|
||||||
Version: $Revision$
|
Version: $Revision$
|
||||||
|
|
||||||
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
|
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
|
||||||
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
|
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
|
||||||
|
|
||||||
This software is distributed WITHOUT ANY WARRANTY; without even
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
||||||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
PURPOSE. See the above copyright notices for more information.
|
PURPOSE. See the above copyright notices for more information.
|
||||||
|
|
||||||
=========================================================================*/
|
=========================================================================*/
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@
|
||||||
cmCTestSubmit::cmCTestSubmit() : m_HTTPProxy(), m_FTPProxy()
|
cmCTestSubmit::cmCTestSubmit() : m_HTTPProxy(), m_FTPProxy()
|
||||||
{
|
{
|
||||||
m_Verbose = false;
|
m_Verbose = false;
|
||||||
std::cout << "Setup proxy" << std::endl;
|
|
||||||
m_HTTPProxy = "";
|
m_HTTPProxy = "";
|
||||||
m_HTTPProxyType = 0;
|
m_HTTPProxyType = 0;
|
||||||
if ( getenv("HTTP_PROXY") )
|
if ( getenv("HTTP_PROXY") )
|
||||||
|
@ -83,14 +82,20 @@ cmCTestSubmit::cmCTestSubmit() : m_HTTPProxy(), m_FTPProxy()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout << this << " HTTP Proxy: " << m_HTTPProxy << std::endl;
|
if ( m_HTTPProxy.size() > 0 )
|
||||||
|
{
|
||||||
|
std::cout << " Use HTTP Proxy: " << m_HTTPProxy << std::endl;
|
||||||
|
}
|
||||||
|
if ( m_FTPProxy.size() > 0 )
|
||||||
|
{
|
||||||
|
std::cout << " Use FTP Proxy: " << m_FTPProxy << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmCTestSubmit::SubmitUsingFTP(const std::string& localprefix,
|
bool cmCTestSubmit::SubmitUsingFTP(const std::string& localprefix,
|
||||||
const std::vector<std::string>& files,
|
const std::vector<std::string>& files,
|
||||||
const std::string& remoteprefix,
|
const std::string& remoteprefix,
|
||||||
const std::string& url)
|
const std::string& url)
|
||||||
{
|
{
|
||||||
CURL *curl;
|
CURL *curl;
|
||||||
CURLcode res;
|
CURLcode res;
|
||||||
|
@ -112,23 +117,23 @@ bool cmCTestSubmit::SubmitUsingFTP(const std::string& localprefix,
|
||||||
curl_easy_setopt(curl, CURLOPT_PROXY, m_FTPProxy.c_str());
|
curl_easy_setopt(curl, CURLOPT_PROXY, m_FTPProxy.c_str());
|
||||||
switch (m_FTPProxyType)
|
switch (m_FTPProxyType)
|
||||||
{
|
{
|
||||||
case 2:
|
case 2:
|
||||||
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// enable uploading
|
// enable uploading
|
||||||
::curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ;
|
::curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ;
|
||||||
|
|
||||||
std::string local_file = localprefix + "/" + files[cc];
|
std::string local_file = localprefix + "/" + files[cc];
|
||||||
std::string upload_as = url + "/" + remoteprefix + files[cc];
|
std::string upload_as = url + "/" + remoteprefix + files[cc];
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if ( ::stat(local_file.c_str(), &st) )
|
if ( ::stat(local_file.c_str(), &st) )
|
||||||
{
|
{
|
||||||
|
@ -138,19 +143,17 @@ bool cmCTestSubmit::SubmitUsingFTP(const std::string& localprefix,
|
||||||
ftpfile = ::fopen(local_file.c_str(), "rb");
|
ftpfile = ::fopen(local_file.c_str(), "rb");
|
||||||
if ( m_Verbose )
|
if ( m_Verbose )
|
||||||
{
|
{
|
||||||
std::cout << "upload file: " << local_file.c_str() << " to "
|
std::cout << " Upload file: " << local_file.c_str() << " to "
|
||||||
<< upload_as.c_str() << std::endl;
|
<< upload_as.c_str() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
//std::cout << "File is opened: " << ftpfile << std::endl;
|
|
||||||
|
|
||||||
if ( m_Verbose )
|
if ( m_Verbose )
|
||||||
{
|
{
|
||||||
::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
|
||||||
}
|
}
|
||||||
// specify target
|
// specify target
|
||||||
::curl_easy_setopt(curl,CURLOPT_URL, upload_as.c_str());
|
::curl_easy_setopt(curl,CURLOPT_URL, upload_as.c_str());
|
||||||
|
|
||||||
// now specify which file to upload
|
// now specify which file to upload
|
||||||
::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile);
|
::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile);
|
||||||
|
|
||||||
|
@ -162,14 +165,14 @@ bool cmCTestSubmit::SubmitUsingFTP(const std::string& localprefix,
|
||||||
fclose(ftpfile);
|
fclose(ftpfile);
|
||||||
if ( res )
|
if ( res )
|
||||||
{
|
{
|
||||||
std::cout << "Error when uploading" << std::endl;
|
std::cout << " Error when uploading file: " << local_file.c_str() << std::endl;
|
||||||
::curl_easy_cleanup(curl);
|
::curl_easy_cleanup(curl);
|
||||||
::curl_global_cleanup();
|
::curl_global_cleanup();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// always cleanup
|
// always cleanup
|
||||||
::curl_easy_cleanup(curl);
|
::curl_easy_cleanup(curl);
|
||||||
std::cout << "Uploaded: " + local_file << std::endl;
|
std::cout << " Uploaded: " + local_file << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
::curl_global_cleanup();
|
::curl_global_cleanup();
|
||||||
|
@ -178,11 +181,10 @@ bool cmCTestSubmit::SubmitUsingFTP(const std::string& localprefix,
|
||||||
|
|
||||||
// Uploading files is simpler
|
// Uploading files is simpler
|
||||||
bool cmCTestSubmit::SubmitUsingHTTP(const std::string& localprefix,
|
bool cmCTestSubmit::SubmitUsingHTTP(const std::string& localprefix,
|
||||||
const std::vector<std::string>& files,
|
const std::vector<std::string>& files,
|
||||||
const std::string& remoteprefix,
|
const std::string& remoteprefix,
|
||||||
const std::string& url)
|
const std::string& url)
|
||||||
{
|
{
|
||||||
std::cout << this << " Using proxy: " << m_HTTPProxy << std::endl;
|
|
||||||
CURL *curl;
|
CURL *curl;
|
||||||
CURLcode res;
|
CURLcode res;
|
||||||
FILE* ftpfile;
|
FILE* ftpfile;
|
||||||
|
@ -204,14 +206,14 @@ bool cmCTestSubmit::SubmitUsingHTTP(const std::string& localprefix,
|
||||||
curl_easy_setopt(curl, CURLOPT_PROXY, m_HTTPProxy.c_str());
|
curl_easy_setopt(curl, CURLOPT_PROXY, m_HTTPProxy.c_str());
|
||||||
switch (m_HTTPProxyType)
|
switch (m_HTTPProxyType)
|
||||||
{
|
{
|
||||||
case 2:
|
case 2:
|
||||||
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,19 +237,19 @@ bool cmCTestSubmit::SubmitUsingHTTP(const std::string& localprefix,
|
||||||
hex[0] = c;
|
hex[0] = c;
|
||||||
switch ( c )
|
switch ( c )
|
||||||
{
|
{
|
||||||
case '+':
|
case '+':
|
||||||
case '?':
|
case '?':
|
||||||
case '/':
|
case '/':
|
||||||
case '\\':
|
case '\\':
|
||||||
case '&':
|
case '&':
|
||||||
case ' ':
|
case ' ':
|
||||||
case '=':
|
case '=':
|
||||||
case '%':
|
case '%':
|
||||||
sprintf(hex, "%%%02X", (int)c);
|
sprintf(hex, "%%%02X", (int)c);
|
||||||
ofile.append(hex);
|
ofile.append(hex);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ofile.append(hex);
|
ofile.append(hex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::string upload_as = url + "?FileName=" + ofile;
|
std::string upload_as = url + "?FileName=" + ofile;
|
||||||
|
@ -261,11 +263,11 @@ bool cmCTestSubmit::SubmitUsingHTTP(const std::string& localprefix,
|
||||||
ftpfile = ::fopen(local_file.c_str(), "rb");
|
ftpfile = ::fopen(local_file.c_str(), "rb");
|
||||||
if ( m_Verbose )
|
if ( m_Verbose )
|
||||||
{
|
{
|
||||||
std::cout << "upload file: " << local_file.c_str() << " to "
|
std::cout << " Upload file: " << local_file.c_str() << " to "
|
||||||
<< upload_as.c_str() << " Size: " << st.st_size << std::endl;
|
<< upload_as.c_str() << " Size: " << st.st_size << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// specify target
|
// specify target
|
||||||
::curl_easy_setopt(curl,CURLOPT_URL, upload_as.c_str());
|
::curl_easy_setopt(curl,CURLOPT_URL, upload_as.c_str());
|
||||||
|
|
||||||
|
@ -281,13 +283,14 @@ bool cmCTestSubmit::SubmitUsingHTTP(const std::string& localprefix,
|
||||||
fclose(ftpfile);
|
fclose(ftpfile);
|
||||||
if ( res )
|
if ( res )
|
||||||
{
|
{
|
||||||
std::cout << "Error when uploading" << std::endl;
|
std::cout << " Error when uploading file: " << local_file.c_str() << std::endl;
|
||||||
::curl_easy_cleanup(curl);
|
::curl_easy_cleanup(curl);
|
||||||
::curl_global_cleanup();
|
::curl_global_cleanup();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// always cleanup
|
// always cleanup
|
||||||
::curl_easy_cleanup(curl);
|
::curl_easy_cleanup(curl);
|
||||||
|
std::cout << " Uploaded: " + local_file << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
::curl_global_cleanup();
|
::curl_global_cleanup();
|
||||||
|
@ -295,14 +298,14 @@ bool cmCTestSubmit::SubmitUsingHTTP(const std::string& localprefix,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmCTestSubmit::TriggerUsingHTTP(const std::vector<std::string>& files,
|
bool cmCTestSubmit::TriggerUsingHTTP(const std::vector<std::string>& files,
|
||||||
const std::string& remoteprefix,
|
const std::string& remoteprefix,
|
||||||
const std::string& url)
|
const std::string& url)
|
||||||
{
|
{
|
||||||
CURL *curl;
|
CURL *curl;
|
||||||
|
|
||||||
/* In windows, this will init the winsock stuff */
|
/* In windows, this will init the winsock stuff */
|
||||||
::curl_global_init(CURL_GLOBAL_ALL);
|
::curl_global_init(CURL_GLOBAL_ALL);
|
||||||
|
|
||||||
std::string::size_type cc, kk;
|
std::string::size_type cc, kk;
|
||||||
for ( cc = 0; cc < files.size(); cc ++ )
|
for ( cc = 0; cc < files.size(); cc ++ )
|
||||||
{
|
{
|
||||||
|
@ -316,14 +319,14 @@ bool cmCTestSubmit::TriggerUsingHTTP(const std::vector<std::string>& files,
|
||||||
curl_easy_setopt(curl, CURLOPT_PROXY, m_HTTPProxy.c_str());
|
curl_easy_setopt(curl, CURLOPT_PROXY, m_HTTPProxy.c_str());
|
||||||
switch (m_HTTPProxyType)
|
switch (m_HTTPProxyType)
|
||||||
{
|
{
|
||||||
case 2:
|
case 2:
|
||||||
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
|
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,30 +344,30 @@ bool cmCTestSubmit::TriggerUsingHTTP(const std::vector<std::string>& files,
|
||||||
hex[0] = c;
|
hex[0] = c;
|
||||||
switch ( c )
|
switch ( c )
|
||||||
{
|
{
|
||||||
case '+':
|
case '+':
|
||||||
case '?':
|
case '?':
|
||||||
case '/':
|
case '/':
|
||||||
case '\\':
|
case '\\':
|
||||||
case '&':
|
case '&':
|
||||||
case ' ':
|
case ' ':
|
||||||
case '=':
|
case '=':
|
||||||
case '%':
|
case '%':
|
||||||
sprintf(hex, "%%%02X", (int)c);
|
sprintf(hex, "%%%02X", (int)c);
|
||||||
ofile.append(hex);
|
ofile.append(hex);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ofile.append(hex);
|
ofile.append(hex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::string turl = url + "?xmlfile=" + ofile;
|
std::string turl = url + "?xmlfile=" + ofile;
|
||||||
if ( m_Verbose )
|
if ( m_Verbose )
|
||||||
{
|
{
|
||||||
std::cout << "Trigger url: " << turl.c_str() << std::endl;
|
std::cout << " Trigger url: " << turl.c_str() << std::endl;
|
||||||
}
|
}
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, turl.c_str());
|
curl_easy_setopt(curl, CURLOPT_URL, turl.c_str());
|
||||||
if ( curl_easy_perform(curl) )
|
if ( curl_easy_perform(curl) )
|
||||||
{
|
{
|
||||||
std::cout << "Error when uploading" << std::endl;
|
std::cout << " Error when triggering: " << turl.c_str() << std::endl;
|
||||||
::curl_easy_cleanup(curl);
|
::curl_easy_cleanup(curl);
|
||||||
::curl_global_cleanup();
|
::curl_global_cleanup();
|
||||||
return false;
|
return false;
|
||||||
|
@ -375,14 +378,14 @@ bool cmCTestSubmit::TriggerUsingHTTP(const std::vector<std::string>& files,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
::curl_global_cleanup();
|
::curl_global_cleanup();
|
||||||
std::cout << "Dart server triggered..." << std::endl;
|
std::cout << " Dart server triggered..." << std::endl;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmCTestSubmit::SubmitUsingSCP(const std::string&,
|
bool cmCTestSubmit::SubmitUsingSCP(const std::string&,
|
||||||
const std::vector<std::string>&,
|
const std::vector<std::string>&,
|
||||||
const std::string&,
|
const std::string&,
|
||||||
const std::string&)
|
const std::string&)
|
||||||
{
|
{
|
||||||
std::cout << "SubmitUsingSCP is not yet implemented" << std::endl;
|
std::cout << "SubmitUsingSCP is not yet implemented" << std::endl;
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1919,7 +1919,7 @@ int cmCTest::SubmitResults()
|
||||||
if ( m_DartConfiguration["DropMethod"] == "" ||
|
if ( m_DartConfiguration["DropMethod"] == "" ||
|
||||||
m_DartConfiguration["DropMethod"] == "ftp" )
|
m_DartConfiguration["DropMethod"] == "ftp" )
|
||||||
{
|
{
|
||||||
std::cout << "FTP submit method" << std::endl;
|
std::cout << " Using FTP submit method" << std::endl;
|
||||||
std::string url = "ftp://";
|
std::string url = "ftp://";
|
||||||
url += cmCTest::MakeURLSafe(m_DartConfiguration["DropSiteUser"]) + ":" +
|
url += cmCTest::MakeURLSafe(m_DartConfiguration["DropSiteUser"]) + ":" +
|
||||||
cmCTest::MakeURLSafe(m_DartConfiguration["DropSitePassword"]) + "@" +
|
cmCTest::MakeURLSafe(m_DartConfiguration["DropSitePassword"]) + "@" +
|
||||||
|
@ -1928,17 +1928,20 @@ int cmCTest::SubmitResults()
|
||||||
if ( !submit.SubmitUsingFTP(m_ToplevelPath+"/Testing/"+m_CurrentTag,
|
if ( !submit.SubmitUsingFTP(m_ToplevelPath+"/Testing/"+m_CurrentTag,
|
||||||
files, prefix, url) )
|
files, prefix, url) )
|
||||||
{
|
{
|
||||||
|
std::cout << " Problems when submitting via FTP" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ( !submit.TriggerUsingHTTP(files, prefix, m_DartConfiguration["TriggerSite"]) )
|
if ( !submit.TriggerUsingHTTP(files, prefix, m_DartConfiguration["TriggerSite"]) )
|
||||||
{
|
{
|
||||||
|
std::cout << " Problems when triggering via HTTP" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
std::cout << " Submission successfull" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if ( m_DartConfiguration["DropMethod"] == "http" )
|
else if ( m_DartConfiguration["DropMethod"] == "http" )
|
||||||
{
|
{
|
||||||
std::cout << "HTTP submit method" << std::endl;
|
std::cout << " Using HTTP submit method" << std::endl;
|
||||||
std::string url = "http://";
|
std::string url = "http://";
|
||||||
if ( m_DartConfiguration["DropSiteUser"].size() > 0 )
|
if ( m_DartConfiguration["DropSiteUser"].size() > 0 )
|
||||||
{
|
{
|
||||||
|
@ -1952,13 +1955,15 @@ int cmCTest::SubmitResults()
|
||||||
url += m_DartConfiguration["DropSite"] + m_DartConfiguration["DropLocation"];
|
url += m_DartConfiguration["DropSite"] + m_DartConfiguration["DropLocation"];
|
||||||
if ( !submit.SubmitUsingHTTP(m_ToplevelPath+"/Testing/"+m_CurrentTag, files, prefix, url) )
|
if ( !submit.SubmitUsingHTTP(m_ToplevelPath+"/Testing/"+m_CurrentTag, files, prefix, url) )
|
||||||
{
|
{
|
||||||
|
std::cout << " Problems when submitting via HTTP" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if ( !submit.TriggerUsingHTTP(files, prefix, m_DartConfiguration["TriggerSite"]) )
|
if ( !submit.TriggerUsingHTTP(files, prefix, m_DartConfiguration["TriggerSite"]) )
|
||||||
{
|
{
|
||||||
|
std::cout << " Problems when triggering via HTTP" << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
std::cout << "Submission successfull" << std::endl;
|
std::cout << " Submission successfull" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue