<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def getstatus():
 """Get the status of the previous 'homely update', or any 'homely update' that may be running in another process. """

    if exists(RUNFILE):
        mtime = os.stat(RUNFILE).st_mtime
        with open(SECTIONFILE) as f:
            section = f.read().strip()
        # what section?
        return UpdateStatus.RUNNING, mtime, section
    if exists(PAUSEFILE):
        return UpdateStatus.PAUSED, None, None

    mtime = None
    if exists(TIMEFILE):
        mtime = os.stat(TIMEFILE).st_mtime

    if exists(FAILFILE):
        if not mtime:
            mtime = os.stat(FAILFILE).st_mtime
        # TODO: return a different error code when the error was inability to
        # contact one or more remote servers
        with open(FAILFILE) as f:
            content = f.read().strip()
            if content == UpdateStatus.NOCONN:
                return UpdateStatus.NOCONN, mtime, None
            elif content == UpdateStatus.DIRTY:
                return UpdateStatus.DIRTY, mtime, None
        return UpdateStatus.FAILED, mtime, None

    if mtime is None:
        return UpdateStatus.NEVER, None, None

    return UpdateStatus.OK, mtime, None