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
🏆«Красная Строка» — №1 среди региональных книжных фестивалей России
Ассоциация книжных фестивалей (АКФ) опубликовала ежегодный рейтинг региональных книжных фестивалей страны — по итогам профессионального голосования издателей и книготорговцев. В опросе участвовали 82 эксперта книжного рынка из разных регионов России.
❤️🔥 По итогам 2025 года «Красная Строка» (Екатеринбург) снова заняла 1 место — второй год подряд.
В тройку лидеров также вошли:
2 место — фестиваль «Китоврас» (Владимир)
3 место — фестиваль «Волжская Волна» (Саратов)
Спасибо всем, кто делает фестиваль вместе с нами — это очень тёплая и честная оценка от тех, кто каждый день работает с книгами и читателями!
Отдельно благодарим нашего программного директора Михаила Фаустова — он также представляет Ассоциацию книжных фестивалей и проект «Читающая Россия» и помогает собирать программу, которой хочется гордиться.
❕А кого вы больше ждёте на «Красной Строке» в следующем году?
#UralMusicNight#КраснаяСтрока#ФПГ#ФондПрезидентскихГрантов
Туристы направили свой взор на Ural Music Night
🔥 110+ площадок.
🔥 3000+ артистов из самых разных жанров: от фолк-джаза до глиттер-попа, от панк-метала до хип-хопа, от академической музыки до драм-н-бейса.
#uralmusicnight2025#UMN#UralMusicNight#UMN2025#UralMusicNight2025
📍Date: Friday, 27 June 2025
🕢Time: 19:40–20:20
📌Venue: BURBON Wine Bar, 47 Sako i Vantsetti Street, Yekaterinburg
🎶An African band to perform at the Ural Music Night festival in Yekaterinburg!
The Office of the Honorary Consul of South Africa, together with the festival team, has invited 4Groove—a dynamic band formed by Nigerian students of Ural Federal University (UrFU)—to take part in this year’s program.
Come and enjoy the rhythm of Africa! 🎤🔥
The project is supported by the Presidential Fund for Cultural Initiatives, the National Project Tourism and Hospitality Industry, the Governor of the Sverdlovsk Region, and the Yekaterinburg City Administration.
Sber is the festival’s official general partner.
#UralMusicNight#4Groove#URFU#Yekaterinburg#SouthAfrica#AfricanMusic#MusicFestival
🎶An African band to perform at the Ural Music Night festival in Yekaterinburg!
The Office of the Honorary Consul of South Africa, together with the festival team, has invited 4Groove—a dynamic band formed by Nigerian students of Ural Federal University (UrFU)—to take part in this year’s program.
🎗 Last year, 4Groove performed a heartfelt charity concert for children and parents at the Children’s Oncology and Hematology Center. 📹 Watch the short videos from that performance—pure joy and energy!
📍Date: Friday, 27 June 2025
🕢Time: 19:40–20:20
📌Venue: BURBON Wine Bar, 47 Sako i Vantsetti Street, Yekaterinburg
Come and enjoy the rhythm of Africa! 🎤🔥
The project is supported by the Presidential Fund for Cultural Initiatives, the National Project Tourism and Hospitality Industry, the Governor of the Sverdlovsk Region, and the Yekaterinburg City Administration.
Sber is the festival’s official general partner.
#UralMusicNight#4Groove#URFU#Yekaterinburg#SouthAfrica#AfricanMusic#MusicFestival
🎶 An African band lit up the crowd at Ural Music Night in Yekaterinburg!
Thanks to the collaboration between the Office of the Honorary Consul of South Africa and the festival organizers, 4Groove — a vibrant band formed by Nigerian students at Ural Federal University (URFU) — was invited to perform.
📹 Check out these energetic performance videos! 🎤🔥
#UralMusicNight#4Groove#URFU#Yekaterinburg#SouthAfrica#AfricanMusic#LiveMusic#MusicUnites