from Hacker News

Show HN: Sultan – Pythonic interface to your shell

by aeroxis on 6/11/17, 7:27 PM with 53 comments

  • by rekwah on 6/12/17, 12:03 AM

    I wrote a pretty significant process wrapper in python at $PREVIOUS_JOB. The problem I have with these loose wrappers around subprocess is that they're, imho, solving the wrong problem. Or, maybe better put, not solving _enough_ of the problem.

    Imagine writing a wrapper for "grep". It may work in one environment, but if you need portability, you're going to quickly realize that there are nuances in implementation and the actual calling interface. Now you're handling branching logic in your application code based on platform, version, etc.

    Interfacing with a command line tool shouldn't be thought of much different than a remote HTTP/ReST API talking text/plain instead of application/json. You're looking for your "client wrapper" to handle argument validation, parsing, versioning, etc.

  • by hultner on 6/11/17, 8:00 PM

    Very nice! I've been using somewhat similar sh[1] for the same purpose. It's nice seeing more alternatives.

    [1]https://amoffat.github.io/sh/

  • by onyb on 6/11/17, 10:54 PM

    This seems to be a simple wrapper around subprocess, but I'm afraid it is not changing things dramatically. Overall, I don't agree that Sultan's syntax is any more Pythonic than subprocess itself.

    +1 for https://sultan.readthedocs.io/en/latest/sultan-examples.html...

    I think it would be interesting if you could iterate on the results of "ls -l", where each row is represented by an object.

  • by asdfgadsfgasfdg on 6/11/17, 10:03 PM

    How does

          s(command_from_potentially_unsafe_source).run()
    
    compare with

          os.system(command_from_potentially_unsafe_source)
    
    or

          subprocess.call(command_from_potentially_unsafe_source, shell=True)
    
    securitywise? I'm assuming all three are equally bad?
  • by Cynddl on 6/11/17, 8:33 PM

    There is also pyinfra [1], which provides the same sort of features for both local and remote devices, yet designed for consistent deployments and state diffing.

    [1] https://github.com/Fizzadar/pyinfra

  • by gerdesj on 6/11/17, 9:58 PM

    When I dabble with Python to get a job done, I invariably end up using subprocess at some stage and going through some contortions. I like the look of Sultan, it seems well thought out and has loads of well written docs.

    Anyone know how the name came about?

  • by Eridrus on 6/11/17, 10:31 PM

    Since we're throwing out random shell related tools, I found pexpect recently: https://pexpect.readthedocs.io/en/stable/api/replwrap.html

    Which was super useful for controlling some utilities that wanted to be run in an interactive bash shell.

  • by fermigier on 6/11/17, 9:50 PM

    I've been using 'tentakel' for remote server admin for years, 'fabric' for lightweight deployment, and more recently 'invoke' for local invocations (all are Python projects).

    This project looks interesting too, will give it a try.

    BTW: Has anyone news on Fabric 2 ?

  • by vram22 on 6/12/17, 2:44 PM

    Here's a comment I made some time ago on HN about similar / related Python libs / tools:

    https://news.ycombinator.com/item?id=8735892#8737512

    Edit: That comment was part of an HN thead about this topic, which might be interesting in its own right:

    Streem – a new programming language from Matz (github.com)

    https://news.ycombinator.com/item?id=8735892

  • by santiagobasulto on 6/11/17, 11:07 PM

    How's this different from sh or fabric?
  • by brett40324 on 6/11/17, 9:46 PM

    Ive written numerous python wrappers around shell commands for all sorts of one off utils, but this is nice and flexible and generic. Sultan looks well thought out. Open to contributors?
  • by llccbb on 6/11/17, 11:08 PM

    Seems like there is lots of talk here about how this is thin wrapper over `subprocess`, but I like the idea. What I don't like is that the logo looks like a penis with a mustache.
  • by jklehm on 6/12/17, 11:54 AM

    Seems similar to the package sh/pbs. [0]

    [0] https://amoffat.github.io/sh/

  • by rntksi on 6/12/17, 5:26 AM

    Trying very hard to ignore it, but to be honest... The logo looks like a smiling phallus.
  • by falsedan on 6/11/17, 9:16 PM

    Why not plumbum?

    (I know why not to use plumbum)

  • by singularity2001 on 6/12/17, 9:00 AM

    No example even if you click on FAQ … what is sultan.
  • by kvajjha on 6/12/17, 6:16 AM

    >Bash, while it seems arcaine, actually is quiet powerful!

    This line triggered me.

  • by pknerd on 6/12/17, 12:03 AM

    how is it different from Fabric?

    Nice stuff though

  • by fnj on 6/11/17, 8:37 PM

    Xonsh is how to do this.