python-utmp consists of three modules, providing access to utmp records.
It is linux specific and runs only on linux, and glibc 2.0 and higher !
There is really no way to make it more portable, because every UNIX has
different structure of utmp files. Glibc provides functions for
accessing utmp, but e.g. on *BSD systems the only way (IMHO) is to read
utmp file as a set of C-structures, using struct to unpack it. This is
very difficult to make portable. The best way would be probably to write
getutent() & comp. as a library for each specific platform, and build
python-utmp on top of it, emulating fields present on glibc utmp but
missing at the specific platform.

utmp.py provides following functions
(see getutent(3) and utmp(5) for more information):

getutent():
    returns None if there is an error (e.g. going past the end of utmp file)
    otherwise returns tuple of:
    (ut_type, ut_pid, ut_line, ut_id, ut_user, ut_host,
     ut_e_termination, ut_e_exit, ut_session,
     ut_tv_sec, ut_tv_usec, ut_addr_v6)

getutid(ut_type[, ut_id]):
    returns None if there is an error (e.g. not found), otherwise returns
    tuple of:
    (ut_type, ut_pid, ut_line, ut_id, ut_user, ut_host,
     ut_e_termination, ut_e_exit, ut_session,
     ut_tv_sec, ut_tv_usec, ut_addr_vut_line6)

getutline(ut_line):
    returns None if there is an error (e.g. not found), otherwise returns
    tuple of:
    (ut_type, ut_pid, ut_line, ut_id, ut_user, ut_host,
     ut_e_termination, ut_e_exit, ut_session,
     ut_tv_sec, ut_tv_usec, ut_addr_v6)

pututline(ut_type, ut_pid, ut_line, ut_id, ut_user, ut_host,
          ut_e_termination, ut_e_exit, ut_session,
          ut_tv_sec, ut_tv_usec, ut_addr_vut_line6):
    returns None

setutent():
    returns None

endutent()
    returns None

utmpname(fname):
    returns None



UTMP.py provides convenient constants for work with utmp.py
(see UTMP.py source)



Utmp.py provides class UtmpRecord with following methods:

getutent()
getutent_dict()
    like getutent(), but returns a dictionary instead of tuple.
    returns {} if there was an error.
getutid(ut_type[, ut_id]):
getutid_dict(ut_type[, ut_id]):
    like getutid(), but returns a dictionary instead of tuple.
    returns {} if there was an error.
getutline(ut_line)
getutline_dict(ut_line)
    like getutline(), but returns a dictionary instead of tuple.
    returns {} if there was an error.
pututline(ut_type, ut_pid, ut_line, ut_id, ut_user, ut_host,
          ut_e_termination, ut_e_exit, ut_session,
          ut_tv_sec, ut_tv_usec, ut_addr_vut_line6)
or pututline(t) where t is tuple as returned by getutent.
pututline_dict(d)
    like pututline(), but d is a dictionary as returned by getutent_dict()
setutent()
endutent()
You pass filename for utmpname() when creating instance of the class, 
e.g. a=Utmp.UtmpRecord("/var/log/wtmp")

