updated portalocker, few py3 syntax/import fix
This commit is contained in:
+11
-4
@@ -18,7 +18,7 @@ import fnmatch
|
||||
import os
|
||||
import copy
|
||||
import random
|
||||
from gluon._compat import builtin
|
||||
from gluon._compat import builtin, PY2
|
||||
from gluon.storage import Storage, List
|
||||
from gluon.template import parse_template
|
||||
from gluon.restricted import restricted, compile2
|
||||
@@ -548,10 +548,17 @@ def run_models_in(environment):
|
||||
path = pjoin(folder, 'models')
|
||||
cpath = pjoin(folder, 'compiled')
|
||||
compiled = os.path.exists(cpath)
|
||||
if compiled:
|
||||
models = sorted(listdir(cpath, '^models[_.][\w.]+\.pyc$', 0), model_cmp)
|
||||
if PY2:
|
||||
if compiled:
|
||||
models = sorted(listdir(cpath, '^models[_.][\w.]+\.pyc$', 0), model_cmp)
|
||||
else:
|
||||
models = sorted(listdir(path, '^\w+\.py$', 0, sort=False), model_cmp_sep)
|
||||
else:
|
||||
models = sorted(listdir(path, '^\w+\.py$', 0, sort=False), model_cmp_sep)
|
||||
if compiled:
|
||||
models = sorted(listdir(cpath, '^models[_.][\w.]+\.pyc$', 0), key=lambda f: '{0:03d}'.format(f.count('.')) + f)
|
||||
else:
|
||||
models = sorted(listdir(path, '^\w+\.py$', 0, sort=False), key=lambda f: '{0:03d}'.format(f.count(os.path.sep)) + f)
|
||||
|
||||
models_to_run = None
|
||||
for model in models:
|
||||
if response.models_to_run != models_to_run:
|
||||
|
||||
@@ -31,7 +31,7 @@ from gluon.contrib.redis_utils import RConn
|
||||
from gluon.contrib.redis_scheduler import RScheduler
|
||||
|
||||
def demo1(*args,**vars):
|
||||
print 'you passed args=%s and vars=%s' % (args, vars)
|
||||
print('you passed args=%s and vars=%s') % (args, vars)
|
||||
return 'done!'
|
||||
|
||||
def demo2():
|
||||
|
||||
+1
-1
@@ -418,7 +418,7 @@ class Response(Storage):
|
||||
self.body.write(to_native(xmlescape(data)))
|
||||
|
||||
def render(self, *a, **b):
|
||||
from compileapp import run_view_in
|
||||
from gluon.compileapp import run_view_in
|
||||
if len(a) > 2:
|
||||
raise SyntaxError(
|
||||
'Response.render can be called with two arguments, at most')
|
||||
|
||||
+2
-2
@@ -164,7 +164,7 @@ def clear_cache(filename):
|
||||
|
||||
|
||||
def read_dict_aux(filename):
|
||||
lang_text = read_locked(filename).replace('\r\n', '\n')
|
||||
lang_text = read_locked(filename).replace(b'\r\n', b'\n')
|
||||
clear_cache(filename)
|
||||
try:
|
||||
return safe_eval(lang_text) or {}
|
||||
@@ -287,7 +287,7 @@ def read_possible_languages(langpath):
|
||||
|
||||
|
||||
def read_plural_dict_aux(filename):
|
||||
lang_text = read_locked(filename).replace('\r\n', '\n')
|
||||
lang_text = read_locked(filename).replace(b'\r\n', b'\n')
|
||||
try:
|
||||
return eval(lang_text) or {}
|
||||
except Exception:
|
||||
|
||||
@@ -148,14 +148,14 @@ class LockedFile(object):
|
||||
|
||||
|
||||
def read_locked(filename):
|
||||
fp = LockedFile(filename, 'r')
|
||||
fp = LockedFile(filename, 'rb')
|
||||
data = fp.read()
|
||||
fp.close()
|
||||
return data
|
||||
|
||||
|
||||
def write_locked(filename, data):
|
||||
fp = LockedFile(filename, 'w')
|
||||
fp = LockedFile(filename, 'wb')
|
||||
data = fp.write(data)
|
||||
fp.close()
|
||||
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ Create File: app/models/scheduler.py ======
|
||||
from gluon.scheduler import Scheduler
|
||||
|
||||
def demo1(*args,**vars):
|
||||
print 'you passed args=%s and vars=%s' % (args, vars)
|
||||
print('you passed args=%s and vars=%s') % (args, vars)
|
||||
return 'done!'
|
||||
|
||||
def demo2():
|
||||
|
||||
@@ -309,12 +309,12 @@ class TestsForSchedulerRunner(testForSchedulerRunnerBase):
|
||||
self.db.commit()
|
||||
self.writefunction(r"""
|
||||
def demo1(*args,**vars):
|
||||
print 'you passed args=%s and vars=%s' % (args, vars)
|
||||
print('you passed args=%s and vars=%s') % (args, vars)
|
||||
return args[0]
|
||||
|
||||
def demo4():
|
||||
time.sleep(15)
|
||||
print "I'm printing something"
|
||||
print("I'm printing something")
|
||||
return dict(a=1, b=2)
|
||||
""")
|
||||
ret = self.exec_sched()
|
||||
@@ -359,24 +359,24 @@ def demo4():
|
||||
self.writefunction(r"""
|
||||
def demo3():
|
||||
time.sleep(15)
|
||||
print 1/0
|
||||
print(1/0)
|
||||
return None
|
||||
|
||||
def demo4():
|
||||
time.sleep(15)
|
||||
print "I'm printing something"
|
||||
print("I'm printing something")
|
||||
return dict(a=1, b=2)
|
||||
|
||||
def demo5():
|
||||
time.sleep(15)
|
||||
print "I'm printing something"
|
||||
print("I'm printing something")
|
||||
rtn = dict(a=1, b=2)
|
||||
|
||||
def demo6():
|
||||
time.sleep(5)
|
||||
print '50%'
|
||||
print('50%')
|
||||
time.sleep(5)
|
||||
print '!clear!100%'
|
||||
print('!clear!100%')
|
||||
return 1
|
||||
""")
|
||||
ret = self.exec_sched()
|
||||
@@ -417,12 +417,12 @@ def demo6():
|
||||
self.db.commit()
|
||||
self.writefunction(r"""
|
||||
def demo1(*args,**vars):
|
||||
print 'you passed args=%s and vars=%s' % (args, vars)
|
||||
print('you passed args=%s and vars=%s' % (args, vars))
|
||||
return args[0]
|
||||
import random
|
||||
def demo7():
|
||||
time.sleep(random.randint(1,5))
|
||||
print W2P_TASK, request.now
|
||||
print(W2P_TASK, request.now)
|
||||
return W2P_TASK.id, W2P_TASK.uuid, W2P_TASK.run_id
|
||||
""")
|
||||
ret = self.exec_sched()
|
||||
@@ -466,7 +466,7 @@ def demo8():
|
||||
num_of_lines = 0
|
||||
with open(placeholder) as f:
|
||||
num_of_lines = len([a for a in f.read().split('\n') if a])
|
||||
print 'number of lines', num_of_lines
|
||||
print('number of lines', num_of_lines)
|
||||
if num_of_lines <= 2:
|
||||
1/0
|
||||
else:
|
||||
|
||||
+4
-4
@@ -25,10 +25,10 @@ import logging
|
||||
import getpass
|
||||
from gluon import main, newcron
|
||||
|
||||
from .fileutils import read_file, write_file, create_welcome_w2p
|
||||
from .settings import global_settings
|
||||
from .shell import run, test
|
||||
from .utils import is_valid_ip_address, is_loopback_ip_address, getipaddrinfo
|
||||
from gluon.fileutils import read_file, write_file, create_welcome_w2p
|
||||
from gluon.settings import global_settings
|
||||
from gluon.shell import run, test
|
||||
from gluon.utils import is_valid_ip_address, is_loopback_ip_address, getipaddrinfo
|
||||
|
||||
|
||||
ProgramName = 'web2py Web Framework'
|
||||
|
||||
Reference in New Issue
Block a user