Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the issue with installing host profiles after moving .visit directory #4026

Merged
merged 2 commits into from
Nov 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/common/misc/InstallationFunctions.C
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
112 changes: 75 additions & 37 deletions src/gui/QvisSetupHostProfilesAndConfigWindow.C
Original file line number Diff line number Diff line change
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,88 @@ 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;

QMessageBox msgBox;
msgBox.setText(tr("Error: Host profiles and configuration files have not been installed. See debug logs for more information."));
msgBox.exec();

close();
}
}
1 change: 1 addition & 0 deletions src/resources/help/en_US/relnotes3.0.3.html
Original file line number Diff line number Diff line change
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>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the "while VisIt is running" necessary.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized that VisIt probably creates the ".visit" directory when it runs, so the only way it can be missing is if it deleted or moved while VisIt is running, so the clause is appropriate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes...this issue only happened when VisIt was running since the parent directories need to be recreated which mkdir didn't do. If the .visit dir is moved when VisIt is not running, during startup VisIt would create the parent directories.

</ul>

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