diff --git a/integrationtests/pycaosdb.ini b/integrationtests/pycaosdb.ini new file mode 100644 index 0000000000000000000000000000000000000000..a4f429736c9b46c8987d05a02724725295f32081 --- /dev/null +++ b/integrationtests/pycaosdb.ini @@ -0,0 +1,29 @@ +[Connection] +url=https://localhost:10443/ +username=admin +debug=0 +#cacert=/home//CaosDB/caosdb-deploy/profiles/default/custom/other/cert/caosdb.cert.pem +password_method=plain +password=caosdb + +ssl_insecure=True +timeout=5000 +[Container] +debug=0 + +#[Crawler] +#oldprefix=/ExperimentalData/ +#newprefix=/home/professional/CaosDB/caosdb-advanced-user-tools/integrationtests/extroot/ExperimentalData +#[IntegrationTests] +#test_server_side_scripting.bin_dir=/home/professional/CaosDB/caosdb-pyinttest/resources + +[Misc] +sendmail=sendmail_to_file +#sendmail=/usr/local/bin/sendmail_to_file +entity_loan.curator_mail_from=admin@indiscale.com +entity_loan.curator_mail_to=admin@indiscale.com +[sss_helper] +external_uri = https://localhost:10443 +[advancedtools] +crawler.from_mail=admin@indiscale.com +crawler.to_mail=admin@indiscale.com diff --git a/integrationtests/test_data/extroot/realworld_example/pycaosdb.ini b/integrationtests/test_data/extroot/realworld_example/pycaosdb.ini new file mode 120000 index 0000000000000000000000000000000000000000..bc443439d842f18ce05e002e5f6b95d37ca22747 --- /dev/null +++ b/integrationtests/test_data/extroot/realworld_example/pycaosdb.ini @@ -0,0 +1 @@ +../../../pycaosdb.ini \ No newline at end of file diff --git a/integrationtests/test_data/extroot/realworld_example/schema/zmt-organisation.yml b/integrationtests/test_data/extroot/realworld_example/schema/organisation.yml similarity index 100% rename from integrationtests/test_data/extroot/realworld_example/schema/zmt-organisation.yml rename to integrationtests/test_data/extroot/realworld_example/schema/organisation.yml diff --git a/integrationtests/test_realworld_example.py b/integrationtests/test_realworld_example.py index cffb84946611e1c37f28d638acfa234ad12253b1..e26bc7dbbbfb8425429a130a85fa65bd38912190 100644 --- a/integrationtests/test_realworld_example.py +++ b/integrationtests/test_realworld_example.py @@ -81,18 +81,26 @@ def clear_database(): ents.delete() -def test_dataset( - clear_database, - usemodel): - +def create_identifiable_adapter(): ident = CaosDBIdentifiableAdapter() - ident.register_identifiable( - "license", db.RecordType().add_parent("license").add_property("name")) - ident.register_identifiable("project_type", db.RecordType( - ).add_parent("project_type").add_property("name")) - ident.register_identifiable("Person", db.RecordType( - ).add_parent("Person").add_property("full_name")) - + ident.register_identifiable("license", ( + db.RecordType() + .add_parent("license") + .add_property("name"))) + ident.register_identifiable("project_type", ( + db.RecordType() + .add_parent("project_type") + .add_property("name"))) + ident.register_identifiable("Person", ( + db.RecordType() + .add_parent("Person") + .add_property("full_name"))) + + return ident + + +def test_dataset(clear_database, usemodel): + ident = create_identifiable_adapter crawler = Crawler(identifiableAdapter=ident) crawler_definition = crawler.load_definition( os.path.join(DATADIR, "dataset_cfoods.yml")) diff --git a/setup.cfg b/setup.cfg index e2d3524ba6508f6a70f65203f02dc590a1dd9a7c..9c652aa9ad32757075bd37f0bd5efeadcaa34582 100644 --- a/setup.cfg +++ b/setup.cfg @@ -24,7 +24,7 @@ install_requires = caosadvancedtools yaml-header-tools pyyaml - odfpy + odfpy #make optional pandas [options.packages.find] diff --git a/src/caoscrawler/authorize.py b/src/caoscrawler/authorize.py new file mode 100644 index 0000000000000000000000000000000000000000..6f1011b227881d4b73186996076abe20d94d52e5 --- /dev/null +++ b/src/caoscrawler/authorize.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +# encoding: utf-8 +# +# This file is a part of the CaosDB Project. +# +# Copyright (C) 2022 Henrik tom Wörden +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# + +from caosadvancedtools.crawler import Crawler as OldCrawler + +import argparse + + +def parse_args(): + parser = argparse.ArgumentParser() + parser.add_argument("run_id", + help="Run ID or the crawler run that created the changes that shall be " + "authorized.") + + return parser.parse_args() + + +if __name__ == "__main__": + args = parse_args() + OldCrawler.update_authorized_changes(args.run_id) diff --git a/src/caoscrawler/crawl.py b/src/caoscrawler/crawl.py index 2a1bc71eeff556869e94ad20e5c46b5e7d5cf151..2d464019bdc689bc16ec7c097167698113cf5cc7 100644 --- a/src/caoscrawler/crawl.py +++ b/src/caoscrawler/crawl.py @@ -29,7 +29,7 @@ the acuired data with CaosDB. """ import importlib -from caosadvancedtools.cache import UpdateCache +from caosadvancedtools.cache import UpdateCache, Cache import uuid import sys import os @@ -777,8 +777,9 @@ class Crawler(object): if securityMode.value > SecurityMode.RETRIEVE.value: db.Container().extend(to_be_inserted).insert() elif run_id is not None: - update_cache = UpdateCache() - update_cache.insert(to_be_inserted, run_id) + raise NotImplementedError("Caching forbidden inserts is currently not implemented") + #cache = Cache() + #cache.insert(to_be_inserted, run_id) @staticmethod def set_ids_and_datatype_of_parents_and_properties(rec_list): @@ -1119,6 +1120,17 @@ def parse_args(): if __name__ == "__main__": args = parse_args() + + conlogger = logging.getLogger("connection") + conlogger.setLevel(level=logging.ERROR) + + # logging config for local execution + logger.addHandler(logging.StreamHandler(sys.stdout)) + if args.debug: + logger.setLevel(logging.DEBUG) + else: + logger.setLevel(logging.INFO) + sys.exit(main( args.crawled_directory_path, args.cfood_file_name, diff --git a/src/caoscrawler/identifiable_adapters.py b/src/caoscrawler/identifiable_adapters.py index ce3a29b7484de83a17f27c27f3373ab91df70c9a..9344862f6af22f6132bfcb36cbcae866b90e1083 100644 --- a/src/caoscrawler/identifiable_adapters.py +++ b/src/caoscrawler/identifiable_adapters.py @@ -202,6 +202,8 @@ class IdentifiableAdapter(metaclass=ABCMeta): if record_prop is None: # TODO: how to handle missing values in identifiables # raise an exception? + print("RECORD\n", record) + print("PROPERTY\n", prop.name) raise NotImplementedError() newval = record_prop.value if isinstance(record_prop.value, db.Entity):