Exemplo n.º 1
0
def fileExists(filename):
    try:
        os.stat(misc.toPath(filename))
    except OSError:
        return False

    return True
Exemplo n.º 2
0
def fileExists(filename):
    try:
        os.stat(misc.toPath(filename))
    except OSError:
        return False

    return True
Exemplo n.º 3
0
def createBackup(filename):

    try:
        f = open(misc.toPath(filename), "r")
        try:
            data = f.read()
        finally:
            f.close()

        f = open(misc.toPath(filename + ".bak"), "w+")
        try:
            f.write(data)
        finally:
            f.close()

        return True
    except IOError, (errno, strerror):
        #wx.MessageBox("Error writing file '%s': %s" % (filename, strerror), "Error", wx.OK, "")
        return False
Exemplo n.º 4
0
def loadFile(filename, frame, maxSize=-1):
    ret = None

    try:
        f = open(misc.toPath(filename), "rb")

        try:
            ret = f.read(maxSize)
        finally:
            f.close()

    except IOError, (errno, strerror):
        wx.MessageBox("Error loading file '%s': %s" % (filename, strerror),
                      "Error", wx.OK, frame)
        ret = None
Exemplo n.º 5
0
def loadFile(filename, frame, maxSize = -1):
    ret = None

    try:
        f = open(misc.toPath(filename), "rb")

        try:
            ret = f.read(maxSize)
        finally:
            f.close()

    except IOError, (errno, strerror):
        wx.MessageBox("Error loading file '%s': %s" % (
                filename, strerror), "Error", wx.OK, frame)
        ret = None
Exemplo n.º 6
0
def writeToFile(filename, data, frame):
    try:
        f = open(misc.toPath(filename), "wb")

        try:
            f.write(data)
        finally:
            f.close()

        return True

    except IOError, (errno, strerror):
        wx.MessageBox("Error writing file '%s': %s" % (filename, strerror),
                      "Error", wx.OK, frame)

        return False
Exemplo n.º 7
0
def writeToFile(filename, data, frame):
    try:
        f = open(misc.toPath(filename), "wb")

        try:
            f.write(data)
        finally:
            f.close()

        return True

    except IOError, (errno, strerror):
        wx.MessageBox("Error writing file '%s': %s" % (
                filename, strerror), "Error", wx.OK, frame)

        return False
Exemplo n.º 8
0
def loadFile(filename, frame, maxSize=-1):
    ret = None

    try:
        f = open(misc.toPath(filename), "r", encoding='UTF-8')

        try:
            ret = f.read(maxSize)
        finally:
            f.close()

    except IOError as xxx_todo_changeme:
        (errno, strerror) = xxx_todo_changeme.args
        wx.MessageBox("Error loading file '%s': %s" % (filename, strerror),
                      "Error", wx.OK, frame)
        ret = None

    return ret
Exemplo n.º 9
0
def writeToFile(filename, data, frame):
    try:
        f = open(misc.toPath(filename), "wb")

        try:
            if isinstance(data, str):
                f.write(data.encode("UTF-8"))
            else:
                f.write(data)
        finally:
            f.close()

        return True

    except IOError as xxx_todo_changeme1:
        (errno, strerror) = xxx_todo_changeme1.args
        wx.MessageBox("Error writing file '%s': %s" % (filename, strerror),
                      "Error", wx.OK, frame)

        return False