GitLab's annual major release is around the corner. Along with a lot of new and exciting features, there will be a few breaking changes. Learn more here.

Commit 9e6497fb authored by J A's avatar J A
Browse files

functions: catch OSError when calling get_encoding



Handles the OSError FileNotFoundException.
The error occurs when the required program 'file' is not installed.
Signed-off-by: J A's avatarJule Anger <ja@sernet.de>
parent 57300a7e
......@@ -239,7 +239,12 @@ def get_encoding(filename):
command_line = "file -bi %s" % filename
logger.debug("Execute command: '%s'" % command_line)
args = shlex.split(command_line)
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
try:
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
except OSError as e:
msg = "The program 'file' is not installed."
logger.error(msg, error=e)
exit(3)
# wait until the process has finished
p.wait()
......
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