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
¡Ya es oficial! ✅
🔴 El #PlanB de reforma electoral contempla la reducción de salarios a funcionarios electorales 🇲🇽👏🏻👀
https://revistaelpolitico.com/nacional/publican-plan-b-reforma-electoral-dof/
Trader #PlanB expressed an interesting idea about how future large ETFs provide themselves with Bitcoins:
"ETFs, in my opinion, such as #BlackRock, are currently loading $BTC through miners, not through exchanges. Buying #BTC directly on exchanges will affect the price too much. An indirect purchase from miners will affect the hashrate, but not the price. This can explain the current hashrate explosion"
¡No más privilegios! ❌💰
🔴#Sheinbaum celebró que el #PlanB ya es constitucional enlistando los 6 logros de esta ley que sigue haciendo llorar a la oposición 🗳️👏🏻
Tsss… 😱
🔴 Luego de la postura en contra del #PlanB de Sheinbaum, los mexicanos disminuyeron su confianza en el #PT🔥‼️👇🏻
https://sinlineamx.com/voto-de-pt-contra-plan-b-representa-ruptura-con-morena/
¡Necios, pero necios! 🙄
🔴 A pesar de que muchos mostraron descontento por la decisión, el #PT sigue insistiendo en no hacer cambios a la iniciativa del #PlanB enviada desde el Senado 🤬🇲🇽🗳️
https://revistaelpolitico.com/nacional/pt-aprobara-plan-b-si
Lo bueno es que no querían perder votos 😅
🔴 ¿Cómo crees que le vaya al #PT en 2027 tras la polémica con el #PlanB? 🤔👇🏻
https://sinlineamx.com/tunden-pt-por-eliminar-revocacion-mandato-plan-b/
¿Se consumó una nueva traición? 🤔
🔴 El #PT jugó del lado del McPRIAN y tumbó la revocación de mandato con una reserva al #PlanB🙄 | Así se vivió la sesión 👇🏻
https://sinlineamx.com/revocacion-de-mandato-queda-fuera-plan-b-pt/
¡Y siguen! 🙄
🔴 Ahora resulta que el #PT solo posó para la foto y dio un falso respaldo al #PlanB de #Sheinbaum😡📄🔍
https://sinlineamx.com/pt-niega-acuerdo-definitivo-morena-sobre-plan-b/
Аналитик PlanB ожидает, что после халвинга курс биткоина достигнет $100 000 в 2024 году, а на пике в 2025 году — $300 000.
Он считает, что текущий цикл ничем не отличается от предыдущих и заявил, что лучшая стратегия — покупка биткоина за 6 месяцев до халвинга и продажа через 18 месяцев.
При таких прогнозах курс Крипто Индекса WBT может достигнуть цены в 5 usdt.
Сегодня самое время докупиться.
#халвинг#мнение#PlanB
PlanB Shifts Funds to Crypto ETFs
Crypto analyst PlanB has transitioned his capital from Bitcoin savings to spot ETFs based on digital gold, deeming it a rational progression towards Bitcoin adoption. His move sparked mixed reactions within the community, with some viewing it as a mistake. Meanwhile, BNB Chain's team is optimizing transaction processing for meme coins following updates aimed at increasing the validator's capacity to process transactions efficiently. Recent judicial developments involving Binance and the SEC may also be influencing market dynamics.
#Crypto#Bitcoin#ETF#BNBChain#SEC#MemeCoins#PlanB