Skip to content

Copy CP2K provided basis set directory to installdir, and use it#996

Merged
boegel merged 5 commits intoeasybuilders:developfrom
hajgato:cp2k_data
Jan 17, 2017
Merged

Copy CP2K provided basis set directory to installdir, and use it#996
boegel merged 5 commits intoeasybuilders:developfrom
hajgato:cp2k_data

Conversation

@hajgato
Copy link
Copy Markdown
Collaborator

@hajgato hajgato commented Sep 20, 2016

No description provided.

Comment thread easybuild/easyblocks/c/cp2k.py Outdated
try:
shutil.copytree(datadir, targetdir)
except:
raise EasyBuildError("Copying tests from %s to %s failed", srctests, targetdir)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@hajgato positive logic is easier to follow, srctests doesn't exist, please use except OSError and include actual error in error message, so:

if os.path.exists(targetdir):
    self.log.info("Won't copy data dir. Destination directory %s already exists", targetdir)
elif os.path.exists(datadir):
    try:
        shutil.copytree(datadir, targetdir)
    except OSError as err:
        raise EasyBuildError("Copying tests from %s to %s failed: %s", datadir, targetdir, err)
else:
    self.log.info("Won't copy data dir. Source directory %s does not exist", datadir)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done

Comment thread easybuild/easyblocks/c/cp2k.py Outdated
txt = super(EB_CP2K, self).make_module_extra()
if os.path.exists(os.path.join(self.installdir, 'data')):
txt += self.module_generator.set_environment('CP2K_DATA_DIR',
os.path.join(self.installdir, 'data'))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@hajgato if you need a value multiple times, it's cleaner to just construct it once:

data_dir = os.path.join(self.installdir, 'data')
if os.path.exists(data_dir):
    txt += self.module_generator.set_environment('CP2K_DATA_DIR', data_dir)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

done

@boegel boegel added this to the v3.0 milestone Sep 20, 2016
Copy link
Copy Markdown
Collaborator Author

@hajgato hajgato left a comment

Choose a reason for hiding this comment

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

requested changes implemented

Comment thread easybuild/easyblocks/c/cp2k.py Outdated
try:
shutil.copytree(datadir, targetdir)
except:
raise EasyBuildError("Copying data dir from %s to %s failed", srctests, targetdir)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@hajgato this is still wrong, where does srctests come from, this should be datadir?
also, mention the error in the message:

except OSError as err:
    raise EasyBuildError("Copying data dir from %s to %s failed", datadir, targetdir)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@boegel It comes from copy paste ;)
Anyway, I corrected it

@boegel boegel modified the milestones: v3.1, v3.0 Nov 13, 2016
@boegel
Copy link
Copy Markdown
Member

boegel commented Jan 17, 2017

merged via #1084, thanks @hajgato!

@hajgato hajgato deleted the cp2k_data branch June 8, 2017 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants