Skip to content

Commit

Permalink
Merge pull request #106 from ddavila0/master
Browse files Browse the repository at this point in the history
making stashcp a package not a module  (SOFTWARE-3799)
  • Loading branch information
djw8605 authored Oct 2, 2019
2 parents df49515 + 992f9ad commit ff35fe4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 20 deletions.
23 changes: 14 additions & 9 deletions bin/stashcp2/tests/test_inside_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ rpm -Uvh https://repo.opensciencegrid.org/osg/3.3/osg-3.3-el${OS_VERSION}-releas

yum -y install osg-oasis

yum -y install python-pip

echo "user_allow_other" >> /etc/fuse.conf

echo "CVMFS_HTTP_PROXY=DIRECT" >> /etc/cvmfs/default.local
Expand All @@ -37,27 +39,30 @@ module load xrootd
# For now, disable pylint failures
#pylint /StashCache/bin/stashcp || /bin/true

# Install stashcp
pip install StashCache/

# Copy in the .job.ad file:
cp /StashCache/bin/stashcp2/tests/job.ad ./.job.ad

# Test against a file that is known to not exist
set +e
/StashCache/stashcp.py --cache=$XRD_CACHE /blah/does/not/exist ./
stashcp --cache=$XRD_CACHE /blah/does/not/exist ./
if [ $? -eq 0 ]; then
echo "Failed to exit with non-zero exit status when it should have"
exit 1
fi
set -e

# Try copying with no forward slash
/StashCache/stashcp.py --cache=$XRD_CACHE user/dweitzel/public/blast/queries/query1 ./
stashcp --cache=$XRD_CACHE user/dweitzel/public/blast/queries/query1 ./

result=`md5sum query1 | awk '{print $1;}'`

rm query1

# Try copying with different destintion filename
/StashCache/stashcp.py --cache=$XRD_CACHE -d /user/dweitzel/public/blast/queries/query1 query.test
stashcp --cache=$XRD_CACHE -d /user/dweitzel/public/blast/queries/query1 query.test

result=`md5sum query.test | awk '{print $1;}'`

Expand All @@ -68,7 +73,7 @@ fi
rm -f query.test

# Perform tests
/StashCache/stashcp.py --cache=$XRD_CACHE -d /user/dweitzel/public/blast/queries/query1 ./
stashcp --cache=$XRD_CACHE -d /user/dweitzel/public/blast/queries/query1 ./

result=`md5sum query1 | awk '{print $1;}'`

Expand All @@ -78,7 +83,7 @@ fi
rm -f query.test

# Perform methods test
/StashCache/stashcp.py --cache=$XRD_CACHE --method=cvmfs,xrootd -d /user/dweitzel/public/blast/queries/query1 ./
stashcp --cache=$XRD_CACHE --method=cvmfs,xrootd -d /user/dweitzel/public/blast/queries/query1 ./

result=`md5sum query1 | awk '{print $1;}'`

Expand All @@ -88,7 +93,7 @@ fi
rm -f query.test

# Perform methods test
/StashCache/stashcp.py --cache=$XRD_CACHE --method=xrootd -d /user/dweitzel/public/blast/queries/query1 ./
stashcp --cache=$XRD_CACHE --method=xrootd -d /user/dweitzel/public/blast/queries/query1 ./

result=`md5sum query1 | awk '{print $1;}'`

Expand All @@ -98,7 +103,7 @@ fi
rm -f query.test

# Perform methods test
/StashCache/stashcp.py --cache=$XRD_CACHE --method=http,xrootd -d /user/dweitzel/public/blast/queries/query1 ./
stashcp --cache=$XRD_CACHE --method=http,xrootd -d /user/dweitzel/public/blast/queries/query1 ./

result=`md5sum query1 | awk '{print $1;}'`

Expand All @@ -108,7 +113,7 @@ fi
rm -f query.test

# Scheme test
/StashCache/stashcp.py --cache=$XRD_CACHE --method=http,xrootd -d stash:///user/dweitzel/public/blast/queries/query1 file:///tmp
stashcp --cache=$XRD_CACHE --method=http,xrootd -d stash:///user/dweitzel/public/blast/queries/query1 file:///tmp

result=`md5sum /tmp/query1 | awk '{print $1;}'`

Expand All @@ -117,7 +122,7 @@ if [ "$result" != "12bdb9a96cd5e8ca469b727a81593201" ]; then
fi
rm -f query.test

/StashCache/stashcp.py --cache=$XRD_CACHE -d -r /user/dweitzel/public/blast/queries ./
stashcp --cache=$XRD_CACHE -d -r /user/dweitzel/public/blast/queries ./
ls -lah

rm -rf queries
Expand Down
8 changes: 5 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
# For a discussion on single-sourcing the version across setup.py and the
# project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='5.4.1', # Required
version='5.5.0', # Required

# This is a one-line description or tagline of what your project does. This
# corresponds to the "Summary" metadata field:
Expand Down Expand Up @@ -121,7 +121,8 @@
# the `py_modules` argument instead as follows, which will expect a file
# called `my_module.py` to exist:
#
py_modules=["stashcp"],
#py_modules=["stashcp"],
packages=["stashcp"],

#packages=find_packages(exclude=['contrib', 'docs', 'tests']), # Required

Expand Down Expand Up @@ -151,6 +152,7 @@
#
# If using Python 2.6 or earlier, then these have to be included in
# MANIFEST.in as well.
package_data={'stashcp': ['caches.json'],},
#package_data={ # Optional
# '': ['bin/caches.json'],
#},
Expand All @@ -160,7 +162,7 @@
# http://docs.python.org/3.4/distutils/setupscript.html#installing-additional-files
#
# In this case, 'data_file' will be installed into '<sys.prefix>/my_data'
data_files=[('', ['caches.json'])], # Optional
data_files=[('share/stashcache/', ['stashcp/caches.json'])],

# To provide executable scripts, use entry points in preference to the
# "scripts" keyword. Entry points provide cross-platform support and allow
Expand Down
16 changes: 8 additions & 8 deletions stashcp.py → stashcp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
from urlparse import urlparse

try:
from pkg_resources import resource_string
from pkg_resources import resource_filename
except ImportError as e:
resource_string = None
resource_filename = None


import logging
from urlparse import urlparse

# Version information for user-agent
VERSION = "5.4.1"
VERSION = "5.5.0"

main_redirector = "root://redirector.osgstorage.org"
stash_origin = "root://stash.osgconnect.net"
Expand Down Expand Up @@ -554,12 +554,12 @@ def get_best_stashcache():
cache_files = [ caches_json_location ]
else:
prefix = os.environ.get("OSG_LOCATION", "/")
cache_files = [os.path.join(os.path.dirname(os.path.realpath(__file__)), "caches.json"),
os.path.join(prefix, "etc/stashcache/caches.json"),
os.path.join(prefix, "usr/share/stashcache/caches.json")]
if resource_string:
cache_files = [os.path.join(prefix, "etc/stashcache/caches.json"),
os.path.join(prefix, "usr/share/stashcache/caches.json"),
os.path.join(prefix, "usr/local/share/stashcache/caches.json")]
if resource_filename:
try:
cache_files.insert(0, resource_string(__name__, 'caches.json'))
cache_files.append(resource_filename(__name__, 'caches.json'))
except IOError as ioe:
logging.debug("Unable to retrieve caches.json using resource string, trying other locations")

Expand Down
File renamed without changes.

0 comments on commit ff35fe4

Please sign in to comment.