示例#1
0
def app_cleanup(app, request):
    """
    Removes session, cache and error files

    Parameters
    ----------
    app:
        application name
    request:
        the global request object
    """
    r = True

    # Remove error files
    path = apath("%s/errors/" % app, request)
    if os.path.exists(path):
        for f in os.listdir(path):
            try:
                if f[:1] != ".":
                    os.unlink(os.path.join(path, f))
            except IOError:
                r = False

    # Remove session files
    path = apath("%s/sessions/" % app, request)
    if os.path.exists(path):
        for f in os.listdir(path):
            try:
                if f[:1] != ".":
                    recursive_unlink(os.path.join(path, f))
            except IOError:
                r = False

    # Remove cache files
    path = apath("%s/cache/" % app, request)
    if os.path.exists(path):
        for f in os.listdir(path):
            try:
                if f[:1] != ".":
                    os.unlink(os.path.join(path, f))
            except IOError:
                r = False
    return r
示例#2
0
def app_cleanup(app, request):
    """
    Removes session, cache and error files

    Parameters
    ----------
    app:
        application name
    request:
        the global request object
    """
    r = True

    # Remove error files
    path = apath('%s/errors/' % app, request)
    if os.path.exists(path):
        for f in os.listdir(path):
            try:
                if f[:1] != '.': os.unlink(os.path.join(path, f))
            except IOError:
                r = False

    # Remove session files
    path = apath('%s/sessions/' % app, request)
    if os.path.exists(path):
        for f in os.listdir(path):
            try:
                if f[:1] != '.': recursive_unlink(os.path.join(path, f))
            except IOError:
                r = False

    # Remove cache files
    path = apath('%s/cache/' % app, request)
    if os.path.exists(path):
        for f in os.listdir(path):
            try:
                if f[:1] != '.': os.unlink(os.path.join(path, f))
            except IOError:
                r = False
    return r