/usr/lib/python2.7/dist-packages/examples/amicommand.py is in python-starpy 1.0.1.0.git.20140806-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #! /usr/bin/env python
"""Test/sample to call "show database" command
"""
from twisted.application import service, internet
from twisted.internet import reactor, defer
from starpy import manager, fastagi
import utilapplication
import menu
import os, logging, pprint, time
log = logging.getLogger( 'callduration' )
APPLICATION = utilapplication.UtilApplication()
def main():
def onConnect( ami ):
def onResult( result ):
print 'Result', result
return ami.logoff()
def onError( reason ):
print reason.getTraceback()
return reason
def onFinished( result ):
reactor.stop()
df = ami.command( 'database show' )
df.addCallbacks( onResult, onError )
df.addCallbacks( onFinished, onFinished )
return df
amiDF = APPLICATION.amiSpecifier.login(
).addCallback( onConnect )
if __name__ == "__main__":
logging.basicConfig()
manager.log.setLevel( logging.DEBUG )
reactor.callWhenRunning( main )
reactor.run()
|