[ARVADOS] created: 446e64dc143148e52a126fa502bf63299c94197e

Git user git at public.curoverse.com
Wed Jul 12 19:28:33 EDT 2017


        at  446e64dc143148e52a126fa502bf63299c94197e (commit)


commit 446e64dc143148e52a126fa502bf63299c94197e
Author: Lucas Di Pentima <lucas at curoverse.com>
Date:   Wed Jul 12 20:27:48 2017 -0300

    5652: Code style fixes.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at curoverse.com>

diff --git a/sdk/python/arvados/commands/put.py b/sdk/python/arvados/commands/put.py
index e931ab0..b357bc9 100644
--- a/sdk/python/arvados/commands/put.py
+++ b/sdk/python/arvados/commands/put.py
@@ -195,7 +195,7 @@ total data size).
 
 _group.add_argument('--silent', action='store_true',
                     help="""
-Don't produce any output unless an error happens.
+Do not produce any output unless an error happens.
 """)
 
 _group = run_opts.add_mutually_exclusive_group()
diff --git a/sdk/python/tests/test_arv_put.py b/sdk/python/tests/test_arv_put.py
index 9821dec..756e378 100644
--- a/sdk/python/tests/test_arv_put.py
+++ b/sdk/python/tests/test_arv_put.py
@@ -980,10 +980,8 @@ class ArvPutIntegrationTest(run_test_server.TestCaseWithServers,
             stderr=subprocess.PIPE, env=self.ENVIRON)
         stdout, stderr = pipe.communicate()
         # No output should occur on normal operations
-        self.assertNotRegex(stderr.decode(),
-                            r'.+')
-        self.assertNotRegex(stdout.decode(),
-                            r'.+')
+        self.assertNotRegex(stderr.decode(), r'.+')
+        self.assertNotRegex(stdout.decode(), r'.+')
 
     def test_silent_mode_does_not_avoid_error_messages(self):
         self.authorize_with('active')
@@ -994,10 +992,8 @@ class ArvPutIntegrationTest(run_test_server.TestCaseWithServers,
             stderr=subprocess.PIPE, env=self.ENVIRON)
         stdout, stderr = pipe.communicate()
         # Error message should be displayed when errors happen
-        self.assertRegex(stderr.decode(),
-                            r'.*ERROR:.*')
-        self.assertNotRegex(stdout.decode(),
-                            r'.+')
+        self.assertRegex(stderr.decode(), r'.*ERROR:.*')
+        self.assertNotRegex(stdout.decode(), r'.+')
 
 
 if __name__ == '__main__':

commit 7777370ae3c0815c266148f097355f70bdd1a0e3
Author: Lucas Di Pentima <lucas at curoverse.com>
Date:   Wed Jul 12 20:10:08 2017 -0300

    5652: Added --silent argument to arv-put to make it produce no
    output when running in normal conditions.
    Added related tests.
    
    Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas at curoverse.com>

diff --git a/sdk/python/arvados/commands/put.py b/sdk/python/arvados/commands/put.py
index 68f63b1..e931ab0 100644
--- a/sdk/python/arvados/commands/put.py
+++ b/sdk/python/arvados/commands/put.py
@@ -193,6 +193,11 @@ Display machine-readable progress on stderr (bytes and, if known,
 total data size).
 """)
 
+_group.add_argument('--silent', action='store_true',
+                    help="""
+Don't produce any output unless an error happens.
+""")
+
 _group = run_opts.add_mutually_exclusive_group()
 _group.add_argument('--resume', action='store_true', default=True,
                     help="""
@@ -243,7 +248,7 @@ def parse_arguments(arguments):
     """)
 
     # Turn on --progress by default if stderr is a tty.
-    if (not (args.batch_progress or args.no_progress)
+    if (not (args.batch_progress or args.no_progress or args.silent)
         and os.isatty(sys.stderr.fileno())):
         args.progress = True
 
@@ -964,9 +969,12 @@ def desired_project_uuid(api_client, project_uuid, num_retries):
 def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr):
     global api_client
 
-    logger = logging.getLogger('arvados.arv_put')
-    logger.setLevel(logging.INFO)
     args = parse_arguments(arguments)
+    logger = logging.getLogger('arvados.arv_put')
+    if args.silent:
+        logger.setLevel(logging.WARNING)
+    else:
+        logger.setLevel(logging.INFO)
     status = 0
     if api_client is None:
         api_client = arvados.api('v1')
@@ -1135,7 +1143,7 @@ def main(arguments=None, stdout=sys.stdout, stderr=sys.stderr):
     # Print the locator (uuid) of the new collection.
     if output is None:
         status = status or 1
-    else:
+    elif not args.silent:
         stdout.write(output)
         if not output.endswith('\n'):
             stdout.write('\n')
diff --git a/sdk/python/tests/test_arv_put.py b/sdk/python/tests/test_arv_put.py
index b31d2ea..9821dec 100644
--- a/sdk/python/tests/test_arv_put.py
+++ b/sdk/python/tests/test_arv_put.py
@@ -969,6 +969,36 @@ class ArvPutIntegrationTest(run_test_server.TestCaseWithServers,
                          r'^\./%s.*:file2.txt' % os.path.basename(tmpdir))
         self.assertRegex(c['manifest_text'], r'^.*:file3.txt')
 
+    def test_silent_mode(self):
+        self.authorize_with('active')
+        tmpdir = self.make_tmpdir()
+        with open(os.path.join(tmpdir, 'test.txt'), 'w') as f:
+            f.write('hello world')
+        pipe = subprocess.Popen(
+            [sys.executable, arv_put.__file__] + ['--silent', tmpdir],
+            stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+            stderr=subprocess.PIPE, env=self.ENVIRON)
+        stdout, stderr = pipe.communicate()
+        # No output should occur on normal operations
+        self.assertNotRegex(stderr.decode(),
+                            r'.+')
+        self.assertNotRegex(stdout.decode(),
+                            r'.+')
+
+    def test_silent_mode_does_not_avoid_error_messages(self):
+        self.authorize_with('active')
+        pipe = subprocess.Popen(
+            [sys.executable, arv_put.__file__] + ['--silent',
+                                                  '/path/not/existant'],
+            stdin=subprocess.PIPE, stdout=subprocess.PIPE,
+            stderr=subprocess.PIPE, env=self.ENVIRON)
+        stdout, stderr = pipe.communicate()
+        # Error message should be displayed when errors happen
+        self.assertRegex(stderr.decode(),
+                            r'.*ERROR:.*')
+        self.assertNotRegex(stdout.decode(),
+                            r'.+')
+
 
 if __name__ == '__main__':
     unittest.main()

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list