Name | asterisk-ami JSON |
Version | 0.1.7 JSON |
download | |
home_page | |
Summary | Python AMI Client |
upload_time | 2024-01-05 12:16:17 |
maintainer | |
docs_url | None |
author | |
requires_python | |
license | |
keywords | asterisk ami |
VCS | |
bugtrack_url | |
requirements | No requirements were recorded. |
Travis-CI | |
coveralls test coverage | No coveralls. |
================= Python AMI Client ================= .. image:: https://travis-ci.org/ettoreleandrotognoli/python-ami.svg?branch=master :target: https://travis-ci.org/ettoreleandrotognoli/python-ami .. image:: https://codecov.io/gh/ettoreleandrotognoli/python-ami/branch/master/graph/badge.svg :target: https://codecov.io/gh/ettoreleandrotognoli/python-ami .. image:: https://badge.fury.io/py/asterisk-ami.svg :target: https://badge.fury.io/py/asterisk-ami .. image:: https://img.shields.io/pypi/dm/asterisk-ami.svg :target: https://pypi.python.org/pypi/asterisk-ami#downloads .. image:: https://api.codeclimate.com/v1/badges/429cda25d75ab470d7f6/maintainability :target: https://codeclimate.com/github/ettoreleandrotognoli/python-ami/maintainability :alt: Maintainability .. image:: https://api.codeclimate.com/v1/badges/429cda25d75ab470d7f6/test_coverage :target: https://codeclimate.com/github/ettoreleandrotognoli/python-ami/test_coverage :alt: Test Coverage .. image:: https://www.codefactor.io/repository/github/ettoreleandrotognoli/python-ami/badge :target: https://www.codefactor.io/repository/github/ettoreleandrotognoli/python-ami :alt: CodeFactor A simple Python AMI client See the `code of conduct <CODE_OF_CONDUCT.md>`_. Install ------- Install asterisk-ami .. code-block:: shell pip install asterisk-ami Install latest asterisk-ami .. code-block:: shell pip install git+https://github.com/ettoreleandrotognoli/python-ami Usage ----- Connect ~~~~~~~ .. code-block:: python from asterisk.ami import AMIClient client = AMIClient(address='127.0.0.1',port=5038) client.login(username='username',secret='password') Disconnect ~~~~~~~~~~ .. code-block:: python client.logoff() Send an action ~~~~~~~~~~~~~~ .. code-block:: python from asterisk.ami import SimpleAction action = SimpleAction( 'Originate', Channel='SIP/2010', Exten='2010', Priority=1, Context='default', CallerID='python', ) client.send_action(action) Send an action with adapter ~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: python from asterisk.ami import AMIClientAdapter adapter = AMIClientAdapter(client) adapter.Originate( Channel='SIP/2010', Exten='2010', Priority=1, Context='default', CallerID='python', ) Synchronous Response ~~~~~~~~~~~~~~~~~~~~ .. code-block:: python #without adapter future = client.send_action(action) response = future.response #with adapter future = adapter.Originate(...) response = future.response Asynchronous Response ~~~~~~~~~~~~~~~~~~~~~ .. code-block:: python def callback_response(response): print(response) #without adapter future = client.send_action(action,callback=callback_response) #with adapter future = adapter.Originate(...,_callback=callback_response) #you can use the future to wait the callback execute reponse = future.response Listen Events ~~~~~~~~~~~~~ .. code-block:: python def event_listener(event,**kwargs): print(event) client.add_event_listener(event_listener) Filter Events ~~~~~~~~~~~~~ With a custom class .. code-block:: python from asterisk.ami import EventListener class RegistryEventListener(EventListener): def on_Registry(event,**kwargs): print('Registry Event',event) client.add_event_listener(RegistryEventListener()) class AllEventListener(EventListener): def on_event(event,**kwargs): print('Event',event) client.add_event_listener(AllEventListener()) With black or white list .. code-block:: python def event_listener(event,**kwargs): print(event) client.add_event_listener( event_listener, white_list=['Registry','PeerStatus'] ) client.add_event_listener( event_listener, black_list=['VarSet'] ) Like a custom class .. code-block:: python def event_listener(event,**kwargs): print(event) client.add_event_listener( on_VarSet=event_listener, on_ExtensionStatus=event_listener ) client.add_event_listener( on_event=event_listener ) Filter Event Value ~~~~~~~~~~~~~~~~~~ .. code-block:: python def event_listener(event,**kwargs): print('Ringing',event) client.add_event_listener( event_listener, white_list='Newstate', ChannelStateDesc='Ringing', ConnectedLineNum='2004', ) Filter with regex ~~~~~~~~~~~~~~~~~ .. code-block:: python import re def event_listener(event,**kwargs): print(event) client.add_event_listener( on_Newstate=event_listener, white_list=re.compile('.*'), ChannelStateDesc=re.compile('^Ring.*'), )
{ "_id": null, "home_page": "", "name": "asterisk-ami", "maintainer": "", "docs_url": null, "requires_python": "", "maintainer_email": "", "keywords": "asterisk,ami", "author": "", "author_email": "Ettore Leandro Tognoli <ettore.leandro.tognoli@gmail.com>", "download_url": "https://files.pythonhosted.org/packages/46/01/ae378a9b0ae4516bc2eee7332e2296a3574bb42feae5ccf2bd8cf7f1968c/asterisk-ami-0.1.7.tar.gz", "platform": null, "description": "=================\nPython AMI Client\n=================\n\n.. image:: https://travis-ci.org/ettoreleandrotognoli/python-ami.svg?branch=master\n :target: https://travis-ci.org/ettoreleandrotognoli/python-ami\n\n.. image:: https://codecov.io/gh/ettoreleandrotognoli/python-ami/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/ettoreleandrotognoli/python-ami\n\n.. image:: https://badge.fury.io/py/asterisk-ami.svg\n :target: https://badge.fury.io/py/asterisk-ami\n\n.. image:: https://img.shields.io/pypi/dm/asterisk-ami.svg\n :target: https://pypi.python.org/pypi/asterisk-ami#downloads\n \n.. image:: https://api.codeclimate.com/v1/badges/429cda25d75ab470d7f6/maintainability\n :target: https://codeclimate.com/github/ettoreleandrotognoli/python-ami/maintainability\n :alt: Maintainability\n \n.. image:: https://api.codeclimate.com/v1/badges/429cda25d75ab470d7f6/test_coverage\n :target: https://codeclimate.com/github/ettoreleandrotognoli/python-ami/test_coverage\n :alt: Test Coverage\n\n.. image:: https://www.codefactor.io/repository/github/ettoreleandrotognoli/python-ami/badge\n :target: https://www.codefactor.io/repository/github/ettoreleandrotognoli/python-ami\n :alt: CodeFactor\n\nA simple Python AMI client\n\nSee the `code of conduct <CODE_OF_CONDUCT.md>`_.\n\nInstall\n-------\n\nInstall asterisk-ami\n\n.. code-block:: shell\n\n pip install asterisk-ami\n\nInstall latest asterisk-ami\n\n.. code-block:: shell\n\n pip install git+https://github.com/ettoreleandrotognoli/python-ami\n\nUsage\n-----\n\n\nConnect\n~~~~~~~\n\n.. code-block:: python\n\n from asterisk.ami import AMIClient\n \n client = AMIClient(address='127.0.0.1',port=5038)\n client.login(username='username',secret='password')\n \nDisconnect\n~~~~~~~~~~\n\n.. code-block:: python\n\n client.logoff()\n\n\nSend an action\n~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n from asterisk.ami import SimpleAction\n \n action = SimpleAction(\n 'Originate',\n Channel='SIP/2010',\n Exten='2010',\n Priority=1,\n Context='default',\n CallerID='python',\n )\n client.send_action(action)\n\n\nSend an action with adapter\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n from asterisk.ami import AMIClientAdapter\n \n adapter = AMIClientAdapter(client)\n adapter.Originate(\n Channel='SIP/2010',\n Exten='2010',\n Priority=1,\n Context='default',\n CallerID='python',\n )\n \nSynchronous Response\n~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n #without adapter\n future = client.send_action(action)\n response = future.response\n \n #with adapter\n future = adapter.Originate(...)\n response = future.response\n \n\nAsynchronous Response\n~~~~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n def callback_response(response):\n print(response)\n\n #without adapter\n future = client.send_action(action,callback=callback_response)\n \n #with adapter\n future = adapter.Originate(...,_callback=callback_response)\n \n #you can use the future to wait the callback execute\n reponse = future.response\n\nListen Events\n~~~~~~~~~~~~~\n\n.. code-block:: python\n\n def event_listener(event,**kwargs):\n print(event)\n\n client.add_event_listener(event_listener)\n \n\nFilter Events\n~~~~~~~~~~~~~\n\nWith a custom class\n\n.. code-block:: python\n\n from asterisk.ami import EventListener\n\n class RegistryEventListener(EventListener):\n \n def on_Registry(event,**kwargs):\n print('Registry Event',event)\n \n client.add_event_listener(RegistryEventListener())\n \n class AllEventListener(EventListener):\n \n def on_event(event,**kwargs):\n print('Event',event)\n \n client.add_event_listener(AllEventListener())\n\nWith black or white list\n\n.. code-block:: python\n\n def event_listener(event,**kwargs):\n print(event)\n \n client.add_event_listener(\n event_listener, white_list=['Registry','PeerStatus']\n )\n \n client.add_event_listener(\n event_listener, black_list=['VarSet']\n )\n \nLike a custom class\n\n.. code-block:: python\n\n def event_listener(event,**kwargs):\n print(event)\n \n client.add_event_listener(\n on_VarSet=event_listener,\n on_ExtensionStatus=event_listener\n )\n \n client.add_event_listener(\n on_event=event_listener\n )\n \n\nFilter Event Value\n~~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n def event_listener(event,**kwargs):\n print('Ringing',event)\n \n \n client.add_event_listener(\n event_listener,\n white_list='Newstate',\n ChannelStateDesc='Ringing',\n ConnectedLineNum='2004',\n )\n \nFilter with regex\n~~~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n import re\n \n def event_listener(event,**kwargs):\n print(event)\n \n client.add_event_listener(\n on_Newstate=event_listener,\n white_list=re.compile('.*'),\n ChannelStateDesc=re.compile('^Ring.*'),\n )\n \n \n", "bugtrack_url": null, "license": "", "summary": "Python AMI Client", "version": "0.1.7", "project_urls": { "Bug Tracker": "https://github.com/ettoreleandrotognoli/python-ami/issues", "Homepage": "https://github.com/ettoreleandrotognoli/python-ami" }, "split_keywords": [ "asterisk", "ami" ], "urls": [ { "comment_text": "", "digests": { "blake2b_256": "3798a29af5201e7a2c9c948debe134def3a636f73fb884710e6afb30771e487f", "md5": "43191867f9734ff3cfd5ddfbee6d235f", "sha256": "b94baabc1107214f3369a804fd1efda0649ba6afcb21095c6b438b6245fef7ff" }, "downloads": -1, "filename": "asterisk_ami-0.1.7-py3-none-any.whl", "has_sig": false, "md5_digest": "43191867f9734ff3cfd5ddfbee6d235f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9745, "upload_time": "2024-01-05T12:16:16", "upload_time_iso_8601": "2024-01-05T12:16:16.387575Z", "url": "https://files.pythonhosted.org/packages/37/98/a29af5201e7a2c9c948debe134def3a636f73fb884710e6afb30771e487f/asterisk_ami-0.1.7-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "blake2b_256": "4601ae378a9b0ae4516bc2eee7332e2296a3574bb42feae5ccf2bd8cf7f1968c", "md5": "b8b70e5ada4d05d6ce619ce91583bd6f", "sha256": "de954116b7b03fb1b5420d9d83d847a3ba0d4cf1449847eada88b4bfde080136" }, "downloads": -1, "filename": "asterisk-ami-0.1.7.tar.gz", "has_sig": false, "md5_digest": "b8b70e5ada4d05d6ce619ce91583bd6f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 33440, "upload_time": "2024-01-05T12:16:17", "upload_time_iso_8601": "2024-01-05T12:16:17.945242Z", "url": "https://files.pythonhosted.org/packages/46/01/ae378a9b0ae4516bc2eee7332e2296a3574bb42feae5ccf2bd8cf7f1968c/asterisk-ami-0.1.7.tar.gz", "yanked": false, "yanked_reason": null } ], "upload_time": "2024-01-05 12:16:17", "github": true, "gitlab": false, "bitbucket": false, "codeberg": false, "github_user": "ettoreleandrotognoli", "github_project": "python-ami", "travis_ci": true, "coveralls": false, "github_actions": false, "requirements": [], "lcname": "asterisk-ami" }