Skip to content
This repository was archived by the owner on Feb 13, 2019. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions src/simian/util/link_module.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,26 @@ function find_module() {
python <<EOF
import imp
try:
print imp.find_module('$1')[1]
print imp.find_module('$1')[1]
except ImportError:
pass
pass
EOF
}

function find_sitepackage_module() {
python <<EOF
import os
import re
try:
user_paths = os.environ['PYTHONPATH'].split(os.pathsep)
except KeyError:
user_paths = []

pymod = '$1'
for path in user_paths:
for f in os.listdir(path):
if re.search(r'(' + pymod + ')', os.path.join(path, f), re.I):
print os.path.join(path, f)
EOF
}

Expand All @@ -21,6 +38,11 @@ function find_egg_file() {
if [[ ! -z "${egg}" ]]; then
echo "${egg}"
fi

egg=$(find .eggs -type f -maxdepth 1 -name ${module}-*.egg 2>/dev/null)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of two find blocks you could just add '.eggs' as a second argument to the find execution above

find . .eggs -type f ....

if [[ ! -z "${egg}" ]]; then
echo "${egg}"
fi
}

function find_egg_dir() {
Expand Down Expand Up @@ -53,6 +75,13 @@ function link_module() {
return
fi

local path=$(find_sitepackage_module ${module})
if [[ ! -z "${path}" ]]; then
rm -f "${GAE_BUNDLE}/${module}"
ln -s "${path}" "${GAE_BUNDLE}/${module}"
return
fi

echo "ERROR: path not found for ${module}. symlink creation failure."
exit 1
}
Expand Down