Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • scs/ipaaca
  • ramin.yaghoubzadeh/ipaaca
2 results
Show changes
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# "Incremental Processing Architecture # "Incremental Processing Architecture
# for Artificial Conversational Agents". # for Artificial Conversational Agents".
# #
# Copyright (c) 2009-2013 Sociable Agents Group # Copyright (c) 2009-2022 Sociable Agents Group
# CITEC, Bielefeld University # CITEC, Bielefeld University
# #
# http://opensource.cit-ec.de/projects/ipaaca/ # http://opensource.cit-ec.de/projects/ipaaca/
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# "Incremental Processing Architecture # "Incremental Processing Architecture
# for Artificial Conversational Agents". # for Artificial Conversational Agents".
# #
# Copyright (c) 2009-2013 Sociable Agents Group # Copyright (c) 2009-2022 Sociable Agents Group
# CITEC, Bielefeld University # CITEC, Bielefeld University
# #
# http://opensource.cit-ec.de/projects/ipaaca/ # http://opensource.cit-ec.de/projects/ipaaca/
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# "Incremental Processing Architecture # "Incremental Processing Architecture
# for Artificial Conversational Agents". # for Artificial Conversational Agents".
# #
# Copyright (c) 2009-2013 Sociable Agents Group # Copyright (c) 2009-2022 Sociable Agents Group
# CITEC, Bielefeld University # CITEC, Bielefeld University
# #
# http://opensource.cit-ec.de/projects/ipaaca/ # http://opensource.cit-ec.de/projects/ipaaca/
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
# Forschungsgemeinschaft (DFG) in the context of the German # Forschungsgemeinschaft (DFG) in the context of the German
# Excellence Initiative. # Excellence Initiative.
from __future__ import division, print_function #from __future__ import division, print_function
import itertools import itertools
import os import os
...@@ -44,7 +44,7 @@ import ipaaca ...@@ -44,7 +44,7 @@ import ipaaca
def iu_update_handler(iu, event_type, local): def iu_update_handler(iu, event_type, local):
try: try:
print(event_type + ': ' + unicode(iu)) print(event_type + ': ' + str(iu))
except: except:
print(u"An error occurred printing an IU for an event of type "+event_type) print(u"An error occurred printing an IU for an event of type "+event_type)
...@@ -86,14 +86,16 @@ parser.add_argument( ...@@ -86,14 +86,16 @@ parser.add_argument(
if __name__ == '__main__': if __name__ == '__main__':
arguments = parser.parse_args() arguments = parser.parse_args()
print('BackEnd is '+str(ipaaca.backend.get_default_backend().name))
ob = ipaaca.OutputBuffer('IpaacaIUInjector') ob = ipaaca.OutputBuffer('IpaacaIUInjector')
ob.register_handler(iu_update_handler) ob.register_handler(iu_update_handler)
iu = ipaaca.Message(arguments.category) if arguments.iu_type == 'Message' else ipaaca.IU(arguments.category) iu = ipaaca.Message(arguments.category) if arguments.iu_type == 'Message' else ipaaca.IU(arguments.category)
if arguments.json_payload: if arguments.json_payload:
# Treat payload values as Python expressions # Treat payload values as Python expressions
iu.payload = {k: eval(v) for (k, v) in itertools.izip_longest(arguments.payload[::2], arguments.payload[1::2])} iu.payload = {k: eval(v) for (k, v) in itertools.zip_longest(arguments.payload[::2], arguments.payload[1::2])}
else: else:
iu.payload = {k: v for (k, v) in itertools.izip_longest(arguments.payload[::2], arguments.payload[1::2])} iu.payload = {k: v for (k, v) in itertools.zip_longest(arguments.payload[::2], arguments.payload[1::2])}
ob.add(iu) ob.add(iu)
print( print(
...@@ -112,7 +114,7 @@ if __name__ == '__main__': ...@@ -112,7 +114,7 @@ if __name__ == '__main__':
time.sleep(0.1) time.sleep(0.1)
except KeyboardInterrupt: except KeyboardInterrupt:
pass pass
except Exception, e: except Exception as e:
print(u'Exception: '+unicode(traceback.format_exc())) print(u'Exception: '+str(traceback.format_exc()))
ipaaca.exit(1) ipaaca.exit(1)
ipaaca.exit(0) ipaaca.exit(0)
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
# Forschungsgemeinschaft (DFG) in the context of the German # Forschungsgemeinschaft (DFG) in the context of the German
# Excellence Initiative. # Excellence Initiative.
from __future__ import division, print_function #from __future__ import division, print_function
import logging import logging
import os import os
...@@ -51,7 +51,7 @@ def event_type_color(typ): ...@@ -51,7 +51,7 @@ def event_type_color(typ):
'MESSAGE': '34;1', 'MESSAGE': '34;1',
'COMMITTED': '35;1', 'COMMITTED': '35;1',
'LINKSUPDATED': '36;1', 'LINKSUPDATED': '36;1',
'RETRACTED': '37;1', 'RETRACTED': '37',
} }
return colors.get(typ, '1') return colors.get(typ, '1')
...@@ -61,13 +61,13 @@ def highlight_if_color(s, c='1'): ...@@ -61,13 +61,13 @@ def highlight_if_color(s, c='1'):
def pretty_printed_dict(d): def pretty_printed_dict(d):
s='{\n' s='{\n'
for k, v in d.items(): for k, v in d.items():
if isinstance(v, unicode) or isinstance(v, str): if isinstance(v, str) or isinstance(v, str):
v = "'"+unicode(v)+"'" v = "'"+str(v)+"'"
else: else:
v = unicode(v) v = str(v)
v2 = v if len(v) <= arguments.max_size else v[:arguments.max_size] + '<excess length omitted>' v2 = v if len(v) <= arguments.max_size else v[:arguments.max_size] + '<excess length omitted>'
v2.replace('\\','\\\\').replace('\n', highlight_if_color('\\n')) v2.replace('\\','\\\\').replace('\n', highlight_if_color('\\n'))
s += "\t '%s': %s,\n" % (highlight_if_color(unicode(k),'1'), unicode(v2)) s += "\t '%s': %s,\n" % (highlight_if_color(str(k),'1'), str(v2))
s+='}' s+='}'
return s return s
...@@ -148,11 +148,24 @@ if __name__ == '__main__': ...@@ -148,11 +148,24 @@ if __name__ == '__main__':
arguments = parser.parse_args() arguments = parser.parse_args()
buffers = {} buffers = {}
backend_name = str(ipaaca.backend.get_default_backend().name)
print('BackEnd is '+backend_name)
universal_listener_category = ''
if backend_name == 'mqtt':
universal_listener_category = '#'
if arguments.categories == ['']: arguments.categories = ['#']
elif backend_name == 'ros':
if arguments.categories == [''] or arguments.regex:
print('ATTENTION: listening to all categories not implemented for ROS back-end!')
print(' (By extension, the same goes for filtering all categories by regex.)')
print(' !! You will receive nothing, please provide fixed category names. !!')
# Create one input buffer for each channel we are listening on # Create one input buffer for each channel we are listening on
for channel in arguments.channels: for channel in arguments.channels:
buffers[channel] = ipaaca.InputBuffer( buffers[channel] = ipaaca.InputBuffer(
'IpaacaIUSniffer', 'IpaacaIUSniffer',
category_interests=arguments.categories if not arguments.regex else [''], category_interests=arguments.categories if not arguments.regex else [universal_listener_category],
channel=channel, channel=channel,
resend_active=True) resend_active=True)
# Check whether the specified event_types are valid # Check whether the specified event_types are valid
...@@ -174,7 +187,7 @@ if __name__ == '__main__': ...@@ -174,7 +187,7 @@ if __name__ == '__main__':
else: else:
print(', '.join([highlight_if_color(et.upper(), event_type_color(et.upper())) for et in arguments.event_types])) print(', '.join([highlight_if_color(et.upper(), event_type_color(et.upper())) for et in arguments.event_types]))
print(' * for category/ies', end='') print(' * for category/ies', end='')
if arguments.categories == ['']: if arguments.categories == [universal_listener_category]:
print(': any') print(': any')
else: else:
if arguments.regex: if arguments.regex:
...@@ -187,7 +200,7 @@ if __name__ == '__main__': ...@@ -187,7 +200,7 @@ if __name__ == '__main__':
time.sleep(1) time.sleep(1)
except KeyboardInterrupt: except KeyboardInterrupt:
pass pass
except Exception, e: except Exception as e:
print(u'Exception: '+unicode(traceback.format_exc())) print(u'Exception: '+str(traceback.format_exc()))
ipaaca.exit(1) ipaaca.exit(1)
ipaaca.exit(0) ipaaca.exit(0)