Skip to content

Commit

Permalink
Resolves #3741. Fixed the issue with installing host profiles after
Browse files Browse the repository at this point in the history
moving or deleting the .visit directory while VisIt is running.
  • Loading branch information
Kevin Griffin committed Nov 8, 2019
1 parent 0f280cb commit 9a0eed3
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 37 deletions.
22 changes: 22 additions & 0 deletions src/common/misc/InstallationFunctions.C
Expand Up @@ -403,6 +403,28 @@ GetAndMakeUserVisItHostsDirectory()
return retval;
}

// ****************************************************************************
// Method: GetVisItHostsDirectory
//
// Purpose:
// Returns only the path to the user's .visit directory's host subdirectory.
// Doesn't try to create the directory like
// GetAndMakeUserVisItHostsDirectory.
//
// Arguments:
// none
//
// Programmer: Kevin Griffin
// Creation: November 07, 2019
//
// ****************************************************************************
std::string
GetVisItHostsDirectory()
{
std::string retval = GetUserVisItDirectory() + "hosts";
return retval;
}

// ****************************************************************************
// Method: GetUserVisItHostsDirectory
//
Expand Down
1 change: 1 addition & 0 deletions src/common/misc/InstallationFunctions.h
Expand Up @@ -66,6 +66,7 @@ std::string MISC_API GetUserVisItRCFile();
std::string MISC_API GetSystemVisItRCFile();

std::string MISC_API GetAndMakeUserVisItHostsDirectory();
std::string MISC_API GetVisItHostsDirectory();
std::string MISC_API GetSystemVisItHostsDirectory();

typedef enum {
Expand Down
106 changes: 69 additions & 37 deletions src/gui/QvisSetupHostProfilesAndConfigWindow.C
Expand Up @@ -52,6 +52,7 @@
#include <QVBoxLayout>

#include <InstallationFunctions.h>
#include <DebugStream.h>

// ****************************************************************************
// Method: QvisSetupHostProfilesAndConfigWindow::QvisSetupHostProfilesAndConfigWindow
Expand Down Expand Up @@ -248,6 +249,10 @@ QvisSetupHostProfilesAndConfigWindow::readDefaultConfigList()
//
// Modifications:
//
// Kevin Griffin, Thu Nov 7 17:43:56 PST 2019
// Added a check to see if the files were successfully copied. If not, a
// debug log message is generated to aid in troubleshooting.
//
// ****************************************************************************

void
Expand All @@ -271,7 +276,11 @@ QvisSetupHostProfilesAndConfigWindow::installConfigFile(const QString& srcFilena
}

// Note: Copy will not overwrite existing files
QFile::copy(srcFilename, destFilename);
bool success = QFile::copy(srcFilename, destFilename);
if(!success)
{
debug1 << "Installing " << srcFilename.toStdString() << " to " << destFilename.toStdString() << " was not successful" << endl;
}
}

// ****************************************************************************
Expand All @@ -296,59 +305,82 @@ QvisSetupHostProfilesAndConfigWindow::installConfigFile(const QString& srcFilena
// Mark C. Miller, Mon Sep 17 08:46:24 PDT 2012
// Fixed leak from using GetDefaultConfigFile directly as arg
// in installConfigFile.
//
// Kevin Griffin, Thu Nov 7 17:43:56 PST 2019
// In rare cases when the user moves or deletes their .visit directory
// all the directories in the path need to be recreated. The call to mkdir
// in the previous GetAndMakeUserVisItHostsDirectory called didn't do that
// and there were no checks for successful creation of the hosts directory.
// The call to get the hosts directory was split from making the directory
// so mkpath could be used to create all the parent directories if needed.
// Successful creation is now checked and if it fails the appropriate debug
// log message is created.
//
// ****************************************************************************

void
QvisSetupHostProfilesAndConfigWindow::performSetup()
{
QString hostsInstallDirectory =
QString::fromStdString(GetAndMakeUserVisItHostsDirectory());

for (std::list<NetworkInfo>::iterator it = networkList.begin();
it != networkList.end(); ++it)
QString::fromStdString(GetVisItHostsDirectory());

// mkpath will create all parent directories necessary to create the directory
// this is needed in rare cases where the .visit directory is deleted or moved and the
// user wants to install the hosts profiles.
QDir dir;
bool success = dir.mkpath(hostsInstallDirectory);
if(success)
{
if (it->checkBox->isChecked())
for (std::list<NetworkInfo>::iterator it = networkList.begin();
it != networkList.end(); ++it)
{
QString srcDir(GetVisItResourcesFile(VISIT_RESOURCES_HOSTS,
it->shortName.toStdString()).c_str());
QDir srcHostProfileDir(srcDir, "host*.xml");
QStringList files = srcHostProfileDir.entryList();
for (int i = 0; i < files.size(); ++ i)
if (it->checkBox->isChecked())
{
const QString &thisProfile = files.at(i);
installConfigFile(srcDir + "/" + thisProfile,
hostsInstallDirectory + "/" + thisProfile);
QString srcDir(GetVisItResourcesFile(VISIT_RESOURCES_HOSTS,
it->shortName.toStdString()).c_str());
QDir srcHostProfileDir(srcDir, "host*.xml");
QStringList files = srcHostProfileDir.entryList();
for (int i = 0; i < files.size(); ++ i)
{
const QString &thisProfile = files.at(i);
installConfigFile(srcDir + "/" + thisProfile,
hostsInstallDirectory + "/" + thisProfile);
}
}
}
}
for (std::list<DefaultConfigInfo>::iterator it = defaultConfigList.begin();
it != defaultConfigList.end(); ++it)
{
if (it->radioButton->isChecked())
for (std::list<DefaultConfigInfo>::iterator it = defaultConfigList.begin();
it != defaultConfigList.end(); ++it)
{
const char *configFilename[] = {
"config", "guiconfig", "visitrc", 0 };

for (int i = 0; configFilename[i] != 0; ++i)
if (it->radioButton->isChecked())
{
std::string srcCfgName =
it->shortName.toStdString() +
"/" + std::string(configFilename[i]);
QString srcCfgPath(GetVisItResourcesFile(VISIT_RESOURCES_HOSTS, srcCfgName).c_str());
if (QFile::exists(srcCfgPath))
const char *configFilename[] = {
"config", "guiconfig", "visitrc", 0 };

for (int i = 0; configFilename[i] != 0; ++i)
{
char *srcCfgFile = GetDefaultConfigFile(configFilename[i]);
installConfigFile(srcCfgPath, srcCfgFile);
delete [] srcCfgFile;
std::string srcCfgName =
it->shortName.toStdString() +
"/" + std::string(configFilename[i]);
QString srcCfgPath(GetVisItResourcesFile(VISIT_RESOURCES_HOSTS, srcCfgName).c_str());
if (QFile::exists(srcCfgPath))
{
char *srcCfgFile = GetDefaultConfigFile(configFilename[i]);
installConfigFile(srcCfgPath, srcCfgFile);
delete [] srcCfgFile;
}
}
}
}
}

QMessageBox msgBox;
msgBox.setText(tr("Host profiles and configuration files have been installed"
" and will be available after VisIt is restarted."));
msgBox.exec();
QMessageBox msgBox;
msgBox.setText(tr("Host profiles and configuration files have been installed"
" and will be available after VisIt is restarted."));
msgBox.exec();

close();
close();
}
else
{
debug1 << "Hosts directory (" << hostsInstallDirectory.toStdString() << ") was not successfully created." << endl;
}
}
1 change: 1 addition & 0 deletions src/resources/help/en_US/relnotes3.0.3.html
Expand Up @@ -27,6 +27,7 @@
<li>Fixed bug with VTK reader parsing .vtm files when 'DataSet' tag doesn't have a 'file' attribute.</li>
<li>Disable VCR play/reverse play buttons when there is not active drawn plot.</li>
<li>Fixed inability to Pick on glyphed points lying near the dataset bounds.</li>
<li>Fixed the issue with installing host profiles after deleting or moving the .visit folder while VisIt is running.</li>
</ul>

<a name="Enhancements"></a>
Expand Down

0 comments on commit 9a0eed3

Please sign in to comment.