{ "info": { "author": "Fabio Codiglioni", "author_email": "fabiocody@icloud.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": "# jasper-sys [![Build Status](https://travis-ci.org/fabiocody/jasper-sys.svg?branch=master)](https://travis-ci.org/fabiocody/jasper-sys)\n\n\n## Overview\n\nJasper is a system designed to supervise your programs that need to be kept running.\nFor example, let's say you have a set of scripts for your smart home system. Of course you don't want these scripts to stop working, otherwise your smart home system would act weirdly, or not work at all. Jasper can help you keep the scripts running and you can also set up some custom actions to be executed when the state of a process changes (e.g. for notification or logging).\n\n\n## Installation\n\nExecute this in a terminal window. Since Jasper is written to work only with Python 3.4+, you have to use the right version of `pip` (normally `pip3` should work).\n```\nsudo pip3 install jasper-sys\n```\n\n\n## Get started\n\nEvery program that has to be controlled by Jasper is called __module__. To get started, you have to create a JSON file to store all of your modules information. Since you're going to pass the file path to the program, you can name it whatever you want, and place it wherever you like.\nHere's an example of what it should look like\n\n```json\n{\n\t\"module_name\": {\n\t\t\"command\": \"/path/to/executable arg1 arg2\",\n\t\t\"start_on_boot\": true,\n\t\t\"restart_on_crash\": true\n\t}\n}\n```\n\nIn the `command` field you have to enter the complete call to your program, as if you were calling it from a terminal window (full paths are highly recommended). The `start_on_boot` and `restart_on_crash` fields indicate respectively if you want your program to be started as soon as Jasper starts, and if you want your program to be restarted when it crashes.\n\nNext, you're going to create a script to get everything up and tuned the way you want.\nHere's an example\n\n```python\nfrom jaspercore import JasperCore\nfrom datetime import datetime\n\ndef log_restart(module):\n\t'''Log a message when a module restarts'''\n\twith open('/path/to/logfile', 'a') as f:\n\t\tf.write('{0} - {1} restarted.'.format(datetime.now(), module))\n\ndef log_start_failure(module):\n\t'''Log a message when a module fails to start'''\n\twith open('/path/to/logfile', 'a') as f:\n\t\tf.write('{0} - {1} failed to start.'.format(datetime.now(), module))\n\ncallback_table = {\n\t'restart': log_restart,\n\t'exec_fail': log_start_failure\n}\n\nJasperCore('/path/to/modules.json', callback_table=callback_table, start_all=True)\n```\n\nThe `JasperCore` class is the main interface to Jasper system. All you need to do to start the system is calling it. The class takes 4 arguments:\n- `modules_file `: the path to the JSON file;\n- `callback_table (optional)`: dictionary of type {str: function} (see below for more information);\n- `start_all (optional, default=False)`: flag to indicate if you want all your enabled modules to be started when the system starts;\n- `restarts_no (optional, default=-1)`: maximum number of restarts for each module (-1 = inf).\n\n\n### Callback table\n\nYou can provide some callbacks to be executed at certain points of a module's lifecycle. Every callback needs to be a function taking only one argument, i.e. the module name.\nThe available callback entries are:\n- `start`: executed when a module starts;\n- `restart`: executed when a module restarts;\n- `stop_restart`: executed when you reach the maximum number of restarts;\n- `exec_fail`: executed when the module fails to start.\n\nYou don't have to create a callback for every available entry, just the ones you need. The listed entries must be used as the keys of the dictionary you're going to provide to the `JasperCore` class.\n\n\n## jasperctl\n\n`jasperctl` is a remote interface to the core system.\nIf you are on the machine Jasper core is running, simply type `jasperctl` in a terminal window. If you are on a remote machine, type `jasperctl -c host` to connect to the remote Jasper core.\nOnce you are connected to a Jasper core session, you can\n- check which modules are running and which are not;\n- start/stop modules.\n\n\n## Contribution\n\nIf you like to contribute, please open an issue.\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/fabiocody/jasper.git", "keywords": "jasper", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "jasper-sys", "package_url": "https://pypi.org/project/jasper-sys/", "platform": "", "project_url": "https://pypi.org/project/jasper-sys/", "project_urls": { "Homepage": "https://github.com/fabiocody/jasper.git" }, "release_url": "https://pypi.org/project/jasper-sys/0.2.4/", "requires_dist": null, "requires_python": "", "summary": "Jasper is a system designed to supervise your programs that need to be kept running.", "version": "0.2.4" }, "last_serial": 3122726, "releases": { "0.2.0": [ { "comment_text": "", "digests": { "md5": "e640cea76906d57abe3c68e21e34ed79", "sha256": "2e6e926b38e1d18fd93e2ec729ec3cec6815d114385a0bf0a4aa02d0bf3e29a7" }, "downloads": -1, "filename": "jasper-sys-0.2.0.tar.gz", "has_sig": false, "md5_digest": "e640cea76906d57abe3c68e21e34ed79", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5946, "upload_time": "2017-08-12T19:21:49", "url": "https://files.pythonhosted.org/packages/ae/44/ad13050a006f663de52547c05b636c7c9a7fef3eb3c843352dc2df0a395f/jasper-sys-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "96344d48042924109e1631c1a16471f2", "sha256": "603d93544176f05925f5f4ca6d2539c87ad0b85b80fa0ddfb0b98f0ace7f8698" }, "downloads": -1, "filename": "jasper-sys-0.2.1.tar.gz", "has_sig": false, "md5_digest": "96344d48042924109e1631c1a16471f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5962, "upload_time": "2017-08-12T19:39:54", "url": "https://files.pythonhosted.org/packages/6b/ec/471e77bfcbba0b9d183adf7858382639b760d266973100bd527cdccbd9d7/jasper-sys-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "4fa9407ed1aec1ffe8c20cd19f05f77d", "sha256": "dcd9b995a882402de3cc26dd3e8d11636bfb281beb7b330d8b37d77a44259301" }, "downloads": -1, "filename": "jasper-sys-0.2.2.tar.gz", "has_sig": false, "md5_digest": "4fa9407ed1aec1ffe8c20cd19f05f77d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6247, "upload_time": "2017-08-25T09:23:27", "url": "https://files.pythonhosted.org/packages/45/56/fe2d0db7a441f9ac619a15d281664e1884dbe1d8955e029e7b41b9b780bc/jasper-sys-0.2.2.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "6fad47c046428d53d29b3a13ec20bc6f", "sha256": "3847d888cc81fc3cff4ebde81a48d28679d327b56ce1cf4a196db4809a58b250" }, "downloads": -1, "filename": "jasper-sys-0.2.3.tar.gz", "has_sig": false, "md5_digest": "6fad47c046428d53d29b3a13ec20bc6f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6306, "upload_time": "2017-08-25T09:42:44", "url": "https://files.pythonhosted.org/packages/8b/6e/517176b4968446ddcfb2ddfe58761d1165dbdb68f0dce5038d16019226e5/jasper-sys-0.2.3.tar.gz" } ], "0.2.4": [ { "comment_text": "", "digests": { "md5": "dd2b9375dda2ae6670b6fa2eca22574e", "sha256": "d7006589571f40b7cb5708c995179bb68ae37fe48f96ab343fea6614d62a28b1" }, "downloads": -1, "filename": "jasper-sys-0.2.4.tar.gz", "has_sig": false, "md5_digest": "dd2b9375dda2ae6670b6fa2eca22574e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6310, "upload_time": "2017-08-25T09:47:45", "url": "https://files.pythonhosted.org/packages/63/40/ce4624b4db9e13a3d680d8b13ac54b96a527646b6172715a85158d655e13/jasper-sys-0.2.4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "dd2b9375dda2ae6670b6fa2eca22574e", "sha256": "d7006589571f40b7cb5708c995179bb68ae37fe48f96ab343fea6614d62a28b1" }, "downloads": -1, "filename": "jasper-sys-0.2.4.tar.gz", "has_sig": false, "md5_digest": "dd2b9375dda2ae6670b6fa2eca22574e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6310, "upload_time": "2017-08-25T09:47:45", "url": "https://files.pythonhosted.org/packages/63/40/ce4624b4db9e13a3d680d8b13ac54b96a527646b6172715a85158d655e13/jasper-sys-0.2.4.tar.gz" } ] }