Commit d6ef69b5 authored by Michael Büsch's avatar Michael Büsch

Add fileExists() helper

Signed-off-by: Michael Büsch's avatarMichael Buesch <>
parent 01020e1b
......@@ -2,7 +2,7 @@
# AWL simulator - common utility functions
# Copyright 2012-2015 Michael Buesch <>
# Copyright 2012-2016 Michael Buesch <>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -27,6 +27,7 @@ from awlsim.common.exceptions import *
import sys
import os
import errno
import random
import base64
import binascii
......@@ -113,6 +114,19 @@ def printWarning(text):
def printError(text):
def fileExists(filename):
"""Returns True, if the file exists.
Returns False, if the file does not exist.
Returns None, if another error occurred.
except OSError as e:
if e.errno == errno.ENOENT:
return False
return None
return True
def awlFileRead(filename, encoding="latin_1"):
fd = open(filename, "rb")
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