Merge pull request #1654 from BuhtigithuB/improve/pep8-admin-py
Enhance admin.py PEP8
This commit is contained in:
+15
-10
@@ -54,7 +54,8 @@ def app_pack(app, request, raise_ex=False, filenames=None):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if filenames is None: app_cleanup(app, request)
|
if filenames is None:
|
||||||
|
app_cleanup(app, request)
|
||||||
filename = apath('../deposit/web2py.app.%s.w2p' % app, request)
|
filename = apath('../deposit/web2py.app.%s.w2p' % app, request)
|
||||||
w2p_pack(filename, apath(app, request), filenames=filenames)
|
w2p_pack(filename, apath(app, request), filenames=filenames)
|
||||||
return filename
|
return filename
|
||||||
@@ -104,7 +105,8 @@ def app_cleanup(app, request):
|
|||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
for f in os.listdir(path):
|
for f in os.listdir(path):
|
||||||
try:
|
try:
|
||||||
if f[:1] != '.': os.unlink(os.path.join(path, f))
|
if f[:1] != '.':
|
||||||
|
os.unlink(os.path.join(path, f))
|
||||||
except IOError:
|
except IOError:
|
||||||
r = False
|
r = False
|
||||||
|
|
||||||
@@ -113,7 +115,8 @@ def app_cleanup(app, request):
|
|||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
for f in os.listdir(path):
|
for f in os.listdir(path):
|
||||||
try:
|
try:
|
||||||
if f[:1] != '.': recursive_unlink(os.path.join(path, f))
|
if f[:1] != '.':
|
||||||
|
recursive_unlink(os.path.join(path, f))
|
||||||
except (OSError, IOError):
|
except (OSError, IOError):
|
||||||
r = False
|
r = False
|
||||||
|
|
||||||
@@ -123,7 +126,8 @@ def app_cleanup(app, request):
|
|||||||
CacheOnDisk(folder=path).clear()
|
CacheOnDisk(folder=path).clear()
|
||||||
for f in os.listdir(path):
|
for f in os.listdir(path):
|
||||||
try:
|
try:
|
||||||
if f[:1] != '.': recursive_unlink(os.path.join(path, f))
|
if f[:1] != '.':
|
||||||
|
recursive_unlink(os.path.join(path, f))
|
||||||
except (OSError, IOError):
|
except (OSError, IOError):
|
||||||
r = False
|
r = False
|
||||||
return r
|
return r
|
||||||
@@ -175,10 +179,9 @@ def app_create(app, request, force=False, key=None, info=False):
|
|||||||
return False
|
return False
|
||||||
try:
|
try:
|
||||||
w2p_unpack('welcome.w2p', path)
|
w2p_unpack('welcome.w2p', path)
|
||||||
for subfolder in [
|
for subfolder in ['models', 'views', 'controllers', 'databases',
|
||||||
'models', 'views', 'controllers', 'databases',
|
'modules', 'cron', 'errors', 'sessions', 'cache',
|
||||||
'modules', 'cron', 'errors', 'sessions', 'cache',
|
'languages', 'static', 'private', 'uploads']:
|
||||||
'languages', 'static', 'private', 'uploads']:
|
|
||||||
subpath = os.path.join(path, subfolder)
|
subpath = os.path.join(path, subfolder)
|
||||||
if not os.path.exists(subpath):
|
if not os.path.exists(subpath):
|
||||||
os.mkdir(subpath)
|
os.mkdir(subpath)
|
||||||
@@ -368,7 +371,7 @@ def unzip(filename, dir, subfolder=''):
|
|||||||
for name in sorted(zf.namelist()):
|
for name in sorted(zf.namelist()):
|
||||||
if not name.startswith(subfolder):
|
if not name.startswith(subfolder):
|
||||||
continue
|
continue
|
||||||
#print name[n:]
|
# print name[n:]
|
||||||
if name.endswith('/'):
|
if name.endswith('/'):
|
||||||
folder = os.path.join(dir, name[n:])
|
folder = os.path.join(dir, name[n:])
|
||||||
if not os.path.exists(folder):
|
if not os.path.exists(folder):
|
||||||
@@ -435,6 +438,7 @@ def add_path_first(path):
|
|||||||
if not global_settings.web2py_runtime_gae:
|
if not global_settings.web2py_runtime_gae:
|
||||||
site.addsitedir(path)
|
site.addsitedir(path)
|
||||||
|
|
||||||
|
|
||||||
def try_mkdir(path):
|
def try_mkdir(path):
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
try:
|
try:
|
||||||
@@ -444,11 +448,12 @@ def try_mkdir(path):
|
|||||||
else:
|
else:
|
||||||
os.mkdir(path)
|
os.mkdir(path)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
if e.strerror == 'File exists': # In case of race condition.
|
if e.strerror == 'File exists': # In case of race condition.
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
|
|
||||||
def create_missing_folders():
|
def create_missing_folders():
|
||||||
if not global_settings.web2py_runtime_gae:
|
if not global_settings.web2py_runtime_gae:
|
||||||
for path in ('applications', 'deposit', 'site-packages', 'logs'):
|
for path in ('applications', 'deposit', 'site-packages', 'logs'):
|
||||||
|
|||||||
Reference in New Issue
Block a user