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
#InfinityX#qpr2#Diting#A15
Project InfinityX - v2.8 | Android 15
Released: 8/05/2025
▪️Gapps: Gdrive
▪️Vanilla: Gdrive
▪️Recovery: Ofox
▪️Screenshots
Notes:
It is recommended to use ofox recovery if you are flashing via fastboot.
fastboot flash recovery_ab recovery.img
Changelogs:
• Synchronized with the latest changes
• Device integrity passes (signed build)
• fixed the problem with freezing when the battery reaches 5%?
• KernelSU Support
• Firmware included
• Dolby Audio by default
• HyperOS Camera by default
Credits:
Thanks to @TeamMEX_XDA❤️
Thanks to @zED141 for giving me space on gdrive
By@Jezzay97 | Donate
Follow@xiaomi_12tpro_updates
Join@xiaomi12tpro_chat
#InfinityX#qpr2#Diting#A15
Project InfinityX - v2.7 HotFix | Android 15
Released: 3/05/2025
▪️Gapps: Mirror | Gdrive
▪️Vanilla: Mirror | Gdrive
▪️Recovery: Ofox
▪️Screenshots
Notes:
It is recommended to use ofox recovery if you are flashing via fastboot.
fastboot flash recovery_ab recovery.img
Changelogs:
• Synchronized with the latest changes
• Device integrity passes (signed build)
• Fixed the error when installing gapps due to missing partition.
• Slot 2 problem for Sim cards solved
• Firmware included
• Dolby Audio by default
• HyperOS Camera by default
• and many more changes...
Credits:
Thanks to @TeamMEX_XDA❤️
Thanks to @zED141 for giving me space on gdrive
By@Jezzay97 | Donate
Follow@xiaomi_12tpro_updates
Join@xiaomi12tpro_chat
#InfinityX#qpr2#Diting#A15
Project Infinity X - v2.7 | Android 15
Released: 3/05/2025
▪️Gapps: Mirror | SF
▪️Vanilla: Mirror | SF
▪️Screenshots
Notes:
• Synchronized with the latest changes
• Device integrity passes (signed build)
• Thermal menu was removed for now
• Remove some ARM blobs
• Now with oss kernel
• Fixed some vibration bugs. now works 100%.
• Added KernelSU support
• Improved performance
• Firmware included
• Dolby Audio by default
• HyperOS Camera by default
• and many more changes...
Credits:
Thanks to @TeamMEX_XDA❤️
By@Jezzay97 | Donate
Follow@xiaomi_12tpro_updates
Join@xiaomi12tpro_chat
#InfinityX#qpr2#Diting#A15
Project Infinity X - v2.7 | Android 15
Released: 20/04/2025
▪️Download: Mirror | SF
▪️Screenshots
Notes:
• Synchronized with the latest changes
• Device integrity passes (signed build)
• Workaround for voip audio routing issue using a monitoring service (Whatsapp calls on speakerphone fixed)
• Firmware included and updated
• Gapps build only
• Dolby Audio by default
• HyperOS Camera by default
By@Jezzay97 | Donate
Follow@xiaomi_12tpro_updates
Join@xiaomi12tpro_chat