{ "info": { "author": "Ben Taylor", "author_email": "ben.taylor@sanger.ac.uk", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Programming Language :: Python", "Topic :: Communications :: Email", "Topic :: System :: Monitoring", "Topic :: Utilities" ], "description": "json2email\n===========\n\nTakes some json and a template and sends an email. Json can be provided\nas a filename or via stdin. Templates are rendered using\n`Jinja2 `_. If the template renders\nonly whitespace, json2email does not send an email. This can be used to\nimplement logic within the template itself.\n\njson2email accepts an argument for an email address which it will try\nand inform if there are errors. Obviously this isn't possible for some\nclasses of error.\n\nThis is still pretty untested so please raise an issue if you spot any\nbugs.\n\nUsage\n-----\n\n::\n\n $ json2email -h\n usage: json2email [-h] [--plain PLAIN] [--subject SUBJECT]\n [--to TO [TO ...]] [--from SENDER] [--server SERVER]\n [--error [ERROR [ERROR ...]]] [--noop] [--json JSON]\n\n Takes a jinja2 template and some json and sends an email\n\n optional arguments:\n -h, --help show this help message and exit\n --plain PLAIN, -p PLAIN\n Template with plain text template for email\n --subject SUBJECT, -s SUBJECT\n Subject line for email\n --to TO [TO ...], -t TO [TO ...]\n To: recipient of email\n --from SENDER, -f SENDER\n From: sender of email\n --server SERVER SMTP server\n --error [ERROR [ERROR ...]], -e [ERROR [ERROR ...]]\n Email address to send errors to (if any)\n --noop, -n Noop: if set, prints email to stdout instead of\n sending\n --json JSON, -j JSON Json formated data file (use '-' for stdin)\n\nExample\n-------\n\nOur team manages a pipeline to which users can add jobs. Some of these\njobs need to be approved by an admin before they run. We output a json\nsummary of the jobs which is shown below. We then use a template (also\nbelow) to render an email every day to remind us to approve the jobs.\n\nExample command (with noop):\n\n::\n\n $ json2email --plain examples/pipeline_jobs.txt.jinja \\\n --subject '[Pipeline-bot] Jobs needing approval' \\\n --to an_email_address@sanger.ac.uk \\\n --from no-reply@sanger.ac.uk \\\n --server localhost \\\n --error an_admin_address@sanger.ac.uk \\\n --json examples/pipeline_jobs_data.json \\\n --noop\n\nExample output:\n\n::\n\n Content-Type: text/plain; charset=\"us-ascii\"\n MIME-Version: 1.0\n Content-Transfer-Encoding: 7bit\n Subject: [Pipeline-bot] Jobs needing approval\n From: no-reply@sanger.ac.uk\n To: an_email_address@sanger.ac.uk\n\n 3 jobs require approval\n /parent\\_dir/annotation\\_job\\_tracker.conf has 1 jobs needing admin attention\n /parent\\_dir/assembly\\_job\\_tracker.conf has 2 jobs needing admin attention\n Report last updated at 2015-03-24T15:26:17.246253\n\nExample json:\n\n::\n\n {\n \"created_at\": \"2015-03-24T15:26:17.246253\",\n \"jobs\": [\n {\n \"approval_required\": true,\n \"config_file\": \"/parent_dir/assembly_jobs/job_1.conf\",\n \"job_type\": \"__Assembly__\",\n \"pipeline_tracker\": \"/parent_dir/assembly_job_tracker.conf\"\n },\n {\n \"approval_required\": true,\n \"config_file\": \"/parent_dir/assembly_jobs/job_2.conf\",\n \"job_type\": \"__Assembly__\",\n \"pipeline_tracker\": \"/parent_dir/assembly_job_tracker.conf\"\n },\n {\n \"approval_required\": false,\n \"config_file\": \"/parent_dir/assembly_jobs/job_3.conf\",\n \"job_type\": \"__Assembly__\",\n \"pipeline_tracker\": \"/parent_dir/assembly_job_tracker.conf\"\n },\n {\n \"approval_required\": true,\n \"config_file\": \"/parent_dir/annotation_jobs/job_1.conf\",\n \"job_type\": \"__Annotation__\",\n \"pipeline_tracker\": \"/parent_dir/annotation_job_tracker.conf\"\n },\n {\n \"approval_required\": false,\n \"config_file\": \"/parent_dir/mapping_jobs/job_1.conf\",\n \"job_type\": \"__Mapping__\",\n \"pipeline_tracker\": \"/parent_dir/mapping_job_tracker.conf\"\n },\n {\n \"approval_required\": false,\n \"config_file\": \"/parent_dir/mapping_jobs/job_2.conf\",\n \"job_type\": \"__Mapping__\",\n \"pipeline_tracker\": \"/parent_dir/mapping_job_tracker.conf\"\n }\n ]\n }\n\nExample template:\n\n::\n\n {% set jobs_requiring_approval = jobs | selectattr('approval_required') | list -%}\n {%- if jobs_requiring_approval -%}\n {{ jobs_requiring_approval | count }} jobs require approval\n {%- for jobs_in_tracker in jobs_requiring_approval | groupby('pipeline_tracker') %}\n {{ jobs_in_tracker.grouper }} has {{ jobs_in_tracker.list | count }} jobs needing admin attention\n {%- endfor %}\n Report last updated at {{ created_at }}\n {%- endif -%}\n\nRequirements\n------------\n\n- jinja2\n- smtplib\n- email\n- re\n\nFor tests:\n\n- unittest\n- mock\n\nTesting\n-------\n\nTest are run using:\n\n::\n\n ./run_tests.sh\n\njson2email has been tested on Ubuntu 12.04 with python 2.7.3", "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/sanger-pathogens/json2email", "keywords": null, "license": "GPLv3", "maintainer": null, "maintainer_email": null, "name": "json2email", "package_url": "https://pypi.org/project/json2email/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/json2email/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/sanger-pathogens/json2email" }, "release_url": "https://pypi.org/project/json2email/0.0.6/", "requires_dist": null, "requires_python": null, "summary": "Takes a jinja2 template and some json and sends an email", "version": "0.0.6" }, "last_serial": 1481393, "releases": { "0.0.5": [ { "comment_text": "", "digests": { "md5": "c3e2a8cb552168c5b0c0db5f93fca0a2", "sha256": "bf91ec586853f49cfad713236d66587d4551233aeb8cf67f01bdb03a52383a78" }, "downloads": -1, "filename": "json2email-0.0.5.tar.gz", "has_sig": false, "md5_digest": "c3e2a8cb552168c5b0c0db5f93fca0a2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5769, "upload_time": "2015-03-28T16:43:03", "url": "https://files.pythonhosted.org/packages/62/cc/a8548247cc7f90bb7b9249afb19b46b08ce7e923437422b9c9208bbd6c7f/json2email-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "961b92b48fd55011260d7343124b4a52", "sha256": "3fd5487ae661a76a1fdbe1e2ddfb7943f83c22f147036f517973760d2c29c7a3" }, "downloads": -1, "filename": "json2email-0.0.6.tar.gz", "has_sig": false, "md5_digest": "961b92b48fd55011260d7343124b4a52", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5763, "upload_time": "2015-03-28T16:56:56", "url": "https://files.pythonhosted.org/packages/4b/61/b4359380c839e0cc7ed66c82014dedf3d161e691114a5de088fd49691939/json2email-0.0.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "961b92b48fd55011260d7343124b4a52", "sha256": "3fd5487ae661a76a1fdbe1e2ddfb7943f83c22f147036f517973760d2c29c7a3" }, "downloads": -1, "filename": "json2email-0.0.6.tar.gz", "has_sig": false, "md5_digest": "961b92b48fd55011260d7343124b4a52", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5763, "upload_time": "2015-03-28T16:56:56", "url": "https://files.pythonhosted.org/packages/4b/61/b4359380c839e0cc7ed66c82014dedf3d161e691114a5de088fd49691939/json2email-0.0.6.tar.gz" } ] }