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
📩#ZROUSDT 30m | Mid-Term
📈Short Entry Zone: 2.2664-2.3691
🎯 - Strategy Accuracy: 92.26%
Last 5 signals: 80.0%
Last 10 signals: 85.0%
Last 20 signals: 87.18%
⏳ - Signal details:
Target 1: 2.2358
Target 2: 2.2052
Target 3: 2.1746
Target 4: 2.0828
_____
🧲Trend-Line: 2.3691
❌Stop-Loss: 2.4010
💡After reaching the first target you can put the rest of the position to breakeven
📩#ZROUSDT 30m | Mid-Term
📈Short Entry Zone: 2.1676-2.3075
🎯 - Strategy Accuracy: 93.28%
Last 5 signals: 87.5%
Last 10 signals: 92.31%
Last 20 signals: 86.96%
⏳ - Signal details:
Target 1: 2.1264
Target 2: 2.0851
Target 3: 2.0439
Target 4: 1.9202
_____
🧲Trend-Line: 2.3075
❌Stop-Loss: 2.3514
💡After reaching the first target you can put the rest of the position to breakeven
#ZROUSDT has achieved 9th TP in 8 hours in our VIP PRO channel!
Using a 5% entry you could've earned $619 with a $1000 deposit
ACCESS TO MANUAL TRADING for 70usdt/month
👉 We ain't just showing our results, we can show you the results of our VIP subscribers as well! Check them out: @propheta_reviews
Register and get bonuses up to $6,000
Binance | OKX | ByBit👈🏻click!
#tradingindicator#trading#btc
👆 Propheta living up to its name yet again 🔮
#ZROUSDT has achieved 9th TP in our VIP PRO channel!
$608 in profits with a 5% entry and a $1000 deposit!
Feels good to be a Propheta VIP, man... 🏖ACCESS TO MANUAL TRADING for 70usdt/month
⚡️Speed up your trading with Propheta AI Signals: real-time precision signals, elite-level automation, and Cornix integration — the future of trading is now! GET THE ACCESS TO AI SIGNALS
Register and get bonuses up to $6,000
Binance | OKX | ByBit👈🏻click!
#cryptoexchange#cryptocurrency#AItrader
#ZROUSDT UPDATE:
#ZRO is now currently trading around $1.4290. It has already broken out of the Falling Wedge pattern and is looking good. So if the price pumps from here, then we can see short-term bullish momentum in it according to the pattern. If the breakout is a fake out, then it may again trade inside the pattern. Keep an eye on it.
0⃣#ZRO + #Tether = 🚀🚀🚀
Tether recently invested in #LayerZero, and you know they don't drop cash without deep due diligence. 🕵️♂️ The fundamentals are rock solid.
This rally is just the beginning. 🌤 I’m stacking as much $ZRO as possible. targeting 2x - 5x gains! 💸
Get in or get left behind.👋
#DeFi#BullRun $ZRO #ZROUSDT
https://x.com/CryptoBull_360/status/2021403228970315928?s=20