Adds Extra Parameter to Logs and Updates Version Variable
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
from crystalpol import VERSION
|
||||
from crystalpol.polarization import Polarization
|
||||
from crystalpol.shared.config import Config
|
||||
from crystalpol.shared.utils.log import Log
|
||||
|
||||
from yaml.loader import SafeLoader
|
||||
from pathlib import Path
|
||||
import setproctitle
|
||||
import yaml
|
||||
from yaml.loader import SafeLoader
|
||||
|
||||
import argparse
|
||||
import logging
|
||||
import yaml
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
__VERSION = "v0.0.1"
|
||||
os.nice(+19)
|
||||
setproctitle.setproctitle("crystalpol-{}".format(__VERSION))
|
||||
setproctitle.setproctitle("crystalpol-{}".format(VERSION))
|
||||
|
||||
|
||||
def main():
|
||||
@@ -24,28 +24,31 @@ def main():
|
||||
|
||||
parser = argparse.ArgumentParser(prog="CrystalPol")
|
||||
parser.add_argument(
|
||||
"-v", "--version", action="version", version=f"crystalpol-{__VERSION}"
|
||||
"-v", "--version", action="version", version=f"crystalpol-{VERSION}"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-c", "--config",
|
||||
"-c",
|
||||
"--config",
|
||||
dest="config",
|
||||
default="config.yml",
|
||||
metavar="INFILE",
|
||||
help="Config file of crystalpol [default = config.yml]"
|
||||
help="Config file of crystalpol [default = config.yml]",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-i", "--input",
|
||||
"-i",
|
||||
"--input",
|
||||
dest="infile",
|
||||
default="crystal.xyz",
|
||||
metavar="INFILE",
|
||||
help="Input file of crystalpol [default = crystal.xyz]"
|
||||
help="Input file of crystalpol [default = crystal.xyz]",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-o", "--output",
|
||||
"-o",
|
||||
"--output",
|
||||
dest="outfile",
|
||||
default="run.log",
|
||||
metavar="OUTFILE",
|
||||
help="Output file of crystalpol [default = run.log]"
|
||||
help="Output file of crystalpol [default = run.log]",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -53,20 +56,16 @@ def main():
|
||||
if log_file.exists():
|
||||
log_file.rename(log_file.with_suffix(".log.backup"))
|
||||
|
||||
logging.basicConfig(
|
||||
filename=args.outfile,
|
||||
format='%(message)s',
|
||||
level=logging.INFO
|
||||
)
|
||||
logging.basicConfig(filename=args.outfile, format="%(message)s", level=logging.INFO)
|
||||
|
||||
try:
|
||||
with open(args.config) as file:
|
||||
data = yaml.load(file, Loader=SafeLoader)
|
||||
config = Config(**data.get('crystal_pol'))
|
||||
config = Config(**data.get("crystal_pol"))
|
||||
except IOError:
|
||||
raise RuntimeError('Invalid or Missing Config File.')
|
||||
raise RuntimeError("Invalid or Missing Config File.")
|
||||
|
||||
Log.make_header(__VERSION, config.to_dict())
|
||||
Log.make_header(VERSION, config.to_dict())
|
||||
|
||||
pol = Polarization(args.infile, args.outfile, config)
|
||||
pol.run()
|
||||
|
||||
Reference in New Issue
Block a user