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
📰Rocket League is adding Easy Anti-Cheat, Psyonix say Linux will still be supported with Proton
Rocket League is set to get Easy Anti-Cheat in April, as the Epic Games owned studio Psyonix just recently announced.Read the full article on GamingOnLinux.
🔗 Source: https://www.gamingonlinux.com/2026/02/rocket-league-is-adding-easy-anti-cheat-psyonix-say-linux-will-still-be-supported-with-proton/
#linux
📰 Bottles 62.0 Adds Dynamic Launcher Portal Support
Bottles 62.0, a Wine prefix manager for running Windows apps on Linux, introduces Dynamic Launcher portal support and adds detailed progress reporting for backups and restore operations.
🔗 Source: https://linuxiac.com/bottles-62-0-adds-dynamic-launcher-portal-support/
#linux
📰 RISC-V In Linux 7.0 Brings User-Space CFI & Optimized strlen Assembly
The RISC-V architecture updates have been merged for Linux 7.0 with a few items to note...
🔗 Source: https://www.phoronix.com/news/Linux-7.0-RISC-V
#linux
📰 CTM360: Lumma Stealer and Ninja Browser malware campaign abusing Google Groups
CTM360 reports 4,000+ malicious Google Groups and 3,500+ Google-hosted URLs used to spread the Lumma Stealer infostealing malware and a trojanized "Ninja Browser." The report details how attackers abuse trusted Google services to steal credentials and maintain persistence across Windows and Linux systems.
🔗 Source: https://www.bleepingcomputer.com/news/security/ctm360-lumma-stealer-and-ninja-browser-malware-campaign-abusing-google-groups/
#linux
📰6 microcontroller projects that used to require a full SBC running Linux
We used to need SBCs for these projects; modern microcontrollers handle them more easily and inexpensively while being easier to maintain.
🔗 Source: https://www.xda-developers.com/microcontroller-projects-used-require-full-sbc-running-linux/
#linux