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
#SPELL/USDT analysis :
#SPELL is currently in an uptrend, having demonstrated a rejection after testing the support zone. It is expected that the price will bounce back, resuming its bullish momentum and targeting higher price levels.
TF : 1D
Entry : $0.0010768
Target : $0.0020884
SL : $0.0008066
#SPELL/USDT analysis :
#SPELL has faced resistance at the 200 EMA and has broken below the trendline, indicating a continuation of its downtrend. The formation of lower lows (LLs) and lower highs (LHs) suggests this bearish trend is likely to persist until it reaches previous lows.
TF : 4h
Entry : $0.000740
Target : $0.000550
SL : $0.000865
#SPELL/USDT analysis :
#SPELL is currently in an uptrend, trading above the 200 EMA. The price is undergoing a corrective phase and is expected to test the support zone. A bounce from this level is anticipated, which would allow the price to continue its bullish momentum. It is advisable to wait for the price to retest and show signs of a bounce from the support zone before considering a long entry.
TF : 4H
Entry : $0.0007415
Target : $0.0009850
SL : $0.0006443
#SPELL/USDT analysis :
#SPELL has recently broken below the 200 EMA and previous support levels, and it has retested these levels. It is now likely to continue its bearish momentum and test the previous lows.
TF : 4h
Entry : $0.000537
Target : $0.000492
SL : $0.000561
#SPELL/USDT analysis :
#SPELL is trading in the resistance zone below the 200 EMA. It is expected that the price gonna face rejection at this level and continue moving downwards. It is advisable to wait for the price to break below the $0.000532 level for an entry.
TF : 2H
Entry : $0.000532
Target : $0.000455
SL : $0.000569
#SPELL LONG
📌Симпатично выглядит технически.
▪График слева - зеркальный уровень, мы видим как тестирует с обратной стороны несколько раз, кажется готовится прорыв.
▪График справа - готовится пробой контртрендовой линии, стоим у границы.
▪Вход: 0.000517$
▪Тейк: буду обновлять.
⚠️Cтоп: 0.00044(-14%)
пс: учитываем, что это альткоин... берем не больше 10% в сделку.
LINK - Maximus Trade|TWITTER