TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: Sultan – Pythonic interface to your shell

155 点作者 aeroxis将近 8 年前

19 条评论

rekwah将近 8 年前
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&#x27;re, imho, solving the wrong problem. Or, maybe better put, not solving _enough_ of the problem.<p>Imagine writing a wrapper for &quot;grep&quot;. It may work in one environment, but if you need portability, you&#x27;re going to quickly realize that there are nuances in implementation and the actual calling interface. Now you&#x27;re handling branching logic in your application code based on platform, version, etc.<p>Interfacing with a command line tool shouldn&#x27;t be thought of much different than a remote HTTP&#x2F;ReST API talking text&#x2F;plain instead of application&#x2F;json. You&#x27;re looking for your &quot;client wrapper&quot; to handle argument validation, parsing, versioning, etc.
评论 #14536423 未加载
评论 #14536843 未加载
hultner将近 8 年前
Very nice! I&#x27;ve been using somewhat similar <i>sh</i>[1] for the same purpose. It&#x27;s nice seeing more alternatives.<p>[1]<a href="https:&#x2F;&#x2F;amoffat.github.io&#x2F;sh&#x2F;" rel="nofollow">https:&#x2F;&#x2F;amoffat.github.io&#x2F;sh&#x2F;</a>
评论 #14535451 未加载
onyb将近 8 年前
This seems to be a simple wrapper around subprocess, but I&#x27;m afraid it is not changing things dramatically. Overall, I don&#x27;t agree that Sultan&#x27;s syntax is any more Pythonic than subprocess itself.<p>+1 for <a href="https:&#x2F;&#x2F;sultan.readthedocs.io&#x2F;en&#x2F;latest&#x2F;sultan-examples.html#example-5-redirecting-output-to-file" rel="nofollow">https:&#x2F;&#x2F;sultan.readthedocs.io&#x2F;en&#x2F;latest&#x2F;sultan-examples.html...</a><p>I think it would be interesting if you could iterate on the results of &quot;ls -l&quot;, where each row is represented by an object.
评论 #14536866 未加载
评论 #14535403 未加载
asdfgadsfgasfdg将近 8 年前
How does<p><pre><code> s(command_from_potentially_unsafe_source).run() </code></pre> compare with<p><pre><code> os.system(command_from_potentially_unsafe_source) </code></pre> or<p><pre><code> subprocess.call(command_from_potentially_unsafe_source, shell=True) </code></pre> securitywise? I&#x27;m assuming all three are equally bad?
评论 #14534072 未加载
Cynddl将近 8 年前
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.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;Fizzadar&#x2F;pyinfra" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Fizzadar&#x2F;pyinfra</a>
gerdesj将近 8 年前
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.<p>Anyone know how the name came about?
评论 #14536925 未加载
评论 #14534794 未加载
Eridrus将近 8 年前
Since we&#x27;re throwing out random shell related tools, I found pexpect recently: <a href="https:&#x2F;&#x2F;pexpect.readthedocs.io&#x2F;en&#x2F;stable&#x2F;api&#x2F;replwrap.html" rel="nofollow">https:&#x2F;&#x2F;pexpect.readthedocs.io&#x2F;en&#x2F;stable&#x2F;api&#x2F;replwrap.html</a><p>Which was super useful for controlling some utilities that wanted to be run in an interactive bash shell.
fermigier将近 8 年前
I&#x27;ve been using &#x27;tentakel&#x27; for remote server admin for years, &#x27;fabric&#x27; for lightweight deployment, and more recently &#x27;invoke&#x27; for local invocations (all are Python projects).<p>This project looks interesting too, will give it a try.<p>BTW: Has anyone news on Fabric 2 ?
评论 #14534034 未加载
vram22将近 8 年前
Here&#x27;s a comment I made some time ago on HN about similar &#x2F; related Python libs &#x2F; tools:<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=8735892#8737512" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=8735892#8737512</a><p>Edit: That comment was part of an HN thead about this topic, which might be interesting in its own right:<p>Streem – a new programming language from Matz (github.com)<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=8735892" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=8735892</a>
santiagobasulto将近 8 年前
How&#x27;s this different from sh or fabric?
brett40324将近 8 年前
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?
评论 #14536943 未加载
llccbb将近 8 年前
Seems like there is lots of talk here about how this is thin wrapper over `subprocess`, but I like the idea. What I don&#x27;t like is that the logo looks like a penis with a mustache.
评论 #14534419 未加载
评论 #14534397 未加载
jklehm将近 8 年前
Seems similar to the package sh&#x2F;pbs. [0]<p>[0] <a href="https:&#x2F;&#x2F;amoffat.github.io&#x2F;sh&#x2F;" rel="nofollow">https:&#x2F;&#x2F;amoffat.github.io&#x2F;sh&#x2F;</a>
评论 #14536663 未加载
rntksi将近 8 年前
Trying very hard to ignore it, but to be honest... The logo looks like a smiling phallus.
falsedan将近 8 年前
Why not plumbum?<p>(I know why not to use plumbum)
评论 #14533958 未加载
singularity2001将近 8 年前
No example even if you click on FAQ … what is sultan.
评论 #14536093 未加载
kvajjha将近 8 年前
&gt;Bash, while it seems arcaine, actually is quiet powerful!<p>This line triggered me.
评论 #14536956 未加载
pknerd将近 8 年前
how is it different from <i>Fabric</i>?<p>Nice stuff though
评论 #14536626 未加载
fnj将近 8 年前
Xonsh is how to do this.
评论 #14533837 未加载