{ "info": { "author": "Brian M. Clapper", "author_email": "bmc@clapper.org", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: BSD License", "Operating System :: Unix", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "Introduction\n============\n\nThe ``pyutmp`` module provides a Python-oriented interface to the *utmp*\nfile on Unix-like operating systems. To paraphrase the *Linux Programmer's\nManual* page *utmp*\\ (5), the *utmp* file allows one to discover information\nabout who is currently using (i.e., is logged into) the system. The *utmp*\nfile is a series of entries whose structure is typically defined by the\n``utmp.h`` C header file.\n\nThis module provides an read-only interface to the underlying operating\nsystem's C *utmp* API.\n\nInterface and Usage\n===================\n\nThe ``pyutmp`` module supplies two classes: UtmpFile and Utmp. A\nUtmpFile object represents the open *utmp* file; when you iterate over a\nUtmpFile object, it yields successive Utmp objects. For example:\n\n::\n\n from pyutmp import UtmpFile\n import time\n\n for utmp in UtmpFile():\n # utmp is a Utmp object\n if utmp.ut_user_process:\n print '%s logged in at %s on tty %s' % (utmp.ut_user, time.ctime(utmp.ut_time), utmp.ut_line)\n\n\nUtmpFile\n--------\n\nIn addition to the ``__iter__()`` generator method, allowing iteration over\nthe contents of the *utmp* file, the UtmpFile class also provides a\n``rewind()`` method that permits you to reset the file pointer to the top\nof the file. See the class documentation for details.\n\nUtmp\n----\n\nThe fields of the Utmp class are operating system-dependent. However, they\nwill *always* include at least the following fields:\n\n+---------------------+-----------+----------------------------------------+\n| Field | Type | Description |\n+=====================+===========+========================================+\n| ``ut_user`` | ``str`` | The user associated with the *utmp* |\n| | | entry, if any. |\n+---------------------+-----------+----------------------------------------+\n| ``ut_line`` | ``str`` | The tty or pseudo-tty associated with |\n| | | the entry, if any. In this API, the |\n| | | line will *always* be the full path to |\n| | | the device. |\n+---------------------+-----------+----------------------------------------+\n| ``ut_host`` | ``str`` | The host name associated with the |\n| | | entry, if any. |\n+---------------------+-----------+----------------------------------------+\n| ``ut_time`` | timestamp | The timestamp associated with the |\n| | | entry. This timestamp is in the form |\n| | | returned by ``time.time()`` and may be |\n| | | passed directly to methods like |\n| | | ``time.ctime()``. |\n+---------------------+-----------+----------------------------------------+\n| ``ut_user_process`` | ``bool`` | Whether or not the *utmp* entry is a |\n| | | user process (as opposed to a reboot or|\n| | | some other system event). |\n+---------------------+-----------+----------------------------------------+\n \nOn some operating systems, other fields may be present. For instance, on\nLinux and Solaris systems (and other System V-derived systems), Utmp also\ncontains the following fields:\n\n+---------------------+-----------+----------------------------------------+\n| Optional Field | Type | Description |\n+=====================+===========+========================================+\n| ``ut_type`` | ``str`` | The type of the entry, typically one of|\n| | | the following string values: |\n| | | \"RUN_LVL\", \"BOOT_TIME\", \"NEW_TIME\", |\n| | | \"OLD_TIME\", \"INIT_PROCESS\", |\n| | | \"LOGIN_PROCESS\", \"USER_PROCESS\", |\n| | | \"DEAD_PROCESS\", \"ACCOUNTING\". |\n| | | See the *utmp*\\ (5) manual page for a |\n| | | description of these values |\n+---------------------+-----------+----------------------------------------+\n| ``ut_pid`` | ``int`` | Associated process ID, if any. |\n+---------------------+-----------+----------------------------------------+\n| ``ut_id`` | ``str`` | The *init*\\ (8) ID, or the abbreviated |\n| | | tty name. |\n+---------------------+-----------+----------------------------------------+\n| ``ut_exit_code`` | ``int`` | Process exit code, if applicable. |\n+---------------------+-----------+----------------------------------------+\n| ``ut_session`` | ``int`` | Session ID, for windowing. |\n+---------------------+-----------+----------------------------------------+\n| ``ut_addr`` | ``int`` | IPv4 address of remote host (if |\n| | array | applicable), one octet per array |\n| | | element. |\n+---------------------+-----------+----------------------------------------+\n\nIf you're writing portable code, you should not count on the presence of\nthose attributes--or, at the very least, you should wrap access to them in\na ``try/catch`` block that catches ``AttributeError``.\n\n\nNotes\n=====\n\nThis module has been tested on the following operating systems:\n\n- Ubuntu Linux, version 8.04\n- FreeBSD\n- Mac OS X 10.4 (Tiger)\n- OpenSolaris (2008.05, x86, using the SunStudio 12 compiler suite)\n\nAdding support for other Unix variants should be straightforward.\n\nRestrictions\n============\n\n- Access to the *utmp* file is read-only. There is no provision for writing\n to the file.\n\nCopyright and License\n=====================\n\nThis software is released under a BSD license, adapted from\n\n\nCopyright (c) 2008-2010 Brian M. Clapper.\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice,\n this list of conditions and the following disclaimer.\n\n* Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimer in the documentation\n and/or other materials provided with the distribution.\n\n* Neither the name \"clapper.org\" nor the names of its contributors may be\n used to endorse or promote products derived from this software without\n specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\nARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\nLIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\nCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\nSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\nINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\nCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\nARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGE.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://bmc.github.com/pyutmp/", "keywords": null, "license": "BSD license", "maintainer": null, "maintainer_email": null, "name": "pyutmp", "package_url": "https://pypi.org/project/pyutmp/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pyutmp/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://bmc.github.com/pyutmp/" }, "release_url": "https://pypi.org/project/pyutmp/0.2.1/", "requires_dist": null, "requires_python": null, "summary": "Python UTMP wrapper for Un*x systems", "version": "0.2.1" }, "last_serial": 798234, "releases": { "0.1": [], "0.2": [], "0.2.1": [ { "comment_text": "", "digests": { "md5": "5bdcbfba033f0b9c64425b4539345bc8", "sha256": "957ae25bc6997c3b18d8255399eb8409c9f47c9fd47c1ac852e49659bfd54869" }, "downloads": -1, "filename": "pyutmp-0.2.1.tar.gz", "has_sig": false, "md5_digest": "5bdcbfba033f0b9c64425b4539345bc8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 33673, "upload_time": "2010-06-25T22:53:58", "url": "https://files.pythonhosted.org/packages/dd/65/da24e5a673cc828f58ec698c73b7fa145c3645d7d03bc8ea993c26532f9b/pyutmp-0.2.1.tar.gz" }, { "comment_text": "", "digests": { "md5": "d931f36d88036f0d02391814bf8017d0", "sha256": "d2d6d4b47f7094f1299114a81217c7c34e1af5ceb4af7837134dc6037af53fdf" }, "downloads": -1, "filename": "pyutmp-0.2.1.zip", "has_sig": false, "md5_digest": "d931f36d88036f0d02391814bf8017d0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 41044, "upload_time": "2010-06-10T13:59:29", "url": "https://files.pythonhosted.org/packages/42/f6/0faec911c0d47ad7424a2afa9489d4ba6ec23969fd81b016a16bb9246e30/pyutmp-0.2.1.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5bdcbfba033f0b9c64425b4539345bc8", "sha256": "957ae25bc6997c3b18d8255399eb8409c9f47c9fd47c1ac852e49659bfd54869" }, "downloads": -1, "filename": "pyutmp-0.2.1.tar.gz", "has_sig": false, "md5_digest": "5bdcbfba033f0b9c64425b4539345bc8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 33673, "upload_time": "2010-06-25T22:53:58", "url": "https://files.pythonhosted.org/packages/dd/65/da24e5a673cc828f58ec698c73b7fa145c3645d7d03bc8ea993c26532f9b/pyutmp-0.2.1.tar.gz" }, { "comment_text": "", "digests": { "md5": "d931f36d88036f0d02391814bf8017d0", "sha256": "d2d6d4b47f7094f1299114a81217c7c34e1af5ceb4af7837134dc6037af53fdf" }, "downloads": -1, "filename": "pyutmp-0.2.1.zip", "has_sig": false, "md5_digest": "d931f36d88036f0d02391814bf8017d0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 41044, "upload_time": "2010-06-10T13:59:29", "url": "https://files.pythonhosted.org/packages/42/f6/0faec911c0d47ad7424a2afa9489d4ba6ec23969fd81b016a16bb9246e30/pyutmp-0.2.1.zip" } ] }