Giter Site home page Giter Site logo

Comments (9)

takluyver avatar takluyver commented on September 26, 2024

Good point. Is there anything particularly egregious that you want to clear up before 3.0, or would you rather have a concerted push afterwards?

from pexpect.

jquast avatar jquast commented on September 26, 2024

It would be trivial for this release to:

  1. remove all but the "keepers"
  2. pep8 and cleanup the remaining 3.

If you're ok with that, then I could submit a pull for this within a few hours, close this issue, and make a new one "Provide better example scripts for pexpect" that we can table for a later next release.

from pexpect.

takluyver avatar takluyver commented on September 26, 2024

I'm not entirely comfortable with removing all but three of the examples - even if the rest are ugly, and there are better ways to do them, they might be useful to show what pexpect is capable of. I'd be inclined to leave the big deletion until later, when it can be more of a big replacement.

from pexpect.

myint avatar myint commented on September 26, 2024

I agree with @jquast. The examples are an ugly mess. It is a lot easier to learn from a concise and correct example than to try to digest and sift through pages of junk.

from pexpect.

takluyver avatar takluyver commented on September 26, 2024

OK, with the release out, it's time to clean up the examples.

I broadly agree with you about the current examples, most of them are pretty crufty, and many probably don't even work. However, I think it's worth keeping some short examples, even if they implement things that are better done with another tool - they're examples, not real programs.

My verdict so far:

  • astat: keep and clean - it's a decent example of using pxssh.
  • bd_client/bd_serv: lose it - the use of pexpect is hidden by a load of socket stuff anyway
  • cgishell: don't list it (we already don't), but leave it around, as it's actually quite clear, and I'm loath to throw that much work away.
  • chess*: condense to one and make sure it works
  • df: see uptime
  • fix_cvs_files: lose it, most of us aren't familiar with CVS now anyway
  • ftp: keep/replace - simple example of using pexpect to control an interactive process
  • hive: unsure - it looks useful as a script, but too complex to be a decent example. Hard to run quickly to experiment with.
  • monitor: keep/condense with astat. Should be using pxssh
  • passmass: keep, convert to pxssh
  • python: keep+improve - very simple, uses something every user is familiar with, and the >>> prompt is instantly recognisable. But it should do more with interactivity, not just print out messages.
  • rippy: lose it - way too complex to be an example, and Noah made it a separate project on Sourceforge anyway.
  • script: keep - good demo of interact
  • ssh_session: lose it - not a great demo.
  • ssh_tunnel: keep/replace - simple example of expect with multiple alternatives
  • sshls: lose it - we have better examples of using pxssh
  • topip: replace with a simpler example of using regexes in expect (uptime?)
  • uptime: keep/replace - this is simple, but can we find a better example with regexes that can't trivially be done with subprocess?

I'd also like a decent example of using the run() function with expect patterns and responses passed in as a dictionary.

Many of the examples also call main() with a superfluous try except to catch any errors and print a traceback. That's Python's default behaviour, although perhaps it wasn't when these were written, so we can clean that up.

How does that sound?

from pexpect.

takluyver avatar takluyver commented on September 26, 2024

Oh, and I'd like an example of controlling a curses or similar program that uses the terminal as a window. The chess examples claim to, but in my brief play with gnuchess, it looks like a standard command line program. I suspect that when the examples were written, gnuchess included a curses interface, but that has since been dropped in favour of providing a backend for more advanced chess UIs.

from pexpect.

takluyver avatar takluyver commented on September 26, 2024

I've started cleaning this up with PR #26.

from pexpect.

jquast avatar jquast commented on September 26, 2024

Its unfortunate that there aren't any well-known curses or interactive programs to be found across platforms, even just a basic linux installation is pretty uninteresting.

I'm thinking up a few ideas,:

  • telnet to rainmaker.wunderground.com, i wrote a simple shell script for this: https://gist.github.com/jquast/5873193 to show a friend how netcat could be scripted -- this host has lasted over the decade in the same form, maybe it will continue into the next; seeking specific prompts and replies, with the result of printing weather data for a target airport code, or displaying available airport codes for a given state prefix.
  • bsdgames: these classics are known by almost all admins, sortof like the minesweeper of unix -- the game "quiz multiplication answer" or "arithmetic" is an awesome example -- parse out the question "3 x 7 ?", split up the operands and values, do the math, and push the answer, expecting the "correct!" response.
  • nethack: character roll -- restart nethack over and over until a character was generated with the desired inventory items and minimum attributes. nethack is very portable/can be found in package managers across many platforms and hardly ever changes
  • gnuchess - i like the idea of pitting two processes against each other, I'd like to see this code brought up to date and work. If I recall you can specify a difficulty level, so it would be interesting to pit a "smart" vs "dumb" as quick as possible and show an output "x wins in z moves" for each game.

from pexpect.

jquast avatar jquast commented on September 26, 2024

This is my issue, I consider our purging complete -- any additional examples are trailed here.

Specific program automation is difficult to provide as portable.

There are actually quite a few lessons to learn within the test cases, and I think these are more important to find a way to share in sphinx documentation, instead.

Any comprehensive, well-documented examples are always welcome, anyway.

from pexpect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.