From cbf6fca05f0b7b207c4deafb0bc22d3b2e0abe06 Mon Sep 17 00:00:00 2001 From: Jungho Shin <jungho@physik.hu-berlin.de> Date: Wed, 29 Nov 2017 14:42:35 +0100 Subject: [PATCH] adding checksum --- .../normalizer-repo-tags/calculate_repo_tags.py | 6 +++--- .../normalizer-repo-tags/extract_from_repo.py | 16 ++++++++++------ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/normalizer/normalizer-repo-tags/calculate_repo_tags.py b/normalizer/normalizer-repo-tags/calculate_repo_tags.py index 5f50166..59b6c29 100644 --- a/normalizer/normalizer-repo-tags/calculate_repo_tags.py +++ b/normalizer/normalizer-repo-tags/calculate_repo_tags.py @@ -20,7 +20,7 @@ def calculateTags(inputDict, backend, calcUri): repo_dic_sub_out = repo_dic_sub.communicate(inputDict_str.encode('utf-8'))[0] repo_dic = json.loads(repo_dic_sub_out.decode("utf-8")) - #backend.addValue("repository_checksum", repo_dic['checksum']) + backend.addValue("repository_checksum", repo_dic['checksum']) backend.addValue("repository_chemical_formula", repo_dic['formula']) backend.addValue("repository_parser_id", repo_dic['prog_name'] + ' v1.0') backend.addValue("repository_atomic_elements", repo_dic['elements']) @@ -55,8 +55,8 @@ def main(): calcUri, parserInfo = {'name':'RepoTagsNormalizer', 'version': '1.0'}) - #dictReader=ParseStreamedDicts(sys.stdin) - dictReader=ParseStreamedDicts(open("/u/jungho/myscratch/nomad-lab-base/normalizers/repo-tags/test/examples/scalaOut2.txt", 'r')) + dictReader=ParseStreamedDicts(sys.stdin) + #dictReader=ParseStreamedDicts(open("/u/jungho/myscratch/nomad-lab-base/normalizers/repo-tags/test/examples/scalaOut2.txt", 'r')) while True: inputDict=dictReader.readNextDict() diff --git a/normalizer/normalizer-repo-tags/extract_from_repo.py b/normalizer/normalizer-repo-tags/extract_from_repo.py index b1375f5..989f398 100644 --- a/normalizer/normalizer-repo-tags/extract_from_repo.py +++ b/normalizer/normalizer-repo-tags/extract_from_repo.py @@ -1,23 +1,27 @@ -#import setup_paths, setup_paths_repo import sys, json -import sqlalchemy + base_path= sys.exec_prefix + '/python' sys.path.insert(0, base_path) + from nomadrepo.core.settings import connect_database, settings from nomadrepo.core.api import API -inputStr = sys.stdin.readline() -def extract_metadata(dic): +def extract_metadata(dic_in): + session = connect_database(settings, None)() + checksum = session.execute("SELECT checksum FROM calculations WHERE calc_id = %d ;" % 4000000).fetchone()[0] + session.commit(); session.close() + work = API() - for calc, error in work._parse(dic, "normalizerRepo"): + for calc, error in work._parse(dic_in, "normalizerRepo"): calc, error = work.classify(calc) calc.info['oadate'] = None - #calc.info['checksum'] = calc.get_checksum() + calc.info['checksum'] = str(checksum) json.dump(calc.info, sys.__stdout__) pass def main(): + inputStr = sys.stdin.readline() inputDict = json.loads(inputStr) extract_metadata(inputDict) -- GitLab