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