[ARVADOS] updated: c7118f62b76c85573d9ecc98d455a1229c764a2f

git at public.curoverse.com git at public.curoverse.com
Wed Aug 13 10:55:43 EDT 2014


Summary of changes:
 sdk/python/arvados/__init__.py | 15 +++++++--------
 sdk/python/bin/arv-get         | 24 +++++++++++-------------
 services/fuse/bin/arv-mount    | 26 ++++++++++++++++++++------
 3 files changed, 38 insertions(+), 27 deletions(-)

       via  c7118f62b76c85573d9ecc98d455a1229c764a2f (commit)
       via  49aae9463ddc72e0d2ddca1892e951aa8402b012 (commit)
      from  7653275ed04ca879047862408ad86dcb3a53c936 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit c7118f62b76c85573d9ecc98d455a1229c764a2f
Author: Brett Smith <brett at curoverse.com>
Date:   Wed Aug 13 10:32:45 2014 -0400

    3457: Make arv-get's logger use more like other tools.
    
    * Don't use the logger for interface messages.
    
    * Demote the "API Collection not found" message to debug level, since
      users usually don't need to worry about it.

diff --git a/sdk/python/bin/arv-get b/sdk/python/bin/arv-get
index 4d8140c..9762e4f 100755
--- a/sdk/python/bin/arv-get
+++ b/sdk/python/bin/arv-get
@@ -12,6 +12,10 @@ import arvados
 
 logger = logging.getLogger('arvados.arv-get')
 
+def abort(msg, code=1):
+    print >>sys.stderr, "arv-get:", msg
+    exit(code)
+
 parser = argparse.ArgumentParser(
     description='Copy data from Keep to a local file or pipe.')
 parser.add_argument('locator', type=str,
@@ -121,23 +125,21 @@ if not get_prefix:
     try:
         if not args.n:
             if not args.f and os.path.exists(args.destination):
-                logger.error('Local file %s already exists', args.destination)
-                sys.exit(1)
+                abort('Local file %s already exists.' % (args.destination,))
             with open(args.destination, 'wb') as f:
                 try:
                     c = arvados.api('v1').collections().get(
                         uuid=collection).execute()
                     manifest = c['manifest_text']
                 except Exception as e:
-                    logger.warning(
+                    logger.debug(
                         "API lookup failed for collection %s (%s: %s)",
                         collection, type(e), str(e))
                     manifest = arvados.Keep.get(collection)
                 f.write(manifest)
         sys.exit(0)
     except arvados.errors.NotFoundError as e:
-        logger.error(e)
-        sys.exit(1)
+        abort(e)
 
 reader = arvados.CollectionReader(collection)
 
@@ -156,8 +158,7 @@ try:
                     os.path.join(s.name(), f.name())[len(get_prefix)+1:])
                 if (not (args.n or args.f or args.skip_existing) and
                     os.path.exists(dest_path)):
-                    logger.error('Local file %s already exists', dest_path)
-                    sys.exit(1)
+                    abort('Local file %s already exists.' % (dest_path,))
             else:
                 if os.path.join(s.name(), f.name()) != '.' + get_prefix:
                     continue
@@ -165,8 +166,7 @@ try:
             todo += [(s, f, dest_path)]
             todo_bytes += f.size()
 except arvados.errors.NotFoundError as e:
-    logger.error(e)
-    sys.exit(1)
+    abort(e)
 
 # Read data, and (if not -n) write to local file(s) or pipe.
 
@@ -182,15 +182,13 @@ for s,f,outfilename in todo:
                            os.path.isdir(outfilename)):
             # Good thing we looked again: apparently this file wasn't
             # here yet when we checked earlier.
-            logger.error('Local file %s already exists', outfilename)
-            sys.exit(1)
+            abort('Local file %s already exists.' % (outfilename,))
         if args.r:
             arvados.util.mkdir_dash_p(os.path.dirname(outfilename))
         try:
             outfile = open(outfilename, 'wb')
         except Exception as e:
-            logger.error('Open(%s) failed: %s', outfilename, e)
-            sys.exit(1)
+            abort('Open(%s) failed: %s' % (outfilename, e))
     if args.hash:
         digestor = hashlib.new(args.hash)
     try:

commit 49aae9463ddc72e0d2ddca1892e951aa8402b012
Author: Brett Smith <brett at curoverse.com>
Date:   Wed Aug 13 10:14:33 2014 -0400

    3457: Fixup: Python logging changes based on review.

diff --git a/sdk/python/arvados/__init__.py b/sdk/python/arvados/__init__.py
index 66aa16e..060ed95 100644
--- a/sdk/python/arvados/__init__.py
+++ b/sdk/python/arvados/__init__.py
@@ -25,17 +25,16 @@ from stream import *
 import errors
 import util
 
-logger = logging.getLogger('arvados')
-if config.get('ARVADOS_DEBUG'):
-    logger.setLevel(logging.DEBUG)
-    log_handler = logging.StreamHandler()
-else:
-    log_handler = logging.NullHandler()
+# Set up Arvados logging based on the user's configuration.
+# All Arvados code should log under the arvados hierarchy.
+log_handler = logging.StreamHandler()
 log_handler.setFormatter(logging.Formatter(
-        '%(asctime)s %(name)s %(levelname)s: %(message)s',
+        '%(asctime)s %(name)s[%(process)d] %(levelname)s: %(message)s',
         '%Y-%m-%d %H:%M:%S'))
-log_handler.setLevel(logger.level)
+logger = logging.getLogger('arvados')
 logger.addHandler(log_handler)
+logger.setLevel(logging.DEBUG if config.get('ARVADOS_DEBUG')
+                else logging.WARNING)
 
 def task_set_output(self,s):
     api('v1').job_tasks().update(uuid=self['uuid'],
diff --git a/services/fuse/bin/arv-mount b/services/fuse/bin/arv-mount
index ed74d95..794a468 100755
--- a/services/fuse/bin/arv-mount
+++ b/services/fuse/bin/arv-mount
@@ -53,15 +53,29 @@ collections on the server.""")
     else:
         daemon_ctx = None
 
-    # Set up logging.
-    arv_logger = logging.getLogger('arvados')
+    # Configure a logger based on command-line switches.
+    # If we're using a contemporary Python SDK (mid-August 2014),
+    # configure the arvados hierarchy logger.
+    # Otherwise, configure the program root logger.
+    base_logger = getattr(arvados, 'logger', None)
+
     if args.logfile:
-        if hasattr(arvados, 'log_handler'):
-            arv_logger.removeHandler(arvados.log_handler)
-        arv_logger.addHandler(logging.FileHandler(args.logfile))
+        log_handler = logging.FileHandler(args.logfile)
+    elif daemon_ctx:
+        log_handler = logging.NullHandler()
+    elif base_logger:
+        log_handler = arvados.log_handler
+    else:
+        log_handler = logging.StreamHandler()
+
+    if base_logger is None:
+        base_logger = logging.getLogger()
+    else:
+        base_logger.removeHandler(arvados.log_handler)
+    base_logger.addHandler(log_handler)
 
     if args.debug:
-        arv_logger.setLevel(logging.DEBUG)
+        base_logger.setLevel(logging.DEBUG)
         logger.debug("arv-mount debugging enabled")
 
     try:

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list