GithubHelp home page GithubHelp logo

starpy's Introduction

StarPy Asterisk Protocols for Twisted

StarPy is a Python + Twisted protocol that provides access to the Asterisk PBX's Manager Interface (AMI) and Fast Asterisk Gateway Interface (FastAGI). Together these allow you write both command-and-control interfaces (used, for example to generate new calls) and to customise user interactions from the dialplan. You can readily write applications that use the AMI and FastAGI protocol together with any of the already available Twisted protocols.

StarPy is primarily intended to allow Twisted developers to add Asterisk connectivity to their Twisted applications. It isn't really targeted at the normal AGI-writing populace, as it requires understanding Twisted's asynchronous programming model. That said, if you do know Twisted, it can readily be used to write stand-alone FastAGIs.

StarPy is Open Source and we are interested in contributions, bug reports and feedback.

starpy's People

Contributors

brettbryant avatar coreyfarrell avatar dmchr avatar exvito avatar frmbelz avatar godsongera avatar itzangler avatar jcolp avatar leedm777 avatar matt-jordan avatar mcfletch avatar measterisk avatar mikelopez avatar opticron avatar pabelanger avatar roramirez avatar russellb avatar sgriepentrog avatar stevetodd avatar zookeeper avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

starpy's Issues

Update package on pypi.

The starpy package on pypi.python.org points to version 1.0.0a11 and to the sourceforge (very old version).

Can you upload the new versions or there are no contact with the owner of the package on pypi?

Exception AMICommandFailure with starpy dbGet when Database entry not found

Starpy 1.0.2 in asterisk-org-starpy-1.0.1-14-gdb7421d.zip.

I am using Asterisk 1.8 and python 2.6 on a "PBX in a Flash" 2.0.6.2 platform. Get an exception AMICommandFailure with starpy dbGet when AMI returns "Response: Error" with "Message: Database entry not found".

I have made some changes to the manager.py code. David Lee said I should file an issue against StarPy and include the diff.

As I told David... I'm not a developer, just a retired engineer with programing as a home hobby. I am not familiar with this git stuff. I don't want to mess up the library system. I am relatively new to python (less than 2yr) and very new to Asterisk.

This is the diff. I hope I didn't go overboard. I have created a method to register a deferred function for an Error response. I used it to return None for the dbGet when it gets an error response from the AMI.

I am open to have anyone make changes. I used the manager.py ub asterisk-org-starpy-1.0.1-14-gdb7421d.zip as the base for the diff.

34a35,43
> class deferredErrorResp(defer.Deferred):
>     """A subclass of defer.Deferred that adds a registerError method
>     to handle function callback when an Error response happens"""
>     _errorRespCallback = None
>     def registerError(self, function ):
>         """Add function for Error response callback"""
>         self._errorRespCallback = function
>         log.debug('Registering function %s to handle Error response'
>                   % (function))
286c295
<         df = defer.Deferred()

---
>         df = deferredErrorResp()
289,290c298,299
<             self.cleanup, self.cleanup,
<             callbackArgs=(actionid,), errbackArgs=(actionid,)

---
>             self.checkErrorResponse, self.cleanup,
>             callbackArgs=(actionid, df,), errbackArgs=(actionid,)
293a303,309
>     def checkErrorResponse(self, result, actionid, df):
>         """Check for error response and callback"""
>         self.cleanup( result, actionid)
>         if result.get('response') == 'Error' and df._errorRespCallback:
>             df._errorRespCallback(result)
>         return result
> 
431d446
< 
433a449
>             self.deregisterEvent("DBGetResponse", extractValue)
435c451,453
< 

---
>         def errorResponse( message ):
>             self.deregisterEvent("DBGetResponse", extractValue)
>             return df.callback(None)
441c459
<         self.sendDeferred(message).addCallback(self.errorUnlessResponse)

---
>         self.sendDeferred(message).registerError(errorResponse)

Error with send command "show queues"

When send command "queue show", receive the error:

2014-02-25 00:03:50-0300 [AMIProtocol,client] Unhandled error in Deferred:
2014-02-25 00:03:50-0300 [AMIProtocol,client] Unhandled Error
    Traceback (most recent call last):
      File "/usr/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 277, in connectionLost
        protocol.connectionLost(reason)
      File "/project/test/bin/starpy/manager.py", line 197, in connectionLost
        "FastAGI connection terminated"))
      File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 368, in callback
        self._startRunCallbacks(result)
      File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 464, in _startRunCallbacks
        self._runCallbacks()
    --- <exception caught here> ---
      File "/usr/lib/python2.7/dist-packages/twisted/internet/defer.py", line 551, in _runCallbacks
        current.result = callback(current.result, *args, **kw)
      File "/project/test/bin/starpy/manager.py", line 405, in onResult
        return message[' ']
    exceptions.TypeError: sequence index must be integer, not 'str'

TypeError on Python3.6.x in FastAGI.

Hi,

When I have run the FastAGI script with python 3.6.8, I have gotten the following error:

image

I think, I found a solution to fix it. How can i contribute to fix the error?

Need the ability to disable reconnect

I can understand the desire for automatic reconnect for many uses of starpy but for the testsuite I think it's undesirable. In at least one case of the Asterisk testsuite (tests/manager/acl-login) the automatic reconnect causes ao2 references to be leaked at shutdown.

See pull request #35.

Connection randomly closes itself

Hi,

I have an application which uses the newest version of starpy and works well for most of the time on most machines it is being used, but randomly stops on some of them.

What happens: The factory stops itself ( Stopping factory <starpy.manager.AMIFactory instance at 0x1dd6998> ) and an error is thrown.
The error given is: " sequence index must be integer, not 'str' ", which doens't seem to be anything with my code.
Sometimes this error is preceded by the following error:

File "/usr/lib64/python2.6/logging/init.py", line 797, in emit
[AMIProtocol,client] stream.write(fs % msg)
[AMIProtocol,client] IOError: [Errno 5] Input/output error

The code randomly throws an error in one of the two following partial codes:
Notes: I'm using the " @defer.inlineCallbacks " decorator and the variable client contains the connection.

try:
dndExtensions = []
dnd = yield client.command ( 'database show DND' )
for extension in dnd:
if 'DND' in extension:
dndExtensions.append ( extension.split ( '/DND/' )[1].split (' ')[0] )
except Exception, e:
# error ...

try:
lunchExtensions = []
lunch = yield client.command ( 'database show Lunch' )
for extension in lunch:
if 'Lunch' in extension:
lunchExtensions.append ( extension.split ( '/Lunch/' )[1].split (' ')[0] )
except Exception, e:
# error ...

Any idea of what might be happening?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.