+4
-4
@@ -25,12 +25,12 @@ install:
|
|||||||
virtualenv --python="$PYENV_ROOT/versions/pypy-$PYPY_VERSION/bin/python" "$HOME/virtualenvs/pypy-$PYPY_VERSION"
|
virtualenv --python="$PYENV_ROOT/versions/pypy-$PYPY_VERSION/bin/python" "$HOME/virtualenvs/pypy-$PYPY_VERSION"
|
||||||
source "$HOME/virtualenvs/pypy-$PYPY_VERSION/bin/activate"
|
source "$HOME/virtualenvs/pypy-$PYPY_VERSION/bin/activate"
|
||||||
fi
|
fi
|
||||||
- if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then pip install --download-cache $HOME/.pip-cache pycrypto pg8000 pymysql; fi;
|
- if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then pip install pycrypto pg8000 pymysql; fi;
|
||||||
- if [[ $TRAVIS_PYTHON_VERSION != '3.5' ]]; then pip install -e .; fi;
|
- if [[ $TRAVIS_PYTHON_VERSION != '3.5' ]]; then pip install -e .; fi;
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then pip install --download-cache $HOME/.pip-cache coverage; fi;
|
- pip install coverage
|
||||||
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then pip install --download-cache $HOME/.pip-cache codecov; fi
|
- pip install codecov
|
||||||
- mysql -e 'create database pydal;'
|
- mysql -e 'create database pydal;'
|
||||||
- psql -c 'create database pydal;' -U postgres
|
- psql -c 'create database pydal;' -U postgres
|
||||||
- psql -c 'create extension postgis;' -U postgres -d pydal;
|
- psql -c 'create extension postgis;' -U postgres -d pydal;
|
||||||
@@ -41,7 +41,7 @@ script: export COVERAGE_PROCESS_START=gluon/tests/coverage.ini; ./web2py.py --ru
|
|||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
- coverage combine;
|
- coverage combine;
|
||||||
- if [[ $TRAVIS_PYTHON_VERSION == '2.7' ]]; then codecov; fi
|
- codecov
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
email: true
|
email: true
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import cStringIO
|
#import gluon.contrib.shell
|
||||||
import gluon.contrib.shell
|
|
||||||
import gluon.dal
|
import gluon.dal
|
||||||
import gluon.html
|
import gluon.html
|
||||||
import gluon.validators
|
import gluon.validators
|
||||||
import code
|
import code
|
||||||
import thread
|
|
||||||
from gluon.debug import communicate, web_debugger, qdb_debugger
|
from gluon.debug import communicate, web_debugger, qdb_debugger
|
||||||
|
from gluon._compat import thread
|
||||||
import pydoc
|
import pydoc
|
||||||
|
|
||||||
|
|
||||||
@@ -122,7 +121,7 @@ def execute():
|
|||||||
output = web_debugger.do_exec(command)
|
output = web_debugger.do_exec(command)
|
||||||
if output is None:
|
if output is None:
|
||||||
output = ""
|
output = ""
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
output = T("Exception %s") % str(e)
|
output = T("Exception %s") % str(e)
|
||||||
k = len(session['debug_commands:' + app]) - 1
|
k = len(session['debug_commands:' + app]) - 1
|
||||||
return '[%i] %s%s\n' % (k + 1, command, output)
|
return '[%i] %s%s\n' % (k + 1, command, output)
|
||||||
@@ -212,7 +211,7 @@ def toggle_breakpoint():
|
|||||||
ok = True
|
ok = True
|
||||||
else:
|
else:
|
||||||
response.flash = T("Unable to determine the line number!")
|
response.flash = T("Unable to determine the line number!")
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
session.flash = str(e)
|
session.flash = str(e)
|
||||||
return response.json({'ok': ok, 'lineno': lineno})
|
return response.json({'ok': ok, 'lineno': lineno})
|
||||||
|
|
||||||
@@ -233,6 +232,6 @@ def list_breakpoints():
|
|||||||
if filename == bp_filename:
|
if filename == bp_filename:
|
||||||
breakpoints.append(bp_lineno)
|
breakpoints.append(bp_lineno)
|
||||||
ok = True
|
ok = True
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
session.flash = str(e)
|
session.flash = str(e)
|
||||||
return response.json({'ok': ok, 'breakpoints': breakpoints})
|
return response.json({'ok': ok, 'breakpoints': breakpoints})
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ from gluon.utils import web2py_uuid
|
|||||||
from gluon.tools import Config
|
from gluon.tools import Config
|
||||||
from gluon.compileapp import find_exposed_functions
|
from gluon.compileapp import find_exposed_functions
|
||||||
from glob import glob
|
from glob import glob
|
||||||
from gluon._compat import iteritems, PY2
|
from gluon._compat import iteritems, PY2, pickle, xrange, urlopen, to_bytes
|
||||||
import shutil
|
import shutil
|
||||||
import platform
|
import platform
|
||||||
|
|
||||||
@@ -127,7 +127,6 @@ def index():
|
|||||||
redirect(send)
|
redirect(send)
|
||||||
elif failed_login_count() >= allowed_number_of_attempts:
|
elif failed_login_count() >= allowed_number_of_attempts:
|
||||||
time.sleep(2 ** allowed_number_of_attempts)
|
time.sleep(2 ** allowed_number_of_attempts)
|
||||||
print('4033')
|
|
||||||
raise HTTP(403)
|
raise HTTP(403)
|
||||||
elif request.vars.password:
|
elif request.vars.password:
|
||||||
if verify_password(request.vars.password[:1024]):
|
if verify_password(request.vars.password[:1024]):
|
||||||
@@ -274,7 +273,7 @@ def site():
|
|||||||
elif form_update.vars.url:
|
elif form_update.vars.url:
|
||||||
# fetch an application via URL or file upload
|
# fetch an application via URL or file upload
|
||||||
try:
|
try:
|
||||||
f = urllib.urlopen(form_update.vars.url)
|
f = urlopen(form_update.vars.url)
|
||||||
if f.code == 404:
|
if f.code == 404:
|
||||||
raise Exception("404 file not found")
|
raise Exception("404 file not found")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -387,7 +386,7 @@ def pack_exe(app, base, filenames=None):
|
|||||||
# Download latest web2py_win and open it with zipfile
|
# Download latest web2py_win and open it with zipfile
|
||||||
download_url = 'http://www.web2py.com/examples/static/web2py_win.zip'
|
download_url = 'http://www.web2py.com/examples/static/web2py_win.zip'
|
||||||
out = StringIO()
|
out = StringIO()
|
||||||
out.write(urllib.urlopen(download_url).read())
|
out.write(urlopen(download_url).read())
|
||||||
web2py_win = zipfile.ZipFile(out, mode='a')
|
web2py_win = zipfile.ZipFile(out, mode='a')
|
||||||
# Write routes.py with the application as default
|
# Write routes.py with the application as default
|
||||||
routes = u'# -*- coding: utf-8 -*-\nrouters = dict(BASE=dict(default_application="%s"))' % app
|
routes = u'# -*- coding: utf-8 -*-\nrouters = dict(BASE=dict(default_application="%s"))' % app
|
||||||
@@ -858,7 +857,7 @@ def todolist():
|
|||||||
for f in listfiles(app, d):
|
for f in listfiles(app, d):
|
||||||
matches = []
|
matches = []
|
||||||
filename = apath(os.path.join(app, d, f), r=request)
|
filename = apath(os.path.join(app, d, f), r=request)
|
||||||
with open(filename, 'r') as f_s:
|
with safe_open(filename, 'r') as f_s:
|
||||||
src = f_s.read()
|
src = f_s.read()
|
||||||
for m in regex.finditer(src):
|
for m in regex.finditer(src):
|
||||||
start = m.start()
|
start = m.start()
|
||||||
@@ -1575,7 +1574,6 @@ def errors():
|
|||||||
""" Error handler """
|
""" Error handler """
|
||||||
import operator
|
import operator
|
||||||
import os
|
import os
|
||||||
import pickle
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
app = get_app()
|
app = get_app()
|
||||||
@@ -1605,7 +1603,7 @@ def errors():
|
|||||||
if not os.path.isfile(fullpath):
|
if not os.path.isfile(fullpath):
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
fullpath_file = open(fullpath, 'r')
|
fullpath_file = safe_open(fullpath, 'rb')
|
||||||
try:
|
try:
|
||||||
error = pickle.load(fullpath_file)
|
error = pickle.load(fullpath_file)
|
||||||
finally:
|
finally:
|
||||||
@@ -1615,7 +1613,7 @@ def errors():
|
|||||||
except EOFError:
|
except EOFError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
hash = hashlib.md5(error['traceback']).hexdigest()
|
hash = hashlib.md5(to_bytes(error['traceback'])).hexdigest()
|
||||||
|
|
||||||
if hash in delete_hashes:
|
if hash in delete_hashes:
|
||||||
os.unlink(fullpath)
|
os.unlink(fullpath)
|
||||||
@@ -1710,7 +1708,7 @@ def get_ticket_storage(app):
|
|||||||
private_folder = apath('%s/private' % app, r=request)
|
private_folder = apath('%s/private' % app, r=request)
|
||||||
ticket_file = os.path.join(private_folder, 'ticket_storage.txt')
|
ticket_file = os.path.join(private_folder, 'ticket_storage.txt')
|
||||||
if os.path.exists(ticket_file):
|
if os.path.exists(ticket_file):
|
||||||
db_string = open(ticket_file).read()
|
db_string = safe_open(ticket_file).read()
|
||||||
db_string = db_string.strip().replace('\r', '').replace('\n', '')
|
db_string = db_string.strip().replace('\r', '').replace('\n', '')
|
||||||
elif is_gae:
|
elif is_gae:
|
||||||
# use Datastore as fallback if there is no ticket_file
|
# use Datastore as fallback if there is no ticket_file
|
||||||
@@ -1965,9 +1963,9 @@ def plugins():
|
|||||||
from serializers import loads_json
|
from serializers import loads_json
|
||||||
if not session.plugins:
|
if not session.plugins:
|
||||||
try:
|
try:
|
||||||
rawlist = urllib.urlopen("http://www.web2pyslices.com/" +
|
rawlist = urlopen("http://www.web2pyslices.com/" +
|
||||||
"public/api.json/action/list/content/Package?package" +
|
"public/api.json/action/list/content/Package?package" +
|
||||||
"_type=plugin&search_index=false").read()
|
"_type=plugin&search_index=false").read()
|
||||||
session.plugins = loads_json(rawlist)
|
session.plugins = loads_json(rawlist)
|
||||||
except:
|
except:
|
||||||
response.flash = T('Unable to download the list of plugins')
|
response.flash = T('Unable to download the list of plugins')
|
||||||
@@ -1993,7 +1991,7 @@ def install_plugin():
|
|||||||
source.split("web2py.plugin.")[-1].split(".w2p")[0]
|
source.split("web2py.plugin.")[-1].split(".w2p")[0]
|
||||||
else:
|
else:
|
||||||
filename = "web2py.plugin.%s.w2p" % cleanpath(plugin)
|
filename = "web2py.plugin.%s.w2p" % cleanpath(plugin)
|
||||||
if plugin_install(app, urllib.urlopen(source),
|
if plugin_install(app, urlopen(source),
|
||||||
request, filename):
|
request, filename):
|
||||||
session.flash = T('New plugin installed: %s', filename)
|
session.flash = T('New plugin installed: %s', filename)
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ def attach_debugger(host='localhost', port=6000, authkey='secret password'):
|
|||||||
gluon.debug.qdb_debugger = qdb.Qdb(gluon.debug.qdb_connection)
|
gluon.debug.qdb_debugger = qdb.Qdb(gluon.debug.qdb_connection)
|
||||||
gluon.debug.dbg = gluon.debug.qdb_debugger
|
gluon.debug.dbg = gluon.debug.qdb_debugger
|
||||||
# welcome message (this should be displayed on the frontend)
|
# welcome message (this should be displayed on the frontend)
|
||||||
print 'debugger connected to', gluon.debug.qdb_listener.last_accepted
|
print('debugger connected to', gluon.debug.qdb_listener.last_accepted)
|
||||||
return True # connection successful!
|
return True # connection successful!
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -516,7 +516,7 @@ def create(options):
|
|||||||
plugin_name = 'web2py.plugin.' + plugin + '.w2p'
|
plugin_name = 'web2py.plugin.' + plugin + '.w2p'
|
||||||
stream = urllib.urlopen(PLUGINS_APP + '/static/' + plugin_name)
|
stream = urllib.urlopen(PLUGINS_APP + '/static/' + plugin_name)
|
||||||
plugin_install(app, stream, request, plugin_name)
|
plugin_install(app, stream, request, plugin_name)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
session.flash = T("unable to download plugin: %s" % plugin)
|
session.flash = T("unable to download plugin: %s" % plugin)
|
||||||
|
|
||||||
### write configuration file into newapp/models/0.py
|
### write configuration file into newapp/models/0.py
|
||||||
|
|||||||
@@ -118,7 +118,7 @@
|
|||||||
<div class="hide inspect" id="session"><h6>session</h6>{{=BEAUTIFY(snapshot['session'])}}</div>
|
<div class="hide inspect" id="session"><h6>session</h6>{{=BEAUTIFY(snapshot['session'])}}</div>
|
||||||
<div class="hide inspect" id="response"><h6>response</h6>{{=BEAUTIFY(snapshot['response'])}}</div>
|
<div class="hide inspect" id="response"><h6>response</h6>{{=BEAUTIFY(snapshot['response'])}}</div>
|
||||||
</div>
|
</div>
|
||||||
{{except Exception, e:}}
|
{{except Exception as e:}}
|
||||||
<!-- this should not happen, just in case... (cannot output normal hmtl as we don't know current open tags) -->
|
<!-- this should not happen, just in case... (cannot output normal hmtl as we don't know current open tags) -->
|
||||||
{{import traceback;tb=traceback.format_exc().replace("\n","\\n") }}
|
{{import traceback;tb=traceback.format_exc().replace("\n","\\n") }}
|
||||||
<script language='javascript'>alert("Exception during snapshot rendering: {{=tb}} ");</script>
|
<script language='javascript'>alert("Exception during snapshot rendering: {{=tb}} ");</script>
|
||||||
|
|||||||
@@ -117,7 +117,7 @@
|
|||||||
<div class="hide inspect" id="session"><h6>session</h6>{{=BEAUTIFY(snapshot['session'])}}</div>
|
<div class="hide inspect" id="session"><h6>session</h6>{{=BEAUTIFY(snapshot['session'])}}</div>
|
||||||
<div class="hide inspect" id="response"><h6>response</h6>{{=BEAUTIFY(snapshot['response'])}}</div>
|
<div class="hide inspect" id="response"><h6>response</h6>{{=BEAUTIFY(snapshot['response'])}}</div>
|
||||||
</div>
|
</div>
|
||||||
{{except Exception, e:}}
|
{{except Exception as e:}}
|
||||||
<!-- this should not happen, just in case... (cannot output normal hmtl as we don't know current open tags) -->
|
<!-- this should not happen, just in case... (cannot output normal hmtl as we don't know current open tags) -->
|
||||||
{{import traceback;tb=traceback.format_exc().replace("\n","\\n") }}
|
{{import traceback;tb=traceback.format_exc().replace("\n","\\n") }}
|
||||||
<script language='javascript'>alert("Exception during snapshot rendering: {{=tb}} ");</script>
|
<script language='javascript'>alert("Exception during snapshot rendering: {{=tb}} ");</script>
|
||||||
|
|||||||
@@ -23,4 +23,4 @@ jQuery(document).ready(function() {
|
|||||||
jQuery.plot(jQuery("#placeholder"), [ {{=progress}} ]);
|
jQuery.plot(jQuery("#placeholder"), [ {{=progress}} ]);
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
<!-- end "about" block -->
|
<!-- end "about" block -->
|
||||||
|
|||||||
@@ -67,7 +67,6 @@ def deletefile(arglist, vars={}):
|
|||||||
**{'_data-placement':'right',
|
**{'_data-placement':'right',
|
||||||
'_data-original-title':T('Delete this file (you will be asked to confirm deletion)')})
|
'_data-original-title':T('Delete this file (you will be asked to confirm deletion)')})
|
||||||
}}
|
}}
|
||||||
|
|
||||||
{{block sectionclass}}design{{end}}
|
{{block sectionclass}}design{{end}}
|
||||||
<!-- begin "design" block -->
|
<!-- begin "design" block -->
|
||||||
|
|
||||||
@@ -120,7 +119,7 @@ def deletefile(arglist, vars={}):
|
|||||||
{{=peekfile('models',m, dict(id=id))}}
|
{{=peekfile('models',m, dict(id=id))}}
|
||||||
</span>
|
</span>
|
||||||
<span class="extras">
|
<span class="extras">
|
||||||
{{if len(defines[m]):}}{{=T("defines tables")}} {{pass}}{{=XML(', '.join([B(table).xml() for table in defines[m]]))}}
|
{{if len(defines[m]):}}{{=T("defines tables")}} {{pass}}{{=XML(b', '.join([B(table).xml() for table in defines[m]]))}}
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
{{pass}}
|
{{pass}}
|
||||||
@@ -133,7 +132,6 @@ def deletefile(arglist, vars={}):
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- FIND CONTROLLER FUNCTIONS -->
|
<!-- FIND CONTROLLER FUNCTIONS -->
|
||||||
{{
|
{{
|
||||||
controller_functions=[]
|
controller_functions=[]
|
||||||
@@ -168,7 +166,7 @@ for c in controllers: controller_functions+=[c[:-3]+'/%s.html'%x for x in functi
|
|||||||
{{=peekfile('controllers',c, dict(id=id))}}
|
{{=peekfile('controllers',c, dict(id=id))}}
|
||||||
</span>
|
</span>
|
||||||
<span class="extras celled">
|
<span class="extras celled">
|
||||||
{{if functions[c]:}}{{=T("exposes")}}{{pass}} {{=XML(', '.join([A(f,_href=URL(a=app,c=c[:-3],f=f)).xml() for f in functions[c]]))}}
|
{{if functions[c]:}}{{=T("exposes")}}{{pass}} {{=XML(b', '.join([A(f,_href=URL(a=app,c=c[:-3],f=f)).xml() for f in functions[c]]))}}
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
{{pass}}
|
{{pass}}
|
||||||
@@ -208,7 +206,7 @@ for c in controllers: controller_functions+=[c[:-3]+'/%s.html'%x for x in functi
|
|||||||
</span>
|
</span>
|
||||||
<span class="extras celled celled-one">
|
<span class="extras celled celled-one">
|
||||||
{{if c in extend:}}{{=T("extends")}} <b>{{=extend[c]}}</b> {{pass}}
|
{{if c in extend:}}{{=T("extends")}} <b>{{=extend[c]}}</b> {{pass}}
|
||||||
{{if include[c]:}}{{=T("includes")}} {{pass}}{{=XML(', '.join([B(f).xml() for f in include[c]]))}}
|
{{if include[c]:}}{{=T("includes")}} {{pass}}{{=XML(b', '.join([B(f).xml() for f in include[c]]))}}
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
{{pass}}
|
{{pass}}
|
||||||
|
|||||||
@@ -25,11 +25,11 @@
|
|||||||
<p class="formfield">
|
<p class="formfield">
|
||||||
{{if functions:}}
|
{{if functions:}}
|
||||||
<span style="text-align:left;" class="exposed">
|
<span style="text-align:left;" class="exposed">
|
||||||
{{=B(T('exposes:'))}} {{=XML(', '.join([A(f,_target="_blank", _href=URL(a=app,c=controller,f=f)).xml() for f in functions]))}}
|
{{=B(T('exposes:'))}} {{=XML(b', '.join([A(f,_target="_blank", _href=URL(a=app,c=controller,f=f)).xml() for f in functions]))}}
|
||||||
</span>
|
</span>
|
||||||
{{if editviewlinks:}}<br/>
|
{{if editviewlinks:}}<br/>
|
||||||
{{=B(T('edit views:'))}}
|
{{=B(T('edit views:'))}}
|
||||||
{{=XML(', '.join([v.xml() for v in editviewlinks]))}}
|
{{=XML(b', '.join([v.xml() for v in editviewlinks]))}}
|
||||||
{{pass}}
|
{{pass}}
|
||||||
{{pass}}
|
{{pass}}
|
||||||
{{if edit_controller:}}
|
{{if edit_controller:}}
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ elif request.args(0)=='edit':
|
|||||||
input = tr[1][0]
|
input = tr[1][0]
|
||||||
help = tr[2][0]
|
help = tr[2][0]
|
||||||
new_form_flds.append(label)
|
new_form_flds.append(label)
|
||||||
print label
|
print(label)
|
||||||
new_form_flds.append(input)
|
new_form_flds.append(input)
|
||||||
new_form_flds.append(help)
|
new_form_flds.append(help)
|
||||||
pass
|
pass
|
||||||
@@ -160,4 +160,4 @@ pass
|
|||||||
}}
|
}}
|
||||||
|
|
||||||
<h2>{{=T('Manage Admin Users/Students')}}</h2>
|
<h2>{{=T('Manage Admin Users/Students')}}</h2>
|
||||||
{{=grid}}
|
{{=grid}}
|
||||||
|
|||||||
+3
-7
@@ -14,7 +14,6 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
import zipfile
|
import zipfile
|
||||||
import urllib
|
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
from gluon.utils import web2py_uuid
|
from gluon.utils import web2py_uuid
|
||||||
from gluon.fileutils import w2p_pack, w2p_unpack, w2p_pack_plugin, w2p_unpack_plugin
|
from gluon.fileutils import w2p_pack, w2p_unpack, w2p_pack_plugin, w2p_unpack_plugin
|
||||||
@@ -23,7 +22,7 @@ from gluon.fileutils import read_file, write_file, parse_version
|
|||||||
from gluon.restricted import RestrictedError
|
from gluon.restricted import RestrictedError
|
||||||
from gluon.settings import global_settings
|
from gluon.settings import global_settings
|
||||||
from gluon.cache import CacheOnDisk
|
from gluon.cache import CacheOnDisk
|
||||||
|
from gluon._compat import urlopen, to_native
|
||||||
|
|
||||||
if not global_settings.web2py_runtime_gae:
|
if not global_settings.web2py_runtime_gae:
|
||||||
import site
|
import site
|
||||||
@@ -60,8 +59,6 @@ def app_pack(app, request, raise_ex=False, filenames=None):
|
|||||||
w2p_pack(filename, apath(app, request), filenames=filenames)
|
w2p_pack(filename, apath(app, request), filenames=filenames)
|
||||||
return filename
|
return filename
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
import traceback
|
|
||||||
print(traceback.format_exc())
|
|
||||||
if raise_ex:
|
if raise_ex:
|
||||||
raise
|
raise
|
||||||
return False
|
return False
|
||||||
@@ -338,8 +335,7 @@ def check_new_version(myversion, version_url):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
from urllib import urlopen
|
version = to_native(urlopen(version_url).read())
|
||||||
version = urlopen(version_url).read()
|
|
||||||
pversion = parse_version(version)
|
pversion = parse_version(version)
|
||||||
pmyversion = parse_version(myversion)
|
pmyversion = parse_version(myversion)
|
||||||
except IOError:
|
except IOError:
|
||||||
@@ -423,7 +419,7 @@ def upgrade(request, url='http://web2py.com'):
|
|||||||
full_url = url + '/examples/static/web2py_%s.zip' % version_type
|
full_url = url + '/examples/static/web2py_%s.zip' % version_type
|
||||||
filename = abspath('web2py_%s_downloaded.zip' % version_type)
|
filename = abspath('web2py_%s_downloaded.zip' % version_type)
|
||||||
try:
|
try:
|
||||||
write_file(filename, urllib.urlopen(full_url).read(), 'wb')
|
write_file(filename, urlopen(full_url).read(), 'wb')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return False, e
|
return False, e
|
||||||
try:
|
try:
|
||||||
|
|||||||
+10
-9
@@ -18,7 +18,7 @@ import fnmatch
|
|||||||
import os
|
import os
|
||||||
import copy
|
import copy
|
||||||
import random
|
import random
|
||||||
from gluon._compat import builtin, PY2, unicodeT, to_native, to_bytes, iteritems, basestring
|
from gluon._compat import builtin, PY2, unicodeT, to_native, to_bytes, iteritems, basestring, reduce, xrange, long
|
||||||
from gluon.storage import Storage, List
|
from gluon.storage import Storage, List
|
||||||
from gluon.template import parse_template
|
from gluon.template import parse_template
|
||||||
from gluon.restricted import restricted, compile2
|
from gluon.restricted import restricted, compile2
|
||||||
@@ -44,18 +44,15 @@ from functools import reduce
|
|||||||
logger = logging.getLogger("web2py")
|
logger = logging.getLogger("web2py")
|
||||||
from gluon import rewrite
|
from gluon import rewrite
|
||||||
from gluon.custom_import import custom_import_install
|
from gluon.custom_import import custom_import_install
|
||||||
|
import py_compile
|
||||||
try:
|
|
||||||
import py_compile
|
|
||||||
except:
|
|
||||||
logger.warning('unable to import py_compile')
|
|
||||||
|
|
||||||
is_pypy = settings.global_settings.is_pypy
|
is_pypy = settings.global_settings.is_pypy
|
||||||
is_gae = settings.global_settings.web2py_runtime_gae
|
is_gae = settings.global_settings.web2py_runtime_gae
|
||||||
is_jython = settings.global_settings.is_jython
|
is_jython = settings.global_settings.is_jython
|
||||||
|
|
||||||
pjoin = os.path.join
|
pjoin = os.path.join
|
||||||
|
|
||||||
|
marshal_header_size = 8 if PY2 else 12
|
||||||
|
|
||||||
TEST_CODE = \
|
TEST_CODE = \
|
||||||
r"""
|
r"""
|
||||||
def _TEST():
|
def _TEST():
|
||||||
@@ -400,6 +397,9 @@ _base_environment_['PY2'] = PY2
|
|||||||
_base_environment_['to_native'] = to_native
|
_base_environment_['to_native'] = to_native
|
||||||
_base_environment_['to_bytes'] = to_bytes
|
_base_environment_['to_bytes'] = to_bytes
|
||||||
_base_environment_['iteritems'] = iteritems
|
_base_environment_['iteritems'] = iteritems
|
||||||
|
_base_environment_['reduce'] = reduce
|
||||||
|
_base_environment_['xrange'] = xrange
|
||||||
|
|
||||||
|
|
||||||
def build_environment(request, response, session, store_current=True):
|
def build_environment(request, response, session, store_current=True):
|
||||||
"""
|
"""
|
||||||
@@ -453,7 +453,8 @@ def save_pyc(filename):
|
|||||||
"""
|
"""
|
||||||
Bytecode compiles the file `filename`
|
Bytecode compiles the file `filename`
|
||||||
"""
|
"""
|
||||||
py_compile.compile(filename)
|
cfile = "%sc" % filename
|
||||||
|
py_compile.compile(filename, cfile=cfile)
|
||||||
|
|
||||||
|
|
||||||
def read_pyc(filename):
|
def read_pyc(filename):
|
||||||
@@ -467,7 +468,7 @@ def read_pyc(filename):
|
|||||||
data = read_file(filename, 'rb')
|
data = read_file(filename, 'rb')
|
||||||
if not is_gae and data[:4] != imp.get_magic():
|
if not is_gae and data[:4] != imp.get_magic():
|
||||||
raise SystemError('compiled code is incompatible')
|
raise SystemError('compiled code is incompatible')
|
||||||
return marshal.loads(data[8:])
|
return marshal.loads(data[marshal_header_size:])
|
||||||
|
|
||||||
|
|
||||||
def compile_views(folder, skip_failed_views=False):
|
def compile_views(folder, skip_failed_views=False):
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import re
|
import re
|
||||||
import urllib
|
import urllib
|
||||||
from gluon._compat import maketrans, urllib_quote, unicodeT, _local_html_escape, to_bytes, to_native, _local_html_escape as escape
|
from gluon._compat import maketrans, urllib_quote, unicodeT, _local_html_escape, to_bytes, to_native, _local_html_escape as escape, xrange
|
||||||
from ast import parse as ast_parse
|
from ast import parse as ast_parse
|
||||||
import ast
|
import ast
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -13,8 +13,8 @@ Debugger support classes
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
import pdb
|
import pdb
|
||||||
import Queue
|
|
||||||
import sys
|
import sys
|
||||||
|
from gluon._compat import Queue
|
||||||
|
|
||||||
logger = logging.getLogger("web2py")
|
logger = logging.getLogger("web2py")
|
||||||
|
|
||||||
|
|||||||
+10
-5
@@ -97,14 +97,19 @@ def parse_version(version):
|
|||||||
return version_tuple
|
return version_tuple
|
||||||
|
|
||||||
|
|
||||||
def read_file(filename, mode='r'):
|
def open_file(filename, mode):
|
||||||
"""Returns content from filename, making sure to close the file explicitly
|
|
||||||
on exit.
|
|
||||||
"""
|
|
||||||
if PY2 or 'b' in mode:
|
if PY2 or 'b' in mode:
|
||||||
f = open(filename, mode)
|
f = open(filename, mode)
|
||||||
else:
|
else:
|
||||||
f = open(filename, mode, encoding="utf8")
|
f = open(filename, mode, encoding="utf8")
|
||||||
|
return f
|
||||||
|
|
||||||
|
|
||||||
|
def read_file(filename, mode='r'):
|
||||||
|
"""Returns content from filename, making sure to close the file explicitly
|
||||||
|
on exit.
|
||||||
|
"""
|
||||||
|
f = open_file(filename, mode)
|
||||||
try:
|
try:
|
||||||
return f.read()
|
return f.read()
|
||||||
finally:
|
finally:
|
||||||
@@ -115,7 +120,7 @@ def write_file(filename, value, mode='w'):
|
|||||||
"""Writes <value> to filename, making sure to close the file
|
"""Writes <value> to filename, making sure to close the file
|
||||||
explicitly on exit.
|
explicitly on exit.
|
||||||
"""
|
"""
|
||||||
f = open(filename, mode)
|
f = open_file(filename, mode)
|
||||||
try:
|
try:
|
||||||
return f.write(value)
|
return f.write(value)
|
||||||
finally:
|
finally:
|
||||||
|
|||||||
+6
-4
@@ -596,17 +596,18 @@ class XML(XmlComponent):
|
|||||||
for A, IMG and BlockQuote).
|
for A, IMG and BlockQuote).
|
||||||
The key is the tag; the value is a list of allowed attributes.
|
The key is the tag; the value is a list of allowed attributes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if sanitize:
|
if sanitize:
|
||||||
text = sanitizer.sanitize(text, permitted_tags, allowed_attributes)
|
text = sanitizer.sanitize(text, permitted_tags, allowed_attributes)
|
||||||
if isinstance(text, unicodeT):
|
if isinstance(text, unicodeT):
|
||||||
text = to_native(text.encode('utf8', 'xmlcharrefreplace'))
|
text = to_native(text.encode('utf8', 'xmlcharrefreplace'))
|
||||||
|
elif isinstance(text, bytes):
|
||||||
|
text = to_native(text)
|
||||||
elif not isinstance(text, str):
|
elif not isinstance(text, str):
|
||||||
text = str(text)
|
text = str(text)
|
||||||
self.text = to_bytes(text)
|
self.text = text
|
||||||
|
|
||||||
def xml(self):
|
def xml(self):
|
||||||
return self.text
|
return to_bytes(self.text)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.text
|
return self.text
|
||||||
@@ -2826,7 +2827,8 @@ class MARKMIN(XmlComponent):
|
|||||||
return to_bytes(html) if not self.kwargs else to_bytes(DIV(XML(html), **self.kwargs).xml())
|
return to_bytes(html) if not self.kwargs else to_bytes(DIV(XML(html), **self.kwargs).xml())
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.xml()
|
# In PY3 __str__ cannot return bytes (TypeError: __str__ returned non-string (type bytes))
|
||||||
|
return to_native(self.xml())
|
||||||
|
|
||||||
|
|
||||||
def ASSIGNJS(**kargs):
|
def ASSIGNJS(**kargs):
|
||||||
|
|||||||
+1
-1
@@ -482,7 +482,7 @@ def wsgibase(environ, responder):
|
|||||||
if request.ajax:
|
if request.ajax:
|
||||||
if response.flash:
|
if response.flash:
|
||||||
http_response.headers['web2py-component-flash'] = \
|
http_response.headers['web2py-component-flash'] = \
|
||||||
urllib2.quote(xmlescape(response.flash).replace('\n', ''))
|
urllib2.quote(xmlescape(response.flash).replace(b'\n', b''))
|
||||||
if response.js:
|
if response.js:
|
||||||
http_response.headers['web2py-component-command'] = \
|
http_response.headers['web2py-component-command'] = \
|
||||||
urllib2.quote(response.js.replace('\n', ''))
|
urllib2.quote(response.js.replace('\n', ''))
|
||||||
|
|||||||
+3
-23
@@ -11,7 +11,7 @@ import errno
|
|||||||
import socket
|
import socket
|
||||||
import logging
|
import logging
|
||||||
import platform
|
import platform
|
||||||
from gluon._compat import iteritems, to_bytes
|
from gluon._compat import iteritems, to_bytes, StringIO, urllib_unquote
|
||||||
|
|
||||||
# Define Constants
|
# Define Constants
|
||||||
VERSION = '1.2.6'
|
VERSION = '1.2.6'
|
||||||
@@ -182,13 +182,6 @@ class Connection(object):
|
|||||||
|
|
||||||
# Import System Modules
|
# Import System Modules
|
||||||
import socket
|
import socket
|
||||||
try:
|
|
||||||
from io import StringIO
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
from cStringIO import StringIO
|
|
||||||
except ImportError:
|
|
||||||
from StringIO import StringIO
|
|
||||||
# Import Package Modules
|
# Import Package Modules
|
||||||
# package imports removed in monolithic build
|
# package imports removed in monolithic build
|
||||||
|
|
||||||
@@ -1179,19 +1172,6 @@ from wsgiref.headers import Headers
|
|||||||
from threading import Thread
|
from threading import Thread
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
try:
|
|
||||||
from urllib import unquote
|
|
||||||
except ImportError:
|
|
||||||
from urllib.parse import unquote
|
|
||||||
|
|
||||||
try:
|
|
||||||
from io import StringIO
|
|
||||||
except ImportError:
|
|
||||||
try:
|
|
||||||
from cStringIO import StringIO
|
|
||||||
except ImportError:
|
|
||||||
from StringIO import StringIO
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from ssl import SSLError
|
from ssl import SSLError
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@@ -1436,7 +1416,7 @@ class Worker(Thread):
|
|||||||
req[k] = ""
|
req[k] = ""
|
||||||
if k == 'path':
|
if k == 'path':
|
||||||
req['path'] = r'%2F'.join(
|
req['path'] = r'%2F'.join(
|
||||||
[unquote(x) for x in re_SLASH.split(v)])
|
[urllib_unquote(x) for x in re_SLASH.split(v)])
|
||||||
|
|
||||||
self.protocol = req['protocol']
|
self.protocol = req['protocol']
|
||||||
return req
|
return req
|
||||||
@@ -1471,7 +1451,7 @@ class Worker(Thread):
|
|||||||
if '?' in path:
|
if '?' in path:
|
||||||
path, query_string = path.split('?', 1)
|
path, query_string = path.split('?', 1)
|
||||||
|
|
||||||
path = r'%2F'.join([unquote(x) for x in re_SLASH.split(path)])
|
path = r'%2F'.join([urllib_unquote(x) for x in re_SLASH.split(path)])
|
||||||
|
|
||||||
req.update(path=path,
|
req.update(path=path,
|
||||||
query_string=query_string,
|
query_string=query_string,
|
||||||
|
|||||||
@@ -10,8 +10,12 @@ fix_sys_path(__file__)
|
|||||||
|
|
||||||
from gluon.compileapp import compile_application, remove_compiled_application
|
from gluon.compileapp import compile_application, remove_compiled_application
|
||||||
from gluon.fileutils import w2p_pack, w2p_unpack
|
from gluon.fileutils import w2p_pack, w2p_unpack
|
||||||
import os
|
from gluon.globals import Request
|
||||||
|
from gluon.admin import app_compile, app_create, app_cleanup, check_new_version, app_uninstall
|
||||||
|
from gluon.main import global_settings
|
||||||
|
import os, shutil
|
||||||
|
|
||||||
|
WEB2PY_VERSION_URL = "http://web2py.com/examples/default/version"
|
||||||
|
|
||||||
class TestPack(unittest.TestCase):
|
class TestPack(unittest.TestCase):
|
||||||
""" Tests the compileapp.py module """
|
""" Tests the compileapp.py module """
|
||||||
@@ -30,6 +34,27 @@ class TestPack(unittest.TestCase):
|
|||||||
w2p_unpack(test_path, unpack_path)
|
w2p_unpack(test_path, unpack_path)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def test_admin_compile(self):
|
||||||
|
#apps = ['welcome', 'admin', 'examples']
|
||||||
|
request = Request(env={})
|
||||||
|
request.application = 'a'
|
||||||
|
request.controller = 'c'
|
||||||
|
request.function = 'f'
|
||||||
|
request.folder = 'applications/admin'
|
||||||
|
apps = ['welcome']
|
||||||
|
for appname in apps:
|
||||||
|
appname_path = os.path.join(os.getcwd(), 'applications', appname)
|
||||||
|
self.assertEqual(app_compile(appname_path, request), None)
|
||||||
|
# remove any existing test_app
|
||||||
|
new_app = 'test_app_%s' % (appname)
|
||||||
|
if(os.path.exists('applications/%s' % (new_app))):
|
||||||
|
shutil.rmtree('applications/%s' % (new_app))
|
||||||
|
self.assertEqual(app_create(new_app, request), True)
|
||||||
|
self.assertEqual(os.path.exists('applications/test_app_%s/controllers/default.py' % (appname)), True)
|
||||||
|
self.assertEqual(app_cleanup(new_app, request), True)
|
||||||
|
self.assertEqual(app_uninstall(new_app, request), True)
|
||||||
|
self.assertNotEqual(check_new_version(global_settings.web2py_version, WEB2PY_VERSION_URL), -1)
|
||||||
|
return
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|||||||
+3
-3
@@ -13,7 +13,7 @@ from __future__ import print_function
|
|||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import sys
|
import sys
|
||||||
from gluon._compat import StringIO, thread
|
from gluon._compat import StringIO, thread, xrange
|
||||||
import time
|
import time
|
||||||
import threading
|
import threading
|
||||||
import os
|
import os
|
||||||
@@ -87,7 +87,7 @@ class IO(object):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
""" """
|
""" """
|
||||||
|
|
||||||
self.buffer = cStringIO.StringIO()
|
self.buffer = StringIO()
|
||||||
|
|
||||||
def write(self, data):
|
def write(self, data):
|
||||||
""" """
|
""" """
|
||||||
@@ -968,7 +968,7 @@ def console():
|
|||||||
run_system_tests(options)
|
run_system_tests(options)
|
||||||
|
|
||||||
if options.quiet:
|
if options.quiet:
|
||||||
capture = cStringIO.StringIO()
|
capture = StringIO()
|
||||||
sys.stdout = capture
|
sys.stdout = capture
|
||||||
logger.setLevel(logging.CRITICAL + 1)
|
logger.setLevel(logging.CRITICAL + 1)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user