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
crDroid - Unofficial | Android 16 | Nothing Phone (2)
📝 Details:
- Version: v12.3
- Device: #Pong
- Released: 15/11/25
⬇️ Downloads: ROM and Recovery Image
⚙️ Flashing Instructions: Here
📖 Changelogs: Here
🏷 Tags: #LOS#ROM#crDroid#Unofficial
✍️Notes:
- GAPPS and Vanilla builds available
- Dolby and initial Nothing camera support available
- WFD broken
- SukiSU Ultra with SUSFS out of the box
- OTA updates are supported
- Signed with release-keys
- Use latest NOS 3 firmware
- If face any bugs report with logs
🏆Credits:
- Ghost and Chandu for DT
- Fabian & HELLBOY for Glyph
- HELLBOY for Meteoric Kernel
👤 Maintainer: @deadlylxrd
💬 Chat: @NothingPhone2
🔔 Updates: @NothingPhone2Updates
OrionOS Project - OFFICIAL | A14 | Nothing Phone (2)
Based on LineageOS & crDroidAndroid
📔 Details:
- Version: Cosmic
- Codename: #Pong
- Released: 04/08/2024
🔽 Download (Recovery) : Vanilla | Gapps
⚙️ Installation: Here
📸 Screenshots: Here
🆘 Support: Telegram
🔖 Tags : #ROM#LOS#Official#QPR3#U#NothingPhone2
✍️ Note:
- Kernel is prepatched with KSU (Download Manager)
- Clean flashing is mandatory
- Both Vanilla & Gapps Build Available
- Powershare (Wireless Reverse Charging)
- Auto brightness in Glyph
- X-Reality Engine in Colors
- MicroG should pass Integrity (Not tested)
- Game Space
- Battery Backup was pretty decent during testing.. Wait for a charging cycle to complete..
‼️ Known Bugs:
- Lock Screen Carrier Text is a bit right.. Would be fixed with next OTA of August SP
🏆 Credits
- Chandu for base device tree & Kernel
- OC'D, Miki, Unluck & Ghost for all help
- Fabian & Hellboy for PA Glyph
- Testers
😎 Maintainers: @AgBKartikey
🔔 Updates: @NothingPhone2Updates
💬 Chat: @NothingPhone2