{ "info": { "author": "Jan-Piet Mens", "author_email": "jpmens@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: MacOS :: MacOS X", "Operating System :: POSIX", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Topic :: Communications", "Topic :: Internet" ], "description": "mqtt-watchdir\n=============\n\nThis simple Python program portably watches a directory recursively and\npublishes the content of newly created and modified files as payload to\nan `MQTT `_ broker. Files which are deleted are\npublished with a NULL payload.\n\nThe path to the directory to watch recursively (default ``.``), as well\nas a list of files to ignore (``*.swp``, ``*.o``, ``*.pyc``), the broker\nhost (``localhost``) and port number (``1883``) must be specified in via\nenvironment variables , together with the topic prefix to which to\npublish to (``watch/``).\n\nInstallation\n------------\n\n::\n\n git clone https://github.com/jpmens/mqtt-watchdir.git\n cd mqtt-watchdir\n virtualenv watchdir\n source watchdir/bin/activate\n pip install -e .\n\nConfiguration\n-------------\n\nSet the following optional environment variables before invoking\n*mqtt-watchdir.py*:\n\n- ``MQTTHOST`` (default ``\"localhost\"``) is the name/address of the MQTT broker.\n- ``MQTTPORT`` (default ``1883``) is the TCP port number of the broker.\n- ``MQTTWATCHDIR`` (default: ``\".\"``) is the path to the directory to watch.\n- ``MQTTQOS`` (default: ``0``) is the MQTT Quality of Service (QoS) to\n use on publish. Allowed values are ``0``, ``1``, or ``2``.\n- ``MQTTRETAIN`` (default: ``0``) specifies whether the \"retain\" flag\n should be set on publish. Set to ``1`` if you want messages to be retained.\n- ``MQTTPREFIX`` (default: ``\"watch\"``) is the prefix to be prepended\n (with a slash) to the MQTT topic name. The topic name is formed from\n this prefix plus the path name of the file that is being modified\n (i.e. watched). You can set this to an empty string (``\"\"``) to avoid\n prefixing the topic name.\n- ``MQTTFILTER`` (default None) allows modifying payload (see below).\n Takes path to a Python file (e.g. ``\"/path/to/example-filter.py\"``.\n- ``MQTTFIXEDTOPIC`` (default None) sets a MQTT topic to which\n all messages are published. If set, the ``MQTTPREFIX`` setting is\n overruled and ignored.\n\n- Set ``WATCHDEBUG`` (default: ``0``) to ``1`` to show debugging\n information.\n\nTesting\n-------\n\nLaunch ``mosquitto_sub``:\n\n::\n\n mosquitto_sub -v -t 'watch/#'\n\nLaunch this program and, in another terminal, try something like this:\n\n::\n\n echo Hello World > message\n echo JP > myname\n rm myname\n\nwhereupon, on the first window, you should see:\n\n::\n\n watch/message Hello World\n watch/myname JP\n watch/myname (null)\n\nFilters\n-------\n\nWithout a filter (the default), *mqtt-watchdir* reads the content of a\nnewly created or modified file and uses that as the MQTT payload. By\ncreating and enabling a so-called *filter*, *mqtt-watchdir* can pass the\npayload into said filter (a Python function) to have a payload\ntranslated.\n\nConsider the included ``example-filter.py``:\n\n::\n\n def mfilter(filename, topic, payload):\n '''Return a tuple [pub, newpayload] indicating whether this event\n should be published (True or False) and a new payload string\n or None'''\n\n print \"Filter for topic %s\" % topic\n\n if filename.endswith('.jpg'):\n return False, None\n\n if payload is not None:\n return True, payload.replace(\"\\n\", \"-\").replace(\" \", \"+\")\n return True, None\n\nThe *mfilter* function is passed the fully qualified path to the file,\nthe (possibly prefixed) MQTT topic name and the payload. In this simple\nexample, spaces and newlines in the payload are replaced by dashes and\nplusses.\n\nThe function must return a tuple with two elements:\n\n1. The first specifies whether the payload will be published (True) or\n not (False)\n2. The second is a string with a possibly modified payload or None. If\n the returned payload is *None*, the original payload is not modified.\n\nPossible uses of filters include\n\n- Limiting payload lengths\n- Conversion to JSON\n- Ignore certain file types (e.g. binary data)\n- Process content of files, say, YAML or JSON, and extract elements\n returning as string\n\nRequirements\n------------\n\n- `watchdog `_, a Python\n library to monitor file-system events.\n- `Paho-MQTT `_'s Python module\n\nRelated utilities & Credits\n---------------------------\n\n- Roger Light (of `Mosquitto `_ fame) created\n `mqttfs `_, a FUSE driver (in C)\n which works similarly.\n- Roger Light (yes, the same busy gentleman) also made\n `treewatch `_, a program to\n watch a set of directories and execute a program when there is a\n change in the files within the directories.\n- Thanks to Karl Palsson for the ``setup.py`` and ``version.py`` magic.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/jpmens/mqtt-watchdir", "keywords": "MQTT,files,notify", "license": "BSD License", "maintainer": null, "maintainer_email": null, "name": "mqtt-watchdir", "package_url": "https://pypi.org/project/mqtt-watchdir/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/mqtt-watchdir/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/jpmens/mqtt-watchdir" }, "release_url": "https://pypi.org/project/mqtt-watchdir/2.2/", "requires_dist": null, "requires_python": null, "summary": "Recursively watch a directory for modifications and publish file content to an MQTT broker", "version": "2.2" }, "last_serial": 1532949, "releases": { "1.3": [ { "comment_text": "", "digests": { "md5": "4035b26b3bbc2648a6b1a2b316d80527", "sha256": "59438cc1ecbb1cb6d3c1a3bccf7fd552f4bf4c4247d6d4f15130fed7d7393f81" }, "downloads": -1, "filename": "mqtt-watchdir-1.3.tar.gz", "has_sig": false, "md5_digest": "4035b26b3bbc2648a6b1a2b316d80527", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4291, "upload_time": "2013-08-16T05:32:15", "url": "https://files.pythonhosted.org/packages/8b/12/a86bcc3451f96673cd3ed417c6f81327e7df7c316356bb2d531d74eacb25/mqtt-watchdir-1.3.tar.gz" } ], "2.0-10-g926c526": [ { "comment_text": "", "digests": { "md5": "8df90cd410427207063116b56396ecd2", "sha256": "3c4ccecdb6f67d0261a40fe1a197b20a96c5ff9ade5e735966eef85a6253a56e" }, "downloads": -1, "filename": "mqtt-watchdir-2.0-10-g926c526.tar.gz", "has_sig": false, "md5_digest": "8df90cd410427207063116b56396ecd2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7231, "upload_time": "2013-08-16T13:05:25", "url": "https://files.pythonhosted.org/packages/6a/60/6b0d9ac18259d9a1d5dce1d65798aa453eb1004c43df9456e0cc4385e6f7/mqtt-watchdir-2.0-10-g926c526.tar.gz" } ], "2.0-8-ge6ac542": [ { "comment_text": "", "digests": { "md5": "458776d50ef812e6cda204e1fc4da3d0", "sha256": "bd88a1bef096bfef6812b32b94303ce92f6755d229e390b9e1af551255598437" }, "downloads": -1, "filename": "mqtt-watchdir-2.0-8-ge6ac542.tar.gz", "has_sig": false, "md5_digest": "458776d50ef812e6cda204e1fc4da3d0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6228, "upload_time": "2013-08-16T10:40:02", "url": "https://files.pythonhosted.org/packages/ca/14/8d4592c1c0650fbad3628a86a932448e0e9919df43171e99871fc5ae7989/mqtt-watchdir-2.0-8-ge6ac542.tar.gz" } ], "2.2": [ { "comment_text": "", "digests": { "md5": "cfe83a3fcbe5829953624dac1f730168", "sha256": "721d4588bfeb1ec73cf20777a0ca885acc97af03c7abec466ec625c3d36d40b5" }, "downloads": -1, "filename": "mqtt-watchdir-2.2.tar.gz", "has_sig": false, "md5_digest": "cfe83a3fcbe5829953624dac1f730168", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7569, "upload_time": "2015-05-04T19:46:02", "url": "https://files.pythonhosted.org/packages/d7/98/e3b9ed14136b35487c0299dda497fddb311d6fdb60141fcdf65282a4637b/mqtt-watchdir-2.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "cfe83a3fcbe5829953624dac1f730168", "sha256": "721d4588bfeb1ec73cf20777a0ca885acc97af03c7abec466ec625c3d36d40b5" }, "downloads": -1, "filename": "mqtt-watchdir-2.2.tar.gz", "has_sig": false, "md5_digest": "cfe83a3fcbe5829953624dac1f730168", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7569, "upload_time": "2015-05-04T19:46:02", "url": "https://files.pythonhosted.org/packages/d7/98/e3b9ed14136b35487c0299dda497fddb311d6fdb60141fcdf65282a4637b/mqtt-watchdir-2.2.tar.gz" } ] }