Skip to main content

Input data

At this step you have your first agent. For the sake of simplicity, we have chosen not to provide the input to the agent (or maybe he doesn't need it).

We will now provide the input param (file by default) to the agent.

important

The page Modify Captain's input outlines the steps to change the input.
For example, if you want to use -u <username> or -w <website>, or even remove the need of any input for your project.


For this example, i'm taking back our previously created Agent my-parser.

agents/my-parser.py
from ..base import Base, logger

class MyParserAgent(Base):
NAME = "MyParser"
ACTIVATED = True
VERSION = "1.0"
MISSION = "Yet another parser to parse"
FILE = None # New property

def __init__(self, file): # New function
self.FILE = file # New property

def mission(self):
logger.info(f'[{self.NAME}] Checking in.')

if self.file: # Agent can now access the argument (file)
with open(file, "rb") as f: # And process it ...
...
logger.info(f'[{self.NAME}] Parsing file')
return <your-output>