Skip to content

Commit ea13c17

Browse files
committed
Adding check for packaging
1 parent f416fe9 commit ea13c17

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

stashcp.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
import socket
1313
import random
1414
import shutil
15-
from pkg_resources import resource_string
15+
16+
try:
17+
from pkg_resources import resource_string
18+
except ImportError as e:
19+
resource_string = None
20+
1621

1722
import logging
1823
from urlparse import urlparse
@@ -493,10 +498,11 @@ def get_best_stashcache():
493498
cache_files = [ caches_json_location ]
494499
else:
495500
prefix = os.environ.get("OSG_LOCATION", "")
496-
cache_files = [resource_string(__name__, 'caches.json'),
497-
os.path.join(os.path.dirname(os.path.realpath(__file__)), "caches.json"),
501+
cache_files = [os.path.join(os.path.dirname(os.path.realpath(__file__)), "caches.json"),
498502
os.path.join(prefix, "/etc/stashcache/caches.json"),
499503
os.path.join(prefix, "/usr/share/stashcache/caches.json")]
504+
if resource_string:
505+
cache_files.insert(0, resource_string(__name__, 'caches.json'))
500506

501507
for cache_file in cache_files:
502508
if os.path.isfile(cache_file):

0 commit comments

Comments
 (0)