carlmontanari / scrapli

Fast, flexible, sync/async, Python 3.7+ screen scraping client specifically for network devices
https://carlmontanari.github.io/scrapli/
MIT License
575 stars 59 forks source link

`read_callback` parameters not used if given `initial_input` #304

Closed MattCatz closed 11 months ago

MattCatz commented 11 months ago

https://github.com/carlmontanari/scrapli/blob/d0eb38b56320acd054c5efc0455d3dde8e4011c5/scrapli/driver/generic/sync_driver.py#L534C32-L534C32

If read_callback is given an initial_input, then read_callback does a write and recursively calls itself. Only the callback parameter is passed to that recursive call, preventing any other parameter from having an effect.

carlmontanari commented 11 months ago

hmm yeah you just mean the delay/timeout args? or am I missing something else too :D

pr would be most welcome if you're up for it! (just plz do sync and async)

MattCatz commented 11 months ago

hmm yeah you just mean the delay/timeout args? or am I missing something else too :D

pr would be most welcome if you're up for it! (just plz do sync and async)

Yeah read_output, read_delay and read_timeout.

I can make a PR. I assume something simple like below would work for both? (I haven't looked at async)

        if initial_input is not None:
            self.channel.write(channel_input=f"{initial_input}{self.comms_return_char}")
            return self.read_callback(callbacks=callbacks, read_output=read_output, read_delay=read_delay, read_timeout=read_timeout, initial_input=None)
carlmontanari commented 11 months ago

yep, that looks good to me! much appreciated! if ya dont wanna/dont get to it I can sort it out this weekend prolly too!

thanks for raising it @MattCatz 🥳

carlmontanari commented 11 months ago

sorted thanks to @MattCatz !