def setUp(self): self.ajam = Pyajam(server=self.server, username=self.user, password=self.pwd) if self.login: self.ajam.login()
def setUp(self): self.ajam = Pyajam() self.ajam._query = fake_query(self.path, self._testMethodName.split('_')[1]) # we *force* asterisk version in ajam (note if we run *test_login*, will be replaced by real version) self.ajam._version_ = self.version
def asterisk_command(self, command): self.ensure_one() if self.no_asterisk_mode(): return ajam = Pyajam(server=self.host, username=self.ami_username, password=self.ami_password, port=self.http_port, path='') # Do not set prefix if not ajam.login(): raise UserError('Asterisk AMI login error!') response = ajam.command(command)
def ajax_mesa(): import pprint from pyajam import Pyajam ajam = Pyajam(username='******', password='******') con = ajam.peers() dict_final = {} ramal = db(Ramal_virtual).select(Ramal_virtual.ramal_virtual, Ramal_virtual.ramal_fisico) print ramal for dado in con: for rm in ramal: if rm.ramal_fisico == dado['objectname']: print dado['objectname'] dict_final[rm.ramal_virtual] = dado return response.json(dict_final)
def test_ajam_unify_xml(self): input = '''<ajax-response> <response type='object' id='unknown'><generic response='Success' message='Waiting for Event...' /></response> <response type='object' id='unknown'><generic event='PeerStatus' privilege='system,all' peer='SIP/601' peerstatus='Registered' /></response> <response type='object' id='unknown'><generic event='WaitEventComplete' /></response> </ajax-response> ''' expected = [{ 'peer': 'SIP/601', 'peerstatus': 'Registered', 'event': 'PeerStatus', 'privilege': 'system,all' }, { 'event': 'WaitEventComplete' }] ajam = Pyajam() #raise SkipTest assert_equal(expected, ajam._unify_xml(input))