Commit f5c36343 authored by whitlocb's avatar whitlocb

Fix the "visit update" feature in the help menu.



git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@16600 18c085ea-50e0-402c-830e-de6fd14e8384
parent 0ce1cfd1
......@@ -615,6 +615,9 @@ GetIsDevelopmentVersion()
// On Windows, if VISISTHOME not defined in registry, check environment
// before getting the module path.
//
// Brad Whitlock, Mon Oct 31 15:26:04 PDT 2011
// Strip off Mac bundle path.
//
// ****************************************************************************
std::string
......@@ -678,6 +681,16 @@ GetVisItInstallationDirectory(const char *version)
installDir = home.substr(0, lastSlash);
else
installDir = idir;
#ifdef __APPLE__
// If we're using a Mac bundle, strip off some more stuff for the
// installation directory since we would not want to install into
// another bundle.
std::string bundlePath("VisIt.app/Contents/Resources");
int bp = home.rfind(bundlePath);
if(bp != -1)
installDir = home.substr(0, bp);
#endif
}
}
return installDir;
......@@ -808,7 +821,10 @@ GetVisItLauncher()
//
// Tom Fogal, Sun Apr 19 12:48:38 MST 2009
// Use `Environment' to simplify and fix a compilation error.
//
//
// Brad Whitlock, Mon Oct 31 15:05:20 PDT 2011
// darwin-x86_64 enhancements.
//
// ****************************************************************************
bool
......@@ -829,8 +845,10 @@ ReadInstallationInfo(std::string &distName, std::string &configName, std::string
"linux-ia64",
"darwin-i386",
"darwin-ppc",
"darwin-x86_64",
// Deprecated
"darwin-ppc",
"sun4-sunos5-sparc",
"ibm-aix-pwr",
......@@ -838,7 +856,6 @@ ReadInstallationInfo(std::string &distName, std::string &configName, std::string
"sgi-irix6-mips2",
// Deprecated
"dec-osf1-alpha",
};
......@@ -857,8 +874,10 @@ ReadInstallationInfo(std::string &distName, std::string &configName, std::string
"linux-altix",
"darwin-i386",
"darwin-ppc",
"darwin-x86_64",
// Deprecated
"darwin-ppc",
"sunos5",
"aix",
......@@ -866,7 +885,6 @@ ReadInstallationInfo(std::string &distName, std::string &configName, std::string
"irix6",
// Deprecated
"osf1",
};
......@@ -947,6 +965,17 @@ ReadInstallationInfo(std::string &distName, std::string &configName, std::string
}
}
}
#ifdef __APPLE__
if(!platformDetermined)
{
if(sizeof(long) == 8)
distName = "darwin-x86_64";
else
distName = "darwin-i386";
platformDetermined = true;
}
#endif
}
return platformDetermined;
......
......@@ -39,11 +39,7 @@
#include <QByteArray>
#include <QFile>
#include <QHttp>
#include <QPushButton>
#include <QLayout>
#define VISIT_DOWNLOAD_URL "wci.llnl.gov"
#include <QNetworkReply>
// ****************************************************************************
// Method: QvisDownloader::QvisDownloader
......@@ -58,31 +54,19 @@
// Creation: Thu Oct 2 10:28:55 PDT 2008
//
// Modifications:
// Brad Whitlock, Tue Nov 1 13:02:42 PDT 2011
// Rewrite.
//
// ****************************************************************************
QvisDownloader::QvisDownloader(QObject *parent) : QObject(parent)
{
file = 0;
bytes = 0;
file = NULL;
bytes = NULL;
http = new QHttp(this);
#ifdef DEBUG_VISIT_DOWNLOADER
connect(http, SIGNAL(requestStarted(int)),
this, SLOT(requestStarted(int)));
connect(http, SIGNAL(requestFinished(int,bool)),
this, SLOT(requestFinished(int,bool)));
connect(http, SIGNAL(stateChanged(int)),
this, SLOT(stateChanged(int)));
#endif
connect(http, SIGNAL(dataReadProgress(int,int)),
this, SIGNAL(downloadProgress(int,int)));
connect(http, SIGNAL(readyRead(const QHttpResponseHeader &)),
this, SLOT(readyRead(const QHttpResponseHeader &)));
connect(http, SIGNAL(done(bool)),
this, SLOT(httpdone(bool)));
connect(http, SIGNAL(sslErrors(const QList<QSslError> &)),
this, SLOT(sslErrors(const QList<QSslError> &)));
manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply *)),
this, SLOT(finished(QNetworkReply *)));
}
// ****************************************************************************
......@@ -121,17 +105,22 @@ QvisDownloader::~QvisDownloader()
// Creation: Thu Oct 2 10:35:28 PDT 2008
//
// Modifications:
// Brad Whitlock, Tue Nov 1 13:02:42 PDT 2011
// Rewrite.
//
// ****************************************************************************
bool
QvisDownloader::get(const QString &remoteFile, QByteArray *b)
QvisDownloader::get(const QUrl &url, QByteArray *b)
{
file = 0;
QNetworkRequest request(url);
QNetworkReply *reply = manager->get(request);
connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
this, SIGNAL(downloadProgress(qint64,qint64)));
bytes = b;
file = NULL;
http->setHost(VISIT_DOWNLOAD_URL, QHttp::ConnectionModeHttps);
http->get(remoteFile);
return true;
}
......@@ -153,24 +142,29 @@ QvisDownloader::get(const QString &remoteFile, QByteArray *b)
// Creation: Thu Oct 2 10:35:28 PDT 2008
//
// Modifications:
//
// Brad Whitlock, Tue Nov 1 13:02:42 PDT 2011
// Rewrite.
//
// ****************************************************************************
bool
QvisDownloader::get(const QString &remoteFile, const QString &localFile)
QvisDownloader::get(const QUrl &url, const QString &localFile)
{
bytes = 0;
bytes = NULL;
file = new QFile(localFile);
if (!file->open(QIODevice::WriteOnly))
{
delete file;
file = 0;
file = NULL;
return false;
}
http->setHost(VISIT_DOWNLOAD_URL, QHttp::ConnectionModeHttps);
http->get(remoteFile, file);
QNetworkRequest request(url);
QNetworkReply *reply = manager->get(request);
connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
this, SIGNAL(downloadProgress(qint64,qint64)));
return true;
}
......@@ -179,165 +173,47 @@ QvisDownloader::get(const QString &remoteFile, const QString &localFile)
//
// ****************************************************************************
// Method: QvisDownloader::readyRead
// Method: QvisDownloader::finished
//
// Purpose:
// This Qt slot function is called when there is new data to be read from
// the http object. We use this occasion to save off the bytes if we're
// storing them in a byte array.
// This method gets called when our network request is finished.
//
// Arguments:
// reply : The network reply.
//
// Returns:
//
// Note:
//
// Programmer: Brad Whitlock
// Creation: Thu Oct 2 10:40:37 PDT 2008
//
// Modifications:
//
// ****************************************************************************
void
QvisDownloader::readyRead(const QHttpResponseHeader &responseHeader)
{
#ifdef DEBUG_VISIT_DOWNLOADER
qDebug("readyRead()");
#endif
switch (responseHeader.statusCode())
{
case 200: // Ok
case 301: // Moved Permanently
case 302: // Found
case 303: // See Other
case 307: // Temporary Redirect
// these are not error conditions
if(bytes != 0)
bytes->append(http->readAll());
break;
default:
#ifdef DEBUG_VISIT_DOWNLOADER
qDebug("Read aborted: %s", responseHeader.reasonPhrase().toStdString().c_str());
#endif
http->abort();
if(bytes != 0)
bytes->clear();
}
}
// ****************************************************************************
// Method: QvisDownloader::httpdone
//
// Purpose:
// This Qt slot function is called when the http object is done processing
// the get request.
//
// Arguments:
// error : True if an error occurred during download.
//
// Programmer: Brad Whitlock
// Creation: Thu Oct 2 10:41:46 PDT 2008
// Creation: Tue Nov 1 13:02:57 PDT 2011
//
// Modifications:
//
// ****************************************************************************
void
QvisDownloader::httpdone(bool error)
QvisDownloader::finished(QNetworkReply *reply)
{
#ifdef DEBUG_VISIT_DOWNLOADER
qDebug("done(%s)", error?"true":"false");
#endif
if(file != 0)
{
file->close();
file = 0;
}
bytes = 0;
emit done(error);
}
disconnect(reply, SIGNAL(downloadProgress(qint64,qint64)),
this, SIGNAL(downloadProgress(qint64,qint64)));
// ****************************************************************************
// Method: QvisDownloader::sslErrors
//
// Purpose:
// This Qt slot function is called when there are SSL concerns during a
// download. We just tell the http object to ignore those errors and
// keep going.
//
// Arguments:
// errors : The SSL errors that have occurred.
//
// Programmer: Brad Whitlock
// Creation: Thu Oct 2 10:42:50 PDT 2008
//
// Modifications:
//
// ****************************************************************************
void
QvisDownloader::sslErrors(const QList<QSslError> &errors)
{
#ifndef QT_NO_OPENSSL
#ifdef DEBUG_VISIT_DOWNLOADER
qDebug("sslErrors()");
QString errorString;
foreach (const QSslError &error, errors)
if(!reply->error())
{
if (!errorString.isEmpty())
errorString += ", ";
errorString += error.errorString();
if(bytes != NULL)
{
*bytes = reply->readAll();
bytes = NULL;
}
if(file != NULL)
{
file->write(reply->readAll());
file->close();
}
bytes = NULL;
file = NULL;
}
qDebug("SSL Errors: %s", errorString.toStdString().c_str());
#endif
http->ignoreSslErrors();
#endif
}
#ifdef DEBUG_VISIT_DOWNLOADER
// Keep for debugging.
void
QvisDownloader::requestStarted(int val)
{
qDebug("requestStarted(%d)", val);
}
void
QvisDownloader::requestFinished(int id, bool error)
{
qDebug("requestFinished(%d, %s)", id, error?"true":"false");
}
void
QvisDownloader::stateChanged(int state)
{
switch(state)
{
case QHttp::Unconnected:
qDebug("stateChanged(Unconnected)");
break;
case QHttp::HostLookup:
qDebug("stateChanged(HostLookup)");
break;
case QHttp::Connecting:
qDebug("stateChanged(Connecting)");
break;
case QHttp::Sending:
qDebug("stateChanged(Sending)");
break;
case QHttp::Reading:
qDebug("stateChanged(Reading)");
break;
case QHttp::Connected:
qDebug("stateChanged(Connected)");
break;
case QHttp::Closing:
qDebug("stateChanged(Closing)");
break;
}
emit done(reply->error());
}
#endif
......@@ -39,19 +39,12 @@
#ifndef QVIS_DOWNLOADER_H
#define QVIS_DOWNLOADER_H
#include <QObject>
#ifdef QT_NO_OPENSSL
// For platforms that don't have QSslError. I need to do this so I can have
// the sslErrors slot defined.
class QSslError { int a; };
#else
#include <QSslError>
#endif
#include <QByteArray>
#include <QNetworkAccessManager>
#include <QUrl>
class QByteArray;
class QFile;
class QHttp;
class QHttpResponseHeader;
class QNetworkReply;
// ****************************************************************************
// Class: QvisDownloader
......@@ -59,15 +52,13 @@ class QHttpResponseHeader;
// Purpose:
// Downloads files from the VisIt web site.
//
// Notes: This class is hard coded to download from wci.llnl.gov but
// it would be trivial to let it download from other sites
// if we later need that functionality.
//
// Programmer: Brad Whitlock
// Creation: Thu Oct 2 10:26:40 PDT 2008
//
// Modifications:
//
// Brad Whitlock, Tue Nov 1 13:03:43 PDT 2011
// I rewrote it in terms of QNetworkAccessManager.
//
// ****************************************************************************
class QvisDownloader : public QObject
......@@ -77,24 +68,17 @@ public:
QvisDownloader(QObject *parent);
virtual ~QvisDownloader();
bool get(const QString &remoteFile, QByteArray *bytes);
bool get(const QString &remoteFile, const QString &localFile);
bool get(const QUrl &url, QByteArray *bytes);
bool get(const QUrl &url, const QString &localFile);
signals:
void done(bool error);
void downloadProgress(int,int);
void downloadProgress(qint64, qint64);
private slots:
#ifdef DEBUG_VISIT_DOWNLOADER
// Keep for debugging.
void requestStarted(int);
void requestFinished(int,bool);
void stateChanged(int);
#endif
void readyRead(const QHttpResponseHeader &);
void httpdone(bool);
void sslErrors(const QList<QSslError> &);
void finished(QNetworkReply *reply);
private:
QHttp *http;
QNetworkAccessManager *manager;
QByteArray *bytes;
QFile *file;
};
......
......@@ -54,8 +54,8 @@
#include <DebugStream.h>
#include <InstallationFunctions.h>
#define STAGE_SUBMIT_RUNINFO 0
#define STAGE_DETERMINE_VERSION 1
#define STAGE_DETERMINE_VERSION 0
#define STAGE_DETERMINE_DOWNLOAD 1
#define STAGE_GET_FILES 2
#define STAGE_INSTALL 3
#define STAGE_CLEAN_UP 4
......@@ -63,15 +63,11 @@
#define CURRENT_VERSION VISIT_VERSION
#ifdef QT_NO_OPENSSL
#define EXECUTABLE_HTML "/codes/visit/executables.html"
#define HTTPS_EXECUTABLE_HTML "https://wci.llnl.gov" EXECUTABLE_HTML
#else
// We don't have SSL so we can't download from our own website.
// Thanks a lot LLNL. Try a mirror site.
#define EXECUTABLE_HTML "/visit/executables.html"
#define HTTPS_EXECUTABLE_HTML "http://www.visitusers.org" EXECUTABLE_HTML
#endif
#define NERSC_RELEASE_HTML "http://portal.nersc.gov/svn/visit/trunk/releases/"
#define LLNL "https://wci.llnl.gov/"
#define LLNL_EXECUTABLE_HTML LLNL "codes/visit/executables.html"
#define LLNL_CODES LLNL "codes/visit"
// There seems to be a QProcess bug on Apple so let's try a workaround.
#ifdef __APPLE__
......@@ -105,10 +101,9 @@
QvisVisItUpdate::QvisVisItUpdate(QObject *parent) : QObject(parent), GUIBase(),
distName(), configName("none"), bankName("bdivp"),
latestVersion(CURRENT_VERSION),
files(), downloads(), bytes()
latestVersion(CURRENT_VERSION), files(), downloads(), bytes()
{
stage = STAGE_SUBMIT_RUNINFO;
stage = STAGE_DETERMINE_VERSION;
downloader = 0;
installProcess = 0;
}
......@@ -135,42 +130,6 @@ QvisVisItUpdate::~QvisVisItUpdate()
{
}
// ****************************************************************************
// Method: QvisVisItUpdate::runInformationString
//
// Purpose:
// This class provides the ftp login for the VisIt FTP site.
//
// Returns: A bogus filename that contains a little run information.
//
// Programmer: Brad Whitlock
// Creation: Tue Feb 15 12:23:38 PDT 2005
//
// Modifications:
//
// ****************************************************************************
QString
QvisVisItUpdate::runInformationString() const
{
#if defined(_WIN32)
const char *platform = "win32";
#else
const char *platform = distName.isEmpty() ? "?" : distName.toStdString().c_str();
#endif
// Get the number of startups.
ConfigStateEnum code;
int nStartups = ConfigStateGetRunCount(code);
QString runinfo;
runinfo.sprintf("/codes/visit/visit_update_%s_%s_%d", CURRENT_VERSION,
platform, nStartups);
return runinfo;
}
// ****************************************************************************
// Method: QvisVisItUpdate::localTempDirectory
//
......@@ -243,6 +202,9 @@ QvisVisItUpdate::getInstallationDir() const
// Brad Whitlock, Thu Oct 2 14:10:44 PDT 2008
// Qt 4.
//
// Brad Whitlock, Tue Nov 1 13:09:15 PDT 2011
// Support bundles.
//
// ****************************************************************************
void
......@@ -275,36 +237,47 @@ QvisVisItUpdate::installVisIt()
// Install VisIt the WIN32 way by running the visit installer.
QString installer(files.front());
#else
// Install VisIt the UNIX way.
QString visit_install(files.front());
QFile::setPermissions(visit_install, QFile::ReadOwner |
QFile::WriteOwner | QFile::ExeOwner);
// Get the VisIt installation directory.
QString installDir(getInstallationDir());
// Create an installation process that will run visit-install.
QString installer(visit_install);
// Add installer arguments.
installerArgs.append("-c");
installerArgs.append(configName);
installerArgs.append("-b");
installerArgs.append(bankName);
installerArgs.append(latestVersion);
installerArgs.append(distName);
installerArgs.append(installDir);
connect(installProcess, SIGNAL(readyReadStandardOutput()),
this, SLOT(readInstallerStdout()));
connect(installProcess, SIGNAL(readyReadStandardError()),
this, SLOT(readInstallerStderr()));
debug1 << "Going to run: visit-install -c "
<< configName.toStdString()
<< " -b " << bankName.toStdString() << " "
<< latestVersion.toStdString() << " "
<< distName.toStdString() << " "
<< installDir.toStdString() << endl;
QString installer;
if(files[1].endsWith(".dmg"))
{
// Assume we want to do a Mac bundle so just open the volume.
installer = "open";
installerArgs.append(files[1]);
}
else
{
// Install VisIt the UNIX way.
QString visit_install(files.front());
QFile::setPermissions(visit_install, QFile::ReadOwner |
QFile::WriteOwner | QFile::ExeOwner);
// Get the VisIt installation directory.
QString installDir(getInstallationDir());
// Create an installation process that will run visit-install.
installer = QString(visit_install);
// Add installer arguments.
installerArgs.append("-c");
installerArgs.append(configName);
installerArgs.append("-b");
installerArgs.append(bankName);
installerArgs.append(latestVersion);
installerArgs.append(distName);
installerArgs.append(installDir);
connect(installProcess, SIGNAL(readyReadStandardOutput()),
this, SLOT(readInstallerStdout()));
connect(installProcess, SIGNAL(readyReadStandardError()),
this, SLOT(readInstallerStderr()));
debug1 << "Going to run: " << visit_install.toStdString() << " -c "
<< configName.toStdString()
<< " -b " << bankName.toStdString() << " "
<< latestVersion.toStdString() << " "
<< distName.toStdString() << " "
<< installDir.toStdString() << endl;
}
#endif