Skip to content
Snippets Groups Projects
Commit 86c74294 authored by ptangu01's avatar ptangu01
Browse files

refactoring method name and variabls to fit with changement in xAAL stack for PEP8 support

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/trunk@1364 b32b6428-25c9-4566-ad07-03861ab6144f
parent 8de167a5
No related branches found
No related tags found
No related merge requests found
......@@ -21,13 +21,13 @@ import xAAL
class Dumper(xAAL.core.Engine):
def processRxMsg(self,msg):
def main_handler(self,msg):
msg.dump()
xAAL.core.Engine.processRxMsg(self,msg)
xAAL.core.Engine.main_handler(self,msg)
if __name__ == '__main__':
logger = xAAL.tools.getLogger(__name__,'DEBUG')
logger = xAAL.tools.get_logger(__name__,'DEBUG')
logger.info('Starting THE dumper')
dumper = Dumper()
dumper.run()
......@@ -2,47 +2,33 @@
# -*- coding: utf-8 -*-
#
# Copyright 2014 Jerome Kerdreux, Telecom Bretagne.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
"""
Examples:
python send.py 2018374a-351c-11e4-9812-5c260a20f3b0 isAlive devTypes any.any
"""
from __future__ import print_function
MIXER_PADDING = 10
from xAAL.core import Engine
from xAAL.message import Message,MessageFactoryParserError,buildTimestamp
import ujson as json
import sys
from xAAL.core import Engine
from xAAL.message import Message, MessageFactoryParserError, build_timestamp
from xAAL import tools
from xAAL import config
def main():
uuid = tools.getRandomUUID()
uuid = tools.get_random_uuid()
print("My Temp UUID is : %s" % uuid)
targets = sys.argv[1]
......@@ -56,48 +42,43 @@ def main():
else:
targets = [targets]
msg.setTargets(targets)
msg.setDevtype('cli.experimental')
msg.setMsgtype('request')
msg.setAction(sys.argv[2])
msg.set_targets(targets)
msg.set_devtype('cli.experimental')
msg.set_msgtype('request')
msg.set_action(sys.argv[2])
if len(sys.argv) > 3:
targets = [targets]
key = sys.argv[3]
value = sys.argv[4]
body = {key: value}
msg.setBody(body)
msg.setSource(uuid)
msg.setTimestamp(buildTimestamp())
msg.set_body(body)
msg.set_source(uuid)
msg.set_timestamp(build_timestamp())
data = app.getMessageFactory().encodeMSG(msg)
data = app.get_message_factory().encode_msg(msg)
app.send_msg(data)
app.sendMSG(data)
filterADDR = [config.XAAL_BCAST_ADDR,uuid]
timeout = 0
msgCnt = 0
msgcnt = 0
while 1:
data = app.getNetworkConnector().getData()
data = app.get_network_connector().get_data()
if data:
try:
msg = app.getMessageFactory().decodeMSG(data)
msg = app.get_message_factory().decode_msg(data)
except MessageFactoryParserError as e:
print(e.message)
if msg.getSource() in targets:
if msg.getAction() != 'alive':
if msg.get_source() in targets:
if msg.get_action() != 'alive':
msg.dump()
msgCnt +=1
msgcnt += 1
timeout += 1
if (msgCnt >0) and (timeout > 10):
if (msgcnt > 0) and (timeout > 10):
break
if timeout > 30:
print("No answer .. timeout")
break
if __name__ == '__main__':
try:
main()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment