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
#ARDR/USDT analysis :
#ARDR is in a bearish trend, consistently making lower lows (LLs) and lower highs (LHs) below the 200 EMA. The price is currently rejecting from the 200 EMA and is anticipated to resume its downward movement, targeting lower levels.
TF : 4H
Entry : $0.07035
Target : $0.05818
SL : $0.07815
#ARDR👈
https://www.binance.com/en/trade/ARDR_BTC
Buying Zone 540-550👈
Buy in parts n successive dips
Strictly follow as directed
On the verge of hardcore pump
Sell
🤑 620-650
🤑 650-700
🚀 700-800
💃 800-900 & above
#ARDR/USDT analysis :
After breaking out above the 200 EMA, the #Ardor has retested it and consolidated sideways over the support zone. Recently, the price has bounced back from the support zone, and it is anticipated to continue its bullish momentum to test the previous swing high level.
TF : 1D
Entry : $0.09132
Target : $0.12550
SL : $0.07356
Roaring Kitty Hints at Comeback
🐦 Roaring Kitty, a key figure in the GameStop stock surge, teases a return. His recent tweet features a video, sparking nostalgia and speculation about upcoming moves. Kitty symbolizes retail investor resistance against Wall Street, igniting the meme stock revolution in 2021.
🔗Roaring Kitty's tweet
🔗 Whale Alert: $102M in #BTC transferred Details here
🔗 Bithumb launches new ARDR & QKC trading Read more
#GameStop#RoaringKitty#memeStocks#BTC#Crypto#VC#RetailInvestors#WhaleAlert#SouthKorea#Trading#Bithumb#ARDR#QKC#Investing#MarketNews#Finance#Nostalgia#Tease#Speculation