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
#SYS/USDT analysis :
The #SYS is currently in a downtrend, trading below the 200EMA. The price is testing resistance at the current level, and it's expected to decline further from there, potentially testing lower price levels.
TF : 2h
Entry : $0.0487
Target : $0.0410
SL : $0.0522
#SYS/USDT analysis :
#SYS is currently in a correction phase, experiencing a retracement toward the 200 EMA. This presents a potential long trade opportunity on lower time frame. Look for price to retrace and test the support zone for a long entry.
TF : 30min
Entry : $0.0676
Target : $0.0735
SL : $0.0644
#SYS/USDT analysis :
#SYS is currently consolidating sideways within the support zone and is expected to rebound from this level, potentially testing previous highs. It is advisable to wait for a pullback to establish a long position.
TF : 1D
Entry : $0.0964
Target : $0.1257
SL : $0.0822
BUYING $SYS HERE
Exchange: Binance / Binance Futures
Leverage: 3-5x
Breakout confirmed. Market conditions are perfect for an easy 100-200% move on #SYS
Targets: OPEN
SL: Below 0.0254
#SYS result
2 nd target achieved in just 11 hours ✅✅
One more huge quick profit 17% +🤑💰🤑
👉 Still thinking? The more you wait more you lose profit
☎️ Contact @MichaelStrategiesVip for membership and grab next breakout signal