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

Merge branch 'f-authorize' into 'dev'

MAINT: logging in loadfiles and static authorization function

See merge request caosdb/caosdb-advanced-user-tools!42
parents 335b7bc7 6e26e3f7
No related branches found
No related tags found
1 merge request!22Release 0.3
......@@ -118,7 +118,8 @@ class Crawler(object):
""" generates items to be crawled with an index"""
yield 0, None
def update_authorized_changes(self, run_id):
@staticmethod
def update_authorized_changes(run_id):
"""
execute the pending updates of a specific run id.
......@@ -128,7 +129,8 @@ class Crawler(object):
-----------
run_id: the id of the crawler run
"""
changes = self.update_cache.get_updates(run_id)
cache = UpdateCache()
changes = cache.get_updates(run_id)
for _, _, old, new, _ in changes:
current = db.Container()
......@@ -147,6 +149,9 @@ class Crawler(object):
continue
new_cont.update(unique=False)
logger.info("Successfully updated {} records!".format(
len(new_cont)))
logger.info("Finished with authorized updates.")
def collect_cfoods(self):
"""
......
......@@ -24,12 +24,14 @@
#
import argparse
import logging
import math
import sys
from argparse import ArgumentParser
import caosdb as db
logger = logging.getLogger(__name__)
timeout_fallback = 20
......@@ -37,8 +39,8 @@ def convert_size(size):
if (size == 0):
return '0B'
size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB")
i = int(math.floor(math.log(size, 1024)))
p = math.pow(1024, i)
i = int(math.floor(math.log(size, 1000)))
p = math.pow(1000, i)
s = round(size / p, 2)
return '%s %s' % (s, size_name[i])
......@@ -47,7 +49,7 @@ def convert_size(size):
def loadpath(path, include, exclude, prefix, dryrun, forceAllowSymlinks):
if dryrun:
print("DRYRUN")
logger.info("Performin a dryrun!")
files = db.Container().retrieve(
unique=False,
raise_exception_on_error=True,
......@@ -73,8 +75,8 @@ def loadpath(path, include, exclude, prefix, dryrun, forceAllowSymlinks):
for f in files:
totalsize += f.size
print("\n\nTOTAL " + str(len(files)) +
" NEW files (" + convert_size(totalsize) + ")")
logger.info("Made in total {} new files with a combined size of {} "
"accessible.".format(len(files), convert_size(totalsize)))
return
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment