[ARVADOS] updated: b23101649f5320c7f4f5c68f3d7745373e316249
git at public.curoverse.com
git at public.curoverse.com
Mon Jul 20 14:50:53 EDT 2015
Summary of changes:
sdk/python/arvados/util.py | 18 +++++++++---------
sdk/python/tests/test_util.py | 18 ++++++++++++++++--
2 files changed, 25 insertions(+), 11 deletions(-)
via b23101649f5320c7f4f5c68f3d7745373e316249 (commit)
from ee29db4af2c800924fa06b7bbc1f3058ba3cfb94 (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 b23101649f5320c7f4f5c68f3d7745373e316249
Author: Brett Smith <brett at curoverse.com>
Date: Mon Jul 20 14:50:33 2015 -0400
6658: Fix exception name errors in PySDK arvados.util.
Refs #6658.
diff --git a/sdk/python/arvados/util.py b/sdk/python/arvados/util.py
index aaf2094..3e59bfb 100644
--- a/sdk/python/arvados/util.py
+++ b/sdk/python/arvados/util.py
@@ -45,7 +45,7 @@ def run_command(execargs, **kwargs):
p = subprocess.Popen(execargs, **kwargs)
stdoutdata, stderrdata = p.communicate(None)
if p.returncode != 0:
- raise errors.CommandFailedError(
+ raise arvados.errors.CommandFailedError(
"run_command %s exit %d:\n%s" %
(execargs, p.returncode, stderrdata))
return stdoutdata, stderrdata
@@ -110,7 +110,7 @@ def tarball_extract(tarball, path):
elif re.search('\.tar$', f.name()):
p = tar_extractor(path, '')
else:
- raise errors.AssertionError(
+ raise arvados.errors.AssertionError(
"tarball_extract cannot handle filename %s" % f.name())
while True:
buf = f.read(2**20)
@@ -121,7 +121,7 @@ def tarball_extract(tarball, path):
p.wait()
if p.returncode != 0:
lockfile.close()
- raise errors.CommandFailedError(
+ raise arvados.errors.CommandFailedError(
"tar exited %d" % p.returncode)
os.symlink(tarball, os.path.join(path, '.locator'))
tld_extracts = filter(lambda f: f != '.locator', os.listdir(path))
@@ -165,7 +165,7 @@ def zipball_extract(zipball, path):
for f in CollectionReader(zipball).all_files():
if not re.search('\.zip$', f.name()):
- raise errors.NotImplementedError(
+ raise arvados.errors.NotImplementedError(
"zipball_extract cannot handle filename %s" % f.name())
zip_filename = os.path.join(path, os.path.basename(f.name()))
zip_file = open(zip_filename, 'wb')
@@ -186,7 +186,7 @@ def zipball_extract(zipball, path):
p.wait()
if p.returncode != 0:
lockfile.close()
- raise errors.CommandFailedError(
+ raise arvados.errors.CommandFailedError(
"unzip exited %d" % p.returncode)
os.unlink(zip_filename)
os.symlink(zipball, os.path.join(path, '.locator'))
@@ -250,7 +250,7 @@ def collection_extract(collection, path, files=[], decompress=True):
outfile.write(buf)
outfile.close()
if len(files_got) < len(files):
- raise errors.AssertionError(
+ raise arvados.errors.AssertionError(
"Wanted files %s but only got %s from %s" %
(files, files_got,
[z.name() for z in CollectionReader(collection).all_files()]))
@@ -305,7 +305,7 @@ def stream_extract(stream, path, files=[], decompress=True):
outfile.write(buf)
outfile.close()
if len(files_got) < len(files):
- raise errors.AssertionError(
+ raise arvados.errors.AssertionError(
"Wanted files %s but only got %s from %s" %
(files, files_got, [z.name() for z in stream.all_files()]))
lockfile.close()
@@ -352,8 +352,8 @@ def is_hex(s, *length_args):
"""
num_length_args = len(length_args)
if num_length_args > 2:
- raise errors.ArgumentError("is_hex accepts up to 3 arguments ({} given)"
- .format(1 + num_length_args))
+ raise arvados.errors.ArgumentError(
+ "is_hex accepts up to 3 arguments ({} given)".format(1 + num_length_args))
elif num_length_args == 2:
good_len = (length_args[0] <= len(s) <= length_args[1])
elif num_length_args == 1:
diff --git a/sdk/python/tests/test_util.py b/sdk/python/tests/test_util.py
index f9e5d8c..41739a9 100644
--- a/sdk/python/tests/test_util.py
+++ b/sdk/python/tests/test_util.py
@@ -1,6 +1,8 @@
-import unittest
import os
-import arvados.util
+import subprocess
+import unittest
+
+import arvados
class MkdirDashPTest(unittest.TestCase):
def setUp(self):
@@ -20,3 +22,15 @@ class MkdirDashPTest(unittest.TestCase):
with open('./tmp/bar', 'wb') as f:
f.write('bar')
self.assertRaises(OSError, arvados.util.mkdir_dash_p, './tmp/bar')
+
+
+class RunCommandTestCase(unittest.TestCase):
+ def test_success(self):
+ stdout, stderr = arvados.util.run_command(['echo', 'test'],
+ stderr=subprocess.PIPE)
+ self.assertEqual("test\n", stdout)
+ self.assertEqual("", stderr)
+
+ def test_failure(self):
+ with self.assertRaises(arvados.errors.CommandFailedError):
+ arvados.util.run_command(['false'])
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list