-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
142 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
retcode=0 | ||
ping_url="https://api.rosette.com/rest/v1" | ||
errors=( "Exception" "processingFailure" "badRequest" "ParseError" "ValueError" "SyntaxError" "AttributeError" "ImportError" ) | ||
|
||
#------------------ Functions ---------------------------------------------------- | ||
#Gets called when the user doesn't provide any args | ||
|
@@ -10,12 +11,14 @@ function HELP { | |
echo " API_KEY - Rosette API key (required)" | ||
echo " FILENAME - Python source file (optional)" | ||
echo " ALT_URL - Alternate service URL (optional)" | ||
echo " GIT_USERNAME - Git username where you would like to push regenerated gh-pages (optional)" | ||
echo " VERSION - Build version (optional)" | ||
echo "Compiles and runs the source file(s) using the local development source." | ||
exit 1 | ||
} | ||
|
||
if [ ! -z ${ALT_URL} ]; then | ||
ping_url=${ALT_URL} | ||
fi | ||
|
||
#Checks if Rosette API key is valid | ||
function checkAPI { | ||
match=$(curl "${ping_url}/ping" -H "X-RosetteAPI-Key: ${API_KEY}" | grep -o "forbidden") | ||
|
@@ -55,41 +58,25 @@ function runExample() { | |
fi | ||
echo "${result}" | ||
echo -e "\n---------- ${1} end -------------" | ||
if [[ "${result}" == *"Exception"* ]]; then | ||
echo "Exception found" | ||
retcode=1 | ||
elif [[ "$result" == *"processingFailure"* ]]; then | ||
retcode=1 | ||
elif [[ "$result" == *"AttributeError"* ]]; then | ||
retcode=1 | ||
elif [[ "$result" == *"ImportError"* ]]; then | ||
retcode=1 | ||
fi | ||
for err in "${errors[@]}"; do | ||
if [[ ${result} == *"${err}"* ]]; then | ||
retcode=1 | ||
fi | ||
done | ||
} | ||
#------------------ Functions End ------------------------------------------------ | ||
|
||
#Gets API_KEY, FILENAME and ALT_URL if present | ||
while getopts ":API_KEY:FILENAME:ALT_URL:GIT_USERNAME:VERSION" arg; do | ||
while getopts ":API_KEY:FILENAME:ALT_URL" arg; do | ||
case "${arg}" in | ||
API_KEY) | ||
API_KEY=${OPTARG} | ||
usage | ||
;; | ||
ALT_URL) | ||
ALT_URL=${OPTARG} | ||
usage | ||
;; | ||
FILENAME) | ||
FILENAME=${OPTARG} | ||
usage | ||
;; | ||
GIT_USERNAME) | ||
GIT_USERNAME=${OPTARG} | ||
usage | ||
;; | ||
VERSION) | ||
VERSION={OPTARG} | ||
usage | ||
;; | ||
esac | ||
done | ||
|
@@ -109,8 +96,10 @@ if [ ! -z ${API_KEY} ]; then | |
python /python-dev/setup.py install | ||
cd /python-dev/examples | ||
if [ ! -z ${FILENAME} ]; then | ||
echo -e "\nRunning example against: ${ping_url}\n" | ||
runExample ${FILENAME} | ||
else | ||
echo -e "\nRunning examples against: ${ping_url}\n" | ||
for file in *.py; do | ||
runExample ${file} | ||
done | ||
|
@@ -123,21 +112,4 @@ fi | |
cd /python-dev | ||
tox | ||
|
||
#Generate gh-pages and push them to git account (if git username is provided) | ||
if [ ! -z ${GIT_USERNAME} ] && [ ! -z ${VERSION} ]; then | ||
#clone python git repo | ||
cd / | ||
git clone [email protected]:${GIT_USERNAME}/python.git | ||
cd python | ||
git checkout origin/gh-pages -b gh-pages | ||
git branch -d develop | ||
#generate gh-pages and set ouput dir to git repo (gh-pages branch) | ||
cd /python-dev | ||
.tox/py27/bin/epydoc -v --no-private --no-frames --css epydoc.css -o /python rosette/*.py | ||
cd /python | ||
git add . | ||
git commit -a -m "publish python apidocs ${VERSION}" | ||
git push | ||
fi | ||
|
||
exit ${retcode} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ | |
limitations under the License. | ||
""" | ||
|
||
__version__ = '1.1.1' | ||
__version__ = '1.2.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.