Python + bash
Если вам часто требуется запускать shell команды из Python-кода, какой способ вы используете?
Самый низкоуровневый это функция os.system(), либо os.popen(). Рекомендованный способ это subprocess.call(). Но это всё еще достаточно неудобно.
Советую обратить своё внимание на очень крутую библиотеку sh.
Что она умеет?
🔸 удобный синтаксис вызова команд как функций
# os
import os
os.system("tar cvf demo.tar ~/")
# subprocess
import subprocess
subprocess.call(['tar', 'cvf', 'demo.tar', '~/'])
# sh
import sh
sh.tar('cvf', 'demo.tar', "~/")
🔸 простое создание функции-алиаса для длинной команды
fn = sh.lsof.bake('-i', '-P', '-n')
output = sh.grep(fn(), 'LISTEN')
в этом примере также задействован пайпинг
🔸 удобный вызов команд от sudo
with sh.contrib.sudo:
print(ls("/root"))
Такой запрос спросит пароль. Чтобы это работало нужно соответствующим способом настроить юзера.
А вот вариант с вводом пароля через код.
password = "secret"
sudo = sh.sudo.bake("-S", _in=password+"\n")
print(sudo.ls("/root"))
Это не все фишки. Больше интересных примеров смотрите в документации.
Специально для Windows💀 юзеров
#libs#linux
Just In: World Liberty Finance ( @worldlibertyfi ) sent 500M $WLFI worth $83.12M to #Jump Trading.
Data - @Nansen_ai
https://x.com/OnchainLens/status/2010748644979577089
Follow @onchainlens for more onchain updates
Shoutout to the early donators 🚀💥 You’re our real VIPs for jumping in first and supporting the new ETH memecoin season! 🙌💰
The more you #JUMP into $JUMP, the closer we get to make ETH great again 🌕🚀
Let’s f***ing jump and save Ethereum together!
Whales are starting to #JUMP into our donation 🐳🐳
A 70 #ETH donation just came in! It came from a very old and large wallet holding over 2500 ETH, the #MEGA movement is getting stronger by the day. Join the movement and make memes on Ethereum great again!
https://etherscan.io/tx/0x25b8397cda09027cc3bcc86ff2abf58fa2dc07022204dd8161a7b2630e658b7d
🚀 The wait is over - $JUMP is live! 🚀
Donate now and secure your stake in Jump.fun, the next-generation memecoin launchpad:
🔥 Liquidity War Mode (loot liquidity, win big!)
💰 FREE 6 ETH liquidity loan on Uniswap
⚡️ Community-ownership via $JUMP token
#jumpfun is the key to bring back memecoin FOMO and fun to the Ethereum ecosystem. #MEGA
🌕 Don’t just watch - #jump high, moon higher!
Crypto Summit Guest List Revealed
Notable figures like Kayne West and the Lazarus Group are invited to a major crypto summit. In related news, Mexican billionaire Ricardo Salinas has raised his Bitcoin holdings to 70%, moving away from gold investments. Meanwhile, Jump is resuming its U.S. crypto operations, boosting hiring amid rising trading volumes.
#Crypto#Bitcoin#Summit#Finance#Investing#Market#Jump#Arbitrum#LazarusGroup#Salinas