protect against use with Python 2.x, use full absolute directory path internally

This commit is contained in:
Axel Kohlmeyer
2021-08-22 22:47:09 -04:00
parent bc91d05857
commit 0c7cf3cdaa
3 changed files with 26 additions and 8 deletions

View File

@ -2,8 +2,13 @@
# Utility for detecting and fixing file permission issues in LAMMPS
#
# Written by Richard Berger (Temple University)
import os
from __future__ import print_function
import sys
if sys.version_info.major < 3:
sys.exit('This script must be run with Python 3.x')
import os
import glob
import yaml
import argparse
@ -82,6 +87,7 @@ def main():
parser.add_argument('-v', '--verbose', action='store_true', help='verbose output')
parser.add_argument('DIRECTORY', help='directory that should be checked')
args = parser.parse_args()
lammpsdir = os.path.abspath(os.path.expanduser(args.DIRECTORY))
if args.config:
with open(args.config, 'r') as cfile:
@ -89,7 +95,7 @@ def main():
else:
config = yaml.load(DEFAULT_CONFIG, Loader=yaml.FullLoader)
if not check_folder(args.DIRECTORY, config, args.fix, args.verbose):
if not check_folder(lammpsdir, config, args.fix, args.verbose):
sys.exit(1)
if __name__ == "__main__":