catkin and setup.py for roslcean
This commit is contained in:
parent
13c6f290e6
commit
bf45df7129
|
@ -1,4 +1,7 @@
|
|||
if(CATKIN)
|
||||
include(catkin.cmake)
|
||||
return()
|
||||
endif()
|
||||
project(rosclean)
|
||||
find_package(catkin)
|
||||
install_cmake_infrastructure(${PROJECT_NAME}
|
||||
VERSION 0.0.1
|
||||
PYTHONPATH src
|
||||
)
|
||||
enable_python(${PROJECT_NAME})
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
project(rosclean)
|
||||
find_package(catkin)
|
||||
install_cmake_infrastructure(${PROJECT_NAME}
|
||||
VERSION 0.0.1
|
||||
PYTHONPATH src
|
||||
)
|
||||
enable_python(${PROJECT_NAME})
|
|
@ -0,0 +1,4 @@
|
|||
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
if(NOT EXISTS ${CMAKE_BINARY_DIR}/bin/rosclean)
|
||||
execute_process(COMMAND /bin/ln -s ${CMAKE_CURRENT_SOURCE_DIR}/rosclean ${CMAKE_BINARY_DIR}/bin/rosclean)
|
||||
endif()
|
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env python
|
||||
# Software License Agreement (BSD License)
|
||||
#
|
||||
# Copyright (c) 2010, Willow Garage, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials provided
|
||||
# with the distribution.
|
||||
# * Neither the name of Willow Garage, Inc. nor the names of its
|
||||
# contributors may be used to endorse or promote products derived
|
||||
# from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import rosclean
|
||||
rosclean.rosclean_main()
|
|
@ -1,17 +1,18 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from distutils.core import setup
|
||||
from setuptools import setup
|
||||
|
||||
import sys
|
||||
sys.path.insert(0, 'src')
|
||||
|
||||
from genmsg import __version__
|
||||
from rosclean import __version__
|
||||
|
||||
setup(name='rosclean',
|
||||
version= __version__,
|
||||
py_modules=['rosclean'],
|
||||
package_dir = {'':'src'},
|
||||
scripts = [],
|
||||
install_requires=['rospkg'],
|
||||
scripts = ['scripts/rosclean'],
|
||||
author = "Ken Conley",
|
||||
author_email = "kwc@willowgarage.com",
|
||||
url = "http://www.ros.org/wiki/rosclean",
|
||||
|
|
|
@ -41,16 +41,15 @@ import subprocess
|
|||
|
||||
import rospkg
|
||||
|
||||
class ROSCleanException(Exception): pass
|
||||
class CleanupException(Exception): pass
|
||||
|
||||
def _ask_and_call(cmds, cwd=None):
|
||||
"""
|
||||
Pretty print cmds, ask if they should be run, and if so, runs
|
||||
them using subprocess.check_call.
|
||||
|
||||
@param cwd: (optional) set cwd of command that is executed
|
||||
@type cwd: str
|
||||
@return: True if cmds were run.
|
||||
:param cwd: (optional) set cwd of command that is executed, ``str``
|
||||
:returns: ``True`` if cmds were run.
|
||||
"""
|
||||
# Pretty-print a string version of the commands
|
||||
def quote(s):
|
||||
|
@ -94,42 +93,39 @@ def _rosclean_cmd_check(argv):
|
|||
def get_human_readable_disk_usage(d):
|
||||
"""
|
||||
Get human-readable disk usage for directory
|
||||
@param d: directory path
|
||||
@type d: str
|
||||
@return: human-readable disk usage (du -h)
|
||||
@rtype: str
|
||||
|
||||
:param d: directory path, ``str`
|
||||
:returns: human-readable disk usage (du -h), ``str``
|
||||
"""
|
||||
# only implemented on Linux and FreeBSD for now. Should work on OS X but need to verify first (du is not identical)
|
||||
if platform.system() in ['Linux', 'FreeBSD']:
|
||||
try:
|
||||
return subprocess.Popen(['du', '-sh', d], stdout=subprocess.PIPE).communicate()[0].split()[0]
|
||||
except:
|
||||
raise ROSCleanException("rosclean is not supported on this platform")
|
||||
raise CleanupException("rosclean is not supported on this platform")
|
||||
else:
|
||||
raise ROSCleanException("rosclean is not supported on this platform")
|
||||
raise CleanupException("rosclean is not supported on this platform")
|
||||
|
||||
def get_disk_usage(d):
|
||||
"""
|
||||
Get disk usage in bytes for directory
|
||||
@param d: directory path
|
||||
@type d: str
|
||||
@return: disk usage in bytes (du -b) or (du -A) * 1024
|
||||
@rtype: int
|
||||
@raise ROSCleanException: if get_disk_usage() cannot be used on this platform
|
||||
:param d: directory path, ``str``
|
||||
:returns: disk usage in bytes (du -b) or (du -A) * 1024, ``int``
|
||||
:raises: :exc:`CleanupException` If get_disk_usage() cannot be used on this platform
|
||||
"""
|
||||
# only implemented on Linux and FreeBSD for now. Should work on OS X but need to verify first (du is not identical)
|
||||
if platform.system() == 'Linux':
|
||||
try:
|
||||
return int(subprocess.Popen(['du', '-sb', d], stdout=subprocess.PIPE).communicate()[0].split()[0])
|
||||
except:
|
||||
raise ROSCleanException("rosclean is not supported on this platform")
|
||||
raise CleanupException("rosclean is not supported on this platform")
|
||||
elif platform.system() == 'FreeBSD':
|
||||
try:
|
||||
return int(subprocess.Popen(['du', '-sA', d], stdout=subprocess.PIPE).communicate()[0].split()[0]) * 1024
|
||||
except:
|
||||
raise ROSCleanException("rosclean is not supported on this platform")
|
||||
raise CleanupException("rosclean is not supported on this platform")
|
||||
else:
|
||||
raise ROSCleanException("rosclean is not supported on this platform")
|
||||
raise CleanupException("rosclean is not supported on this platform")
|
||||
|
||||
def _rosclean_cmd_purge(argv):
|
||||
dirs = _get_check_dirs()
|
||||
|
|
Loading…
Reference in New Issue