{"id":18486824,"url":"https://github.com/jrodal98/sms-decorator","last_synced_at":"2025-05-13T22:14:31.882Z","repository":{"id":116040498,"uuid":"191088055","full_name":"jrodal98/sms-decorator","owner":"jrodal98","description":"A python decorator that sends you an SMS when a function finishes execution.","archived":false,"fork":false,"pushed_at":"2019-06-10T04:18:07.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-16T22:18:52.611Z","etag":null,"topics":["decorator","decorators","sms","twilio","twilio-python","twilio-sms"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jrodal98.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-10T03:11:12.000Z","updated_at":"2019-06-10T04:20:04.000Z","dependencies_parsed_at":"2023-03-17T18:30:18.644Z","dependency_job_id":null,"html_url":"https://github.com/jrodal98/sms-decorator","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrodal98%2Fsms-decorator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrodal98%2Fsms-decorator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrodal98%2Fsms-decorator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jrodal98%2Fsms-decorator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jrodal98","download_url":"https://codeload.github.com/jrodal98/sms-decorator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254036843,"owners_count":22003654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["decorator","decorators","sms","twilio","twilio-python","twilio-sms"],"created_at":"2024-11-06T12:49:51.889Z","updated_at":"2025-05-13T22:14:31.845Z","avatar_url":"https://github.com/jrodal98.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sms-decorator\n\nThe `sms_decorator.py` file contains a decorator that will send you a text message with details about the execution when a decorated function finishes execution.  This is helpful when waiting on long processes, as you don't have to constantly check your python process to see if it has finished.  The output will look something like this:\n\n    Sent from your Twilio trial account - A python function has finished exectuting.\n\n            Function: test_function\n\n            Arguments: (1, 2)\n\n            Keyword Arguments: {'kwarg1': 3, 'kwarg2': 4}\n\n            Returned: 10\n\n            Length of Execution: 2.002 seconds\n\n            Sent at: 22:57\n\nor this\n\n    Sent from your Twilio trial account - A python function has finished exectuting, but the information is too large to display.\n\n            Function: batch_classify\n\n            Length of Execution: 2.947 minutes\n\n            Sent at: 00:07\n\n## How to use\nNOTE: You'll need to be running python 3.6+ for this to work, as my code uses f-strings, which weren't introduced until python 3.6. If you refuse to update, you can modify the two or three lines of codes that use f-strings easily.\n### Setup\nIn the event that there is ever demand for this decorator, I will look into adding this project to PyPI.  In the meantime, you'll want to do the following:\n\n1) Clone this repo.\n```bash\ngit clone https://github.com/jrodal98/sms-decorator.git\n```\n2) Install dependencies doing something like this:\n```bash\ncd sms-decorator\npip3 install -r requirements.txt\n```\n3) Copy `sms_decorator.py` and `config.py` into any project you want to use the decorator in.\n4) Setup a free twilio account [here](https://www.twilio.com/)\n5) Setup the config.py file (skeleton provided).  It should include the following:\n    1) Your account SID\n    2) Your auth token\n    3) Your twilio number\n    4) Your cellphone number\n6) import `sms_decorator as sms_decorator` into the file you desire.  You might need to import it differently depending on the structure of your project. (Left as an exercise to the reader)\nI recommend running `test.py` to verify that everything is setup properly.\n\n### Usage\nIf you don't know what decorators are, consider reading this [short explanation](https://www.geeksforgeeks.org/decorators-in-python/).  Essentially, decorators allow you to wrap another function to extend its behavior without permanently modifying it.  In our case, the SMS decorator grants your function the ability to operate as you write it with the bonus behavior of also sending a text message when your function completes its execution.  It can be used like so:\n\n```python\nfrom sms_decorator import sms_decorator\n\n@sms_decorator\ndef your_function():\n    print(\"Do whatever you want here\")\n\n\"\"\"Above code is equivalent to - \n  \ndef your_function():\n    print(\"Do whatever you want here\")\n      \nyour_function = sms_decorator(your_function)\"\"\"\n```\n\nWhen `your_function` is executed, it will print \"Do whatever you want here\" and then send you a text message.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjrodal98%2Fsms-decorator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjrodal98%2Fsms-decorator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjrodal98%2Fsms-decorator/lists"}