Commit e7641909 by Steve Strassmann

uncommit unneeded files

parent 6e34c668
......@@ -94,7 +94,7 @@ urlpatterns = ('',
# noop to squelch ajax errors
url(r'^event$', 'contentstore.views.event', name='event'),
url(r'^heartbeat$', include('heartbeat.urls'))
url(r'^heartbeat$', include('heartbeat.urls')),
)
# User creation and updating views
......
......@@ -93,7 +93,7 @@ clone_repos() {
### START
PROG=${0##*/}
BASE="$HOME/src/mitx_all"
BASE="$HOME/mitx_all"
PYTHON_DIR="$BASE/python"
RUBY_DIR="$BASE/ruby"
RUBY_VER="1.9.3"
......@@ -290,8 +290,7 @@ source $PYTHON_DIR/bin/activate
NUMPY_VER="1.6.2"
SCIPY_VER="0.10.1"
if [-z "false"]; then
if [[ -n $compile ]]; then
if [[ -n $compile ]]; then
output "Downloading numpy and scipy"
curl -sL -o numpy.tar.gz http://downloads.sourceforge.net/project/numpy/NumPy/${NUMPY_VER}/numpy-${NUMPY_VER}.tar.gz
curl -sL -o scipy.tar.gz http://downloads.sourceforge.net/project/scipy/scipy/${SCIPY_VER}/scipy-${SCIPY_VER}.tar.gz
......@@ -306,7 +305,6 @@ if [-z "false"]; then
python setup.py install
cd "$BASE"
rm -rf numpy-${NUMPY_VER} scipy-${SCIPY_VER}
fi
fi
case `uname -s` in
......
import urllib, urllib2, json
# Google Translate API
# see https://code.google.com/apis/language/translate/v2/getting_started.html
#
#
# usage: translate('flower', 'fr') => 'fleur'
# --------------------------------------------
# Translation limit = 100,000 chars/day (request submitted for more)
# Limit of 5,000 characters per request
# This key is personally registered to Steve Strassmann
#
#KEY = 'AIzaSyCDapmXdBtIYw3ofsvgm6gIYDNwiVmSm7g'
KEY = 'AIzaSyDOhTQokSOqqO-8ZJqUNgn12C83g-muIqA'
URL = 'https://www.googleapis.com/language/translate/v2'
SOURCE = 'en' # source: English
TARGETS = ['zh-CN', 'ja', 'fr', 'de', # tier 1: Simplified Chinese, Japanese, French, German
'es', 'it', # tier 2: Spanish, Italian
'ru'] # extra credit: Russian
def translate (string, target):
return extract(fetch(string, target))
# Ask Google to translate string to target language
# string: English string
# target: lang (e.g. 'fr', 'cn')
# Returns JSON object
def fetch (string, target, url=URL, key=KEY, source=SOURCE):
data = {'key':key,
'q':string,
'source': source,
'target':target}
fullUrl = '%s?%s' % (url, urllib.urlencode(data))
try:
response = urllib2.urlopen(fullUrl)
return json.loads(response.read())
except urllib2.HTTPError as err:
if err.code == 403:
print "***"
print "*** Possible daily limit exceeded for Google Translate:"
print "***"
print "***", json.loads("".join(err.readlines()))
print "***"
raise
# Extracts a translated result from a json object returned from Google
def extract (response):
data = response['data']
translations = data['translations']
first = translations[0]
result = first.get('translated_text', None)
if result != None:
return result
else:
result = first.get('translatedText', None)
if result != None:
return result
else:
raise Exception("Could not read translation from: %s" % translations)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment