[ros-resource-retriever] 01/07: New upstream version 1.12.3

Jochen Sprickerhof jspricke at moszumanska.debian.org
Sat Dec 23 16:05:34 UTC 2017


This is an automated email from the git hooks/post-receive script.

jspricke pushed a commit to branch master
in repository ros-resource-retriever.

commit 2d71dc7a1944cbf4f1916076767fea4567a2600e
Author: Jochen Sprickerhof <git at jochen.sprickerhof.de>
Date:   Fri Jun 23 11:35:35 2017 +0200

    New upstream version 1.12.3
---
 CHANGELOG.rst                      | 14 ++++++++++++++
 CMakeLists.txt                     |  2 +-
 package.xml                        |  8 +++++---
 src/resource_retriever/__init__.py | 26 ++++++++++++++------------
 test/CMakeLists.txt                |  2 ++
 test/test.cpp                      |  2 +-
 test/test.py                       | 36 ++++++++++++++++++++++++++++++++++++
 7 files changed, 73 insertions(+), 17 deletions(-)

diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index b61cf58..06590eb 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -2,6 +2,20 @@
 Changelog for package resource_retriever
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
+1.12.3 (2017-03-27)
+-------------------
+* Fix C++11 to use set_directory_properties
+* Make Shane and Chris the maintainers.
+* Python3 compatibility (`#10 <https://github.com/ros/resource_retriever/issues/10>`_)
+  * Replace urlgrabber with urllib[2]
+  As urlgrabber is not supported for Python 3 replace it with either the built-in urllib (Python 2) or urllib2 (Python 3)
+  * Use rospkg instead of system call for rospack
+  * Add test for python functionality
+  * Fix rospkg dependency definition
+* Update URL in http test to something which exists (`#8 <https://github.com/ros/resource_retriever/issues/8>`_)
+  * Update URL in http test to something which exists
+* Contributors: Chris Lalancette, Mike Purvis, Ruben Smits
+
 1.12.2 (2016-06-10)
 -------------------
 * fix failing build due to cmake error (`#6 <https://github.com/ros/resource_retriever/issues/6>`_)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c6fc80d..dcbdf67 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,7 @@
 cmake_minimum_required(VERSION 2.8.3)
 project(resource_retriever)
 
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
+set_directory_properties(PROPERTIES COMPILE_OPTIONS "-std=c++11")
 
 find_package(catkin REQUIRED COMPONENTS rosconsole roslib)
 
diff --git a/package.xml b/package.xml
index 558ea1d..6f190be 100644
--- a/package.xml
+++ b/package.xml
@@ -1,6 +1,6 @@
 <package>
   <name>resource_retriever</name>
-  <version>1.12.2</version>
+  <version>1.12.3</version>
   <description>
    This package retrieves data from url-format files such as http://,
    ftp://, package:// file://, etc., and loads the data into memory.
@@ -11,7 +11,9 @@
   </description>
 
   <author email="jfaust at willowgarage.com">Josh Faust</author>
-  <maintainer email="isucan at gmail.com">Ioan Sucan</maintainer>
+  <author email="isucan at gmail.com">Ioan Sucan</author>
+  <maintainer email="clalancette at osrfoundation.org">Chris Lalancette</maintainer>
+  <maintainer email="sloretz at osrfoundation.org">Shane Loretz</maintainer>
 
   <license>BSD</license>
 
@@ -28,6 +30,6 @@
   <run_depend>curl</run_depend>
   <run_depend>rosconsole</run_depend>
   <run_depend>roslib</run_depend>
-  <run_depend>python-urlgrabber</run_depend>
+  <run_depend>python-rospkg</run_depend>
 
 </package>
diff --git a/src/resource_retriever/__init__.py b/src/resource_retriever/__init__.py
index d92baca..747a63f 100644
--- a/src/resource_retriever/__init__.py
+++ b/src/resource_retriever/__init__.py
@@ -33,17 +33,16 @@
 
 import roslib; roslib.load_manifest('resource_retriever')
 import subprocess
-import urlgrabber, string
+import rospkg
+try:
+    from urllib.request import urlopen
+    from urllib.error import URLError
+except ImportError:
+    from urllib2 import urlopen
+    from urllib2 import URLError
 
 PACKAGE_PREFIX = 'package://'
-
-def rospack_find(package):
-    process = subprocess.Popen(['rospack', 'find', package], shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-    (stdout, stderr) = process.communicate()
-    if len(stderr) > 0:
-        raise Exception(stderr)
-    else:
-        return string.strip(stdout)
+r = rospkg.RosPack()
 
 def get_filename(url, use_protocol=True ):
     mod_url = url
@@ -55,7 +54,7 @@ def get_filename(url, use_protocol=True ):
 
         package = mod_url[0:pos]
         mod_url = mod_url[pos:]
-        package_path = rospack_find(package)
+        package_path = r.get_path(package)
 
         if use_protocol:
             protocol = "file://"
@@ -65,5 +64,8 @@ def get_filename(url, use_protocol=True ):
     return mod_url
 
 def get(url):
-    return urlgrabber.urlopen(get_filename(url))
-
+    filename = get_filename(url)
+    try:
+        return urlopen(filename).read()
+    except URLError:
+        raise Exception("Invalid URL: {}".format(filename))
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index f133bf6..e311f59 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -2,3 +2,5 @@ set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR})
 
 catkin_add_gtest(${PROJECT_NAME}_utest test.cpp)
 target_link_libraries(${PROJECT_NAME}_utest ${PROJECT_NAME})
+
+catkin_add_nosetests(test.py)
diff --git a/test/test.cpp b/test/test.cpp
index d5c9034..89b95a3 100644
--- a/test/test.cpp
+++ b/test/test.cpp
@@ -88,7 +88,7 @@ TEST(Retriever, http)
   try
   {
     Retriever r;
-    MemoryResource res = r.get("http://pr.willowgarage.com/downloads/svnmerge.py");
+    MemoryResource res = r.get("http://packages.ros.org/ros.key");
 
     ASSERT_GT(res.size, 0);
   }
diff --git a/test/test.py b/test/test.py
new file mode 100644
index 0000000..ce1843f
--- /dev/null
+++ b/test/test.py
@@ -0,0 +1,36 @@
+import resource_retriever as r
+
+import os
+import rospkg
+from nose.tools import raises
+
+rospack = rospkg.RosPack()
+
+def test_get_by_package():
+    res = r.get("package://resource_retriever/test/test.txt")
+    assert len(res) == 1
+    assert res == 'A'.encode()
+
+def test_get_large_file():
+    res_path = os.path.join(rospack.get_path("resource_retriever"), "test/large_file.dat")
+    with open(res_path, 'w') as f:
+        for _ in range(1024*1024*50):
+            f.write('A')
+    res = r.get("package://resource_retriever/test/large_file.dat")
+    assert len(res) == 1024*1024*50
+
+def test_http():
+    res = r.get("http://packages.ros.org/ros.key")
+    assert len(res) > 0
+
+ at raises(Exception)
+def test_invalid_file():
+    r.get("file://fail")
+
+ at raises(Exception)
+def test_no_file():
+    r.get("package://roscpp")
+
+ at raises(rospkg.common.ResourceNotFound)
+def test_invalid_package():
+    r.get("package://invalid_package_blah/test.xml")

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/ros/ros-resource-retriever.git



More information about the debian-science-commits mailing list