mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[mod] pep8 on hooks.py
This commit is contained in:
parent
40ea2f9477
commit
83971afb9c
1 changed files with 20 additions and 15 deletions
|
@ -50,8 +50,10 @@ def hook_add(app, file):
|
||||||
path, filename = os.path.split(file)
|
path, filename = os.path.split(file)
|
||||||
priority, action = _extract_filename_parts(filename)
|
priority, action = _extract_filename_parts(filename)
|
||||||
|
|
||||||
try: os.listdir(CUSTOM_HOOK_FOLDER + action)
|
try:
|
||||||
except OSError: os.makedirs(CUSTOM_HOOK_FOLDER + action)
|
os.listdir(CUSTOM_HOOK_FOLDER + action)
|
||||||
|
except OSError:
|
||||||
|
os.makedirs(CUSTOM_HOOK_FOLDER + action)
|
||||||
|
|
||||||
finalpath = CUSTOM_HOOK_FOLDER + action + '/' + priority + '-' + app
|
finalpath = CUSTOM_HOOK_FOLDER + action + '/' + priority + '-' + app
|
||||||
os.system('cp %s %s' % (file, finalpath))
|
os.system('cp %s %s' % (file, finalpath))
|
||||||
|
@ -73,7 +75,8 @@ def hook_remove(app):
|
||||||
for script in os.listdir(CUSTOM_HOOK_FOLDER + action):
|
for script in os.listdir(CUSTOM_HOOK_FOLDER + action):
|
||||||
if script.endswith(app):
|
if script.endswith(app):
|
||||||
os.remove(CUSTOM_HOOK_FOLDER + action + '/' + script)
|
os.remove(CUSTOM_HOOK_FOLDER + action + '/' + script)
|
||||||
except OSError: pass
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def hook_info(action, name):
|
def hook_info(action, name):
|
||||||
|
@ -165,6 +168,7 @@ def hook_list(action, list_by='name', show_info=False):
|
||||||
else:
|
else:
|
||||||
if list_by == 'name':
|
if list_by == 'name':
|
||||||
result = set()
|
result = set()
|
||||||
|
|
||||||
def _append_hook(d, priority, name, path):
|
def _append_hook(d, priority, name, path):
|
||||||
# Add only the name
|
# Add only the name
|
||||||
d.add(name)
|
d.add(name)
|
||||||
|
@ -346,7 +350,7 @@ def hook_exec(path, args=None, raise_on_error=False, no_trace=False,
|
||||||
|
|
||||||
# prepend environment variables
|
# prepend environment variables
|
||||||
cmd = '{0} {1}'.format(
|
cmd = '{0} {1}'.format(
|
||||||
' '.join(['{0}={1}'.format(k, shell_quote(v)) \
|
' '.join(['{0}={1}'.format(k, shell_quote(v))
|
||||||
for k, v in env.items()]), cmd)
|
for k, v in env.items()]), cmd)
|
||||||
command.append(cmd.format(script=cmd_script, args=cmd_args))
|
command.append(cmd.format(script=cmd_script, args=cmd_args))
|
||||||
|
|
||||||
|
@ -392,6 +396,7 @@ def _extract_filename_parts(filename):
|
||||||
|
|
||||||
_find_unsafe = re.compile(r'[^\w@%+=:,./-]', re.UNICODE).search
|
_find_unsafe = re.compile(r'[^\w@%+=:,./-]', re.UNICODE).search
|
||||||
|
|
||||||
|
|
||||||
def shell_quote(s):
|
def shell_quote(s):
|
||||||
"""Return a shell-escaped version of the string *s*."""
|
"""Return a shell-escaped version of the string *s*."""
|
||||||
s = str(s)
|
s = str(s)
|
||||||
|
|
Loading…
Add table
Reference in a new issue