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
📰 Linux MAINTAINERS Cleaning For Recently Departed Intel Devs, Altera Drivers Oprhaned
The layoffs and restructuring at Intel in 2025 caused unfortunate hits to their Linux/open-source engineering including various driver maintainers leaving and even their CPU temperature driver being orphaned for lack of maintainers. Sent out today were a number of additional updates to the MAINTAINERS file for the Linux kernel to reflect other Intel departures in recent months.
🔗 Source: https://www.phoronix.com/news/Linux-MAINTAINERS-Intel-March
#linux#opensource#intel#kernel
📰 Intel Begins Preparations For Xe3P Upstreaming To Open-Source OpenGL & Vulkan Drivers
Following the mainline Linux kernel beginning to see Xe3P graphics enablement for upcoming Nova Lake integrated graphics as well as the Crescent Island AI inference accelerator, Intel's Mesa OpenGL "Iris" and Vulkan "ANV" drivers are preparing to begin laying out their Xe3P driver support...
🔗 Source: https://www.phoronix.com/news/Intel-Mesa-Xe3P-Start
#linux#opensource#intel#kernel
📰 Arm Preparing The Linux Kernel For 128-bit Page Table Entries "FEAT_D128"
A new core infrastructure improvement for the Linux kernel on ARM being worked on is enabling 128-bit page table entries (PTEs) with FEAT_D128 as a new optional feature of Armv9.3 and later...
🔗 Source: https://www.phoronix.com/news/Arm-Linux-FEAT-D128-Patches
#arm#kernel#linux
📰 IBM Updates Linux Patches For Introducing ARM64 KVM Virtualization On s390
At the start of April was the peculiar announcement of IBM collaborating with Arm on "dual architecture" hardware. The initial fruits of that collaboration at least are Linux kernel patches for enabling ARM64 virtualization acceleration on IBM Z servers. As we approach the end of the month, IBM has now posted a second iteration of those patches for enabling AArch64 software to run on IBM s390 via the Kernel-based Virtual Machine (KVM)...
🔗 Source: https://www.phoronix.com/news/ARM64-On-s390-IBM-Z-v2
#arm#kernel#linux
📰With Linux 7.1 The Mainline Kernel Now Supports Real-Time "RT" On ARM
The Linux 7.1 mainline kernel will allow building a real-time "PREEMPT_RT" kernel for the ARM architecture with no longer needing any out-of-tree patches...
🔗 Source: https://www.phoronix.com/news/Linux-7.1-ARM-RT
#arm#kernel#linux
📰 Linux 7.1 Lands Workaround For Arm C1-Pro Erratum
Merged yesterday to the Linux 7.1 kernel is a workaround for an Arm C1-Pro CPU hardware bug around its Scalable Matrix Extension implementation...
🔗 Source: https://www.phoronix.com/news/Linux-7.1-Arm-C1-Pro-Fix
#arm#kernel#linux
📰Arm Preparing Live Firmware Activation Support For Linux
A new platform feature being worked on by Arm engineers for the Linux kernel is Live Firmware Activation to allow for updated firmware components to be deployed without requiring a system reboot...
🔗 Source: https://www.phoronix.com/news/Arm-Live-Firmware-Activation
#arm#linux#kernel
📰 ARM NEON Accelerated CRC64 Optimization Shows Nearly 6x Improvement
A patch posted today to the Linux kernel mailing list provides an ARM64-optimized CRC64-NVMe implementation for nearly a 6x improvement on modern Arm SoCs...
🔗 Source: https://www.phoronix.com/news/ARM-NEON-CRC64-6x
#linux#kernel#arm
📰 Kernel 6.19: GPU, SoC, and Rust improvements
Collabora continues to be a key contributor to the Linux kernel, with 125 patches from 21 developers! Highlights include Arm Mali GPU improvements, expanded MediaTek and Rockchip SoC support, Rust integration progress, and new Rockchip video capture functionality.
🔗 Source: https://www.collabora.com/news-and-blog/news-and-events/kernel-619-gpu-soc-rust-improvements.html
#linux#kernel#arm
ЛюбопытныйTUI для перехвата сетевого трафика с использованием eBPF в Linux
Особенности
- Мониторинг и визуализация трафика в реальном времени.
- Полная статистика сетевого трафика.
- Функции межсетевого экрана.
- Исследователь метрик.
https://github.com/pythops/oryx
#ит_заметки#linux#kernel#network#ebpf#oryx