Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement special channels (NIL, VOID) #6

Open
mschatten opened this issue Mar 30, 2021 · 0 comments
Open

Implement special channels (NIL, VOID) #6

mschatten opened this issue Mar 30, 2021 · 0 comments

Comments

@mschatten
Copy link
Member

Most TODO's are already implemented (channel subscription). What needs to be done is to implement NIL channel (needs to be connected to agent's stopping behaviour) and void channel (sending output to /dev/null)

APi/agent.py

Lines 242 to 288 in e1208c0

def subscribe_to_channel( self, channel, channel_type ):
# TODO: Implement channel subscription (sender, receiver)
# Channel types:
# NIL -> sends stop to agent (0 process)
# VOID -> sends output to /dev/null
# STDIN -> reads input from stdin
# STDOUT/STDERR -> writes output to STDIN/STDERR
# <name> -> gets instructions from channel on how
# to connect (via Netcat)
if channel_type == 'input':
if channel == 'NIL':
err = 'Input cannot be 0 (NIL)'
raise APiChannelDefinitionError( err )
elif channel == 'VOID':
err = 'Input cannot be VOID'
raise APiChannelDefinitionError( err )
elif channel == 'STDOUT':
err = 'Input cannot be STDOUT'
raise APiChannelDefinitionError( err )
elif channel == 'STDERR':
err = 'Input cannot be STDERR'
raise APiChannelDefinitionError( err )
elif channel == 'STDIN':
self.start_shell_client( prompt=True, await_stdin=True )
else:
self.say( 'Adding input channel', channel )
self.input_channel_query_buffer.append( channel )
elif channel_type == 'output':
if channel == 'NIL':
# TODO: stop agent
raise NotImplementedError( NIE )
elif channel == 'VOID':
# TODO: send to /dev/null (i.e. do nothing )
raise NotImplementedError( NIE )
elif channel == 'STDOUT':
self.start_shell_client( print_stdout=True )
elif channel == 'STDERR':
self.start_shell_client( print_stderr=False )
elif channel == 'STDIN':
err = 'Output cannot be STDIN'
raise APiChannelDefinitionError( err )
else:
# TODO: send message to channel agent
# and get instructions on how to
# connect
self.say( 'Adding output channel', channel )
self.output_channel_query_buffer.append( channel )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant