{ "info": { "author": "Julian Porter", "author_email": "julian@jpembedded.solutions", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Console", "Environment :: No Input/Output (Daemon)", "Environment :: Web Environment", "Environment :: X11 Applications", "Intended Audience :: Developers", "Intended Audience :: System Administrators", "License :: OSI Approved :: Python Software Foundation License", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3", "Topic :: System :: Filesystems", "Topic :: System :: Monitoring" ], "description": "1 Summary\n=========\n\n**pollinotify** is a simple extension module that wraps the Linux **inotify** service, providing a way to watch for \nspecific kinds of file events happening to specified files or in specified directories. Its major selling points are\nthat:\n\n 1 It is *polled*, so instead of having to set up a background thread, or attach a separate event-watching package, the programmer calls it with an optional timeout, so it reports event that have already occurred, or waits for at most the specified time, or until an event occurs;\n \n 2 The polling can wait for specific kinds of event.\n\nAs the module depends on the **inotify** service, **it is only available on Linux**.\n \n\n2 Module Structure\n==================\n\n2.1 Constants\n-------------\n\nA number of constants representing common Linux file system event codes, with friendly names:\n\n============= ================ =================================================================\nConstant Name Linux Name Interpretation\n============= ================ =================================================================\nAccess IN_ACCESS Object accessed\nModify IN_MODIFY Object modified\nAttributes IN_ATTRIB Object attributes modified\nOpen IN_OPEN\t\t File opened\nCloseWrite IN_CLOSE_WRITE File closed after contents changed\nCloseOther IN_CLOSE_NOWRITE File closed without contents changed\nClose IN_CLOSE File closed\nMoveFrom IN_MOVED_FROM Object moved from location\nMoveTo IN_MOVED_TO Object moved to location\nMove IN_MOVE Object moved\nMoveSelf IN_MOVE_SELF Object being monitored is deleted\nCreate IN_CREATE Object created\nDelete IN_DELETE Object deleted\nDeleteSelf IN_DELETE_SELF Object being monitored is deleted\nIgnored IN_IGNORED Ignored\nDirEvent IN_ISDIR The monitored object to which the event occurred is a directory\nAllEvents IN_ALL_EVENTS\t Any event\n============= ================ =================================================================\n\n\n\n2.2 Utility functions\n---------------------\n\n*maskAsString(mask)*\n\tTakes a value equal to one or more of the event constants *or*-ed together\n\tand returns a readable string representation, consisting of a space-separated\n\tlist of the names of the matching events\n\t\n2.3 *FileEvent* class\n---------------------\n\n*FileEvent* represents an event detected by the **inotify** service. The event information is held\nin the attributes:\n\n*self.path*\n\tThe path to the file or directory suffering the event\n*self.mask*\n\tValue representing the event(s) it suffered, represented as an *or*-ed collection of event codes, one for\n\teach kind of event that was detected\n*self.decode()*\n\tReturns a list of the names of the event types to which the event corresponds\n*self.matches(mask)*\n\tReturns **True** if the argument is the code for one of the event types that the object represents, **False** \n\totherwise\n\t\n\t\nIn addition, if *e* is a *FileEvent* object then\n\n::\n\n\tstr(e) = maskAsString(e.mask)\n\tlen(e) = len(e.decode())\n\tx in e = e.matches(x)\n\t\n\n2.4 *Watcher* class\n-------------------\n\nThe fundamental class of the module. It connects to the system **inotify** service and uses it to \npoll for events in one or more specified file system paths. Polling is based on a timeout,\nand so can be non-blocking. \n\nIt has the following methods:\n \n\n*__init__()*\t\t\t\n\tNo-args constructor\n*addPath(path,mode=AllEvents)*\n\tAdds *path* to the list of directories to be polled for events; polling \n\twill collect only events that match the *or*-ed event code mask \n\tspecified in the optional argument *mode* (defaults to all events)\n*poll(timeout=0)*\n\tPolls for events occurring on the specified paths, returning\n\t**True** if any occur, **False** otherwise; times out\n\tafter *timeout* milliseconds, in which case it returns **False**\n*events(match=AllEvents)*\t\t\n\tReturns a list of *FileEvent* objects, one for\n\teach event detected during last polling session\n\tthat matches the specified optional *or*-ed event code mask\n*nPaths()*\t\t\t\n\tReturns the number of paths currently registered with the Watcher\n*nEvents()*\t\t\t\n\tReturns the number of events detected in the last polling session\n\n\nIf *w* is a *Watcher* instance then\n\n::\n\n\tlen(w) = w.nEvents()\n\titer(w) = iter(w.events())\n\t\n\n3 EXAMPLE\n=========\n\nA simple example that polls with a timeout of 1 second and lists those events\ncorresponding to file creation or modification (including **touch**) in the\nuser's home directory.\n\n::\n\n import pollinotify\n\n n=pollinotify.Watcher()\n n.addPath('~')\n while True:\n got=n.poll(timeout=1000)\n if got:\n events=n.events(match=notify.CloseWrite)\n print('Got{} events'.format(len(events))\n for event in events:\n print('{} : {} : {}'.format(event.path,event.mask,str(event)))\n \n", "description_content_type": null, "docs_url": "https://pythonhosted.org/pollinotify/", "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://jpembedded.solutions", "keywords": "inotify", "license": "", "maintainer": "", "maintainer_email": "", "name": "pollinotify", "package_url": "https://pypi.org/project/pollinotify/", "platform": "", "project_url": "https://pypi.org/project/pollinotify/", "project_urls": { "Homepage": "http://jpembedded.solutions" }, "release_url": "https://pypi.org/project/pollinotify/1.2/", "requires_dist": null, "requires_python": "", "summary": "inotify wrapper providing polling with timeout for specified filesystem events", "version": "1.2" }, "last_serial": 3441382, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "e5743ac6af921dbf290ea0316168a78b", "sha256": "e70eaeca581f4d987df96fb0f886df5ab959d50822fb538a5792ef88d7e96623" }, "downloads": -1, "filename": "pollinotify-0.1.0.tar.gz", "has_sig": false, "md5_digest": "e5743ac6af921dbf290ea0316168a78b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12269, "upload_time": "2014-08-28T23:55:36", "url": "https://files.pythonhosted.org/packages/71/1f/3586b935be7708b0014517e5a43bde06b470e2157379d1126b5627fb3f25/pollinotify-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "0d2f90a99f1434ccecd8ccec3bd87642", "sha256": "ea641e134101d1e0629b570a0acaeef0b5c3cd8dd664566016dc2f59486da8ac" }, "downloads": -1, "filename": "pollinotify-0.1.1.tar.gz", "has_sig": false, "md5_digest": "0d2f90a99f1434ccecd8ccec3bd87642", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12651, "upload_time": "2014-09-04T23:36:48", "url": "https://files.pythonhosted.org/packages/3d/37/805be3136a01f1920a1ce5a81e5b842cdfa0f6c951c49fa5a55d38ba4fdd/pollinotify-0.1.1.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "bb99627efbe86efd5631ed992995f102", "sha256": "e89ee19f32e74c1c0a0c49ee2aa148e29af85c35ce4df0dcd5253d4a23295a76" }, "downloads": -1, "filename": "pollinotify-1.2.tar.gz", "has_sig": false, "md5_digest": "bb99627efbe86efd5631ed992995f102", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13875, "upload_time": "2017-12-25T05:09:30", "url": "https://files.pythonhosted.org/packages/29/23/72f42f32ff3865d6e7a45a17c93964acdd80d847b90ade5276b63f4d7b69/pollinotify-1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "bb99627efbe86efd5631ed992995f102", "sha256": "e89ee19f32e74c1c0a0c49ee2aa148e29af85c35ce4df0dcd5253d4a23295a76" }, "downloads": -1, "filename": "pollinotify-1.2.tar.gz", "has_sig": false, "md5_digest": "bb99627efbe86efd5631ed992995f102", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13875, "upload_time": "2017-12-25T05:09:30", "url": "https://files.pythonhosted.org/packages/29/23/72f42f32ff3865d6e7a45a17c93964acdd80d847b90ade5276b63f4d7b69/pollinotify-1.2.tar.gz" } ] }