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
#SNX/USDT analysis :
#SNX is currently retracing towards the support zone following a recent impulsive move. It is anticipated that after a breakout from this zone, the price will retest and subsequently bounce back, resuming its bullish momentum.
TF : 1D
Entry : $2.0
Target : $3.4
SL : $1.5
#SNX/USDT analysis :
#SNX has broken and retested the support zone, and it is currently facing resistance from the 200 EMA. The price is likely to continue its bearish momentum from its current level and retest previous lows.
TF : 4H
Entry : $1.353
Target : $1.229
SL : $1.430
#SNX🐻👀
A little bit risky but will worth to try. Use SL.
Want to see more strategies for any coin? Check out CoinLegs in order to have an overview before your trades 📊
UNBELIEVABLE PROFIT OF 23,600% HAS BEEN REALIZED IN #SNX
🔀
We're made a massive 2️⃣3️⃣6️⃣🔤 profit this Trade 🤑🔥
If you had only $50 inthis single position you would've made $11,800⭐
Went from 7,910% to 23,615%—That’s an extra 15,705% profit just by holding for maximum gains🥂🔥
If you're someone who's been following our progress, but haven't yet joined the PREMIUM group, what's holding you back? You can see the consistent profits we're making on a regular basis. The only difference between you and the members who send us the positive feedback you see, is that they took action and joined the PREMIUM group.
It's business as usual - every day, like clockwork, we are in the fast lane, leaving the competition eating our dust
😮💨🪙
If you are ready to step up, send me a message and let's get started 👇
@Kevindexter✅
🔀#SNX/USDT 2,170% profit, insane move! 🤯
That’s 2️⃣1️⃣🔤 gain on your money 💰🔥
💰$50 would return $3600💸
💰$50 would return $1,085💎
💰$50 would return $1,085💎
Fast & solid results—that’s what we love the most. Any guesses on who’s missing out again? 🤔
Enjoy 2,170% profit🆙. 🤝Congratulations all Premium Members.
Now imagine if you followed the rest of the signals.. 🤑💯
chat to join
➡️@Kevindexter✅️