Skip to content
Snippets Groups Projects
Commit 70b57ac5 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

Merge branch 'f-filenotfound' into 'dev'

catch filenotfoundErrors

See merge request caosdb/caosdb-advanced-user-tools!63
parents 90a2b9ac e2c34f31
No related branches found
No related tags found
1 merge request!22Release 0.3
...@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### ### Added ###
- Error handling for missing files when using the crawler
- included the scifolder module - included the scifolder module
- included the caosmodels module - included the caosmodels module
* `send_mail` function in `caosadvancedtools.serverside.helper` module * `send_mail` function in `caosadvancedtools.serverside.helper` module
......
...@@ -19,9 +19,13 @@ python3 -m pytest test_crawler_with_cfoods.py ...@@ -19,9 +19,13 @@ python3 -m pytest test_crawler_with_cfoods.py
echo "make a change" echo "make a change"
pushd extroot pushd extroot
egrep -liRZ 'A description of another example' . | xargs -0 -l sed -i -e 's/A description of another example/A description of this example/g' egrep -liRZ 'A description of another example' . | xargs -0 -l sed -i -e 's/A description of another example/A description of this example/g'
# remove a file to check that this does not lead to a crawler crash
mv DataAnalysis/2010_TestProject/2019-02-03_something/README.xlsx DataAnalysis/2010_TestProject/2019-02-03_something/README.xlsx_back
popd popd
echo "run crawler" echo "run crawler"
./crawl.py / &> $OUT ./crawl.py / | tee $OUT
# rename the moved file
mv extroot/DataAnalysis/2010_TestProject/2019-02-03_something/README.xlsx_back extroot/DataAnalysis/2010_TestProject/2019-02-03_something/README.xlsx
# check whether there was something UNAUTHORIZED # check whether there was something UNAUTHORIZED
set -e set -e
grep "There where unauthorized changes" $OUT grep "There where unauthorized changes" $OUT
......
...@@ -196,6 +196,9 @@ class Crawler(object): ...@@ -196,6 +196,9 @@ class Crawler(object):
logger.debug("{} matched\n{}.".format( logger.debug("{} matched\n{}.".format(
Cfood.__name__, Cfood.__name__,
item)) item))
except FileNotFoundError as e:
logger.info("Cannot access {}. However, it might be needed for"
" the correct execution".format(e.filename))
except DataInconsistencyError as e: except DataInconsistencyError as e:
logger.debug(traceback.format_exc()) logger.debug(traceback.format_exc())
logger.debug(e) logger.debug(e)
...@@ -227,6 +230,10 @@ class Crawler(object): ...@@ -227,6 +230,10 @@ class Crawler(object):
logger.debug(traceback.format_exc()) logger.debug(traceback.format_exc())
logger.debug(e) logger.debug(e)
remove_cfoods.append(cfood) remove_cfoods.append(cfood)
except FileNotFoundError as e:
logger.info("Cannot access {}. However, it might be needed for"
" the correct execution".format(e.filename))
remove_cfoods.append(cfood)
except Exception as e: except Exception as e:
try: try:
DataModelProblems.evaluate_exception(e) DataModelProblems.evaluate_exception(e)
...@@ -313,6 +320,9 @@ class Crawler(object): ...@@ -313,6 +320,9 @@ class Crawler(object):
cfood.update_identifiables() cfood.update_identifiables()
self.push_identifiables_to_CaosDB(cfood) self.push_identifiables_to_CaosDB(cfood)
except FileNotFoundError as e:
logger.info("Cannot access {}. However, it might be needed for"
" the correct execution".format(e.filename))
except DataInconsistencyError as e: except DataInconsistencyError as e:
logger.debug(traceback.format_exc()) logger.debug(traceback.format_exc())
logger.debug(e) logger.debug(e)
...@@ -534,6 +544,9 @@ carefully and if the changes are ok, click on the following link: ...@@ -534,6 +544,9 @@ carefully and if the changes are ok, click on the following link:
logger.debug(cfood.to_be_updated) logger.debug(cfood.to_be_updated)
try: try:
guard.safe_update(cfood.to_be_updated, unique=False) guard.safe_update(cfood.to_be_updated, unique=False)
except FileNotFoundError as e:
logger.info("Cannot access {}. However, it might be needed for"
" the correct execution".format(e.filename))
except ProhibitedException: except ProhibitedException:
try: try:
self.update_cache.insert(cfood.to_be_updated, self.run_id) self.update_cache.insert(cfood.to_be_updated, self.run_id)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment