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
Nameless AOSP - Official | Android 13 | Nothing Phone (2)
📝 Details:
- Version: 1.4
- Status: #Official
- Device: Pong
- Released: 26/11/23
⬇️Download : Build l Images
👀 Changelogs : Here
🌳Device Tree : Here
📔Flashing Instructions : Here
🎙Support Group: Here
🏛 XDA : Here
📸 Screenshots:Here
💰Donate : Paypal | UPI : chandudyavanapelli3-1@okhdfcbank
🏷Tags : #AOSP#ROM#Nameless#T
❌Known Issues:
- No NFC Support (Sadly PN560 NFC is not supported in Android 13. Will be revisited once we move to Android 14)
✍️Note:
- Report issues (if any except known ones) with logs in support group / comments
- This is the final Android 13 release. We will start work on Android 14 from 2024 January.
🏆 Credits:
- Chandu Dyavanapelli for initial DT bringup
- Pong Dev and Testing Team & Contributors
👤 Maintainer : @Chandu_Dyavanapelli
🔔 Updates : @NothingPhone2Updates
🐙 Chat : @NothingPhone2
Nameless AOSP | Android 13 | Nothing Phone (2)
📝 Details:
- Version: 1.4
- Build: #Beta
- Status: #Official
- Device: Pong
- Released: 12/11/23]
⬇️Download : Build l Images
🌳Device Tree : Here
📔Flashing Instructions : Here
🎙Support Group: Here
📸 Screenshots:Here
💰Donate : Paypal
🏷Tags : #AOSP#ROM#Nameless#T
✨ Changelogs:
- Initial Test Build
❌ Known issues:
- NFC is broken, causing the system UI to crash after every reboot, but only once.
- Haptics are not similar to stock but will improve in upcoming builds.
- Dont use "Hey Google" as it leads to crashdump. Use factory reset to revive.
- Some device specific features are not added, will be added eventually.
- Report bugs (with logs ofc) in the comment section.
🏆 Credits:
- Chandu Dyavanapelli for initial DT bringup
- Pong Dev and Testing Team & Contributors
👤 Maintainer : @Chandu_Dyavanapelli
🔔 Updates : @NothingPhone2Updates
🐙 Chat : @NothingPhone2
Nameless CLO - Official | Android 15 | Nothing Phone (2)
🗒 Details:
- Version: A15
- Codename: #Pong
- Released: 22/12/24
🔽 Download: ROM [ Sourceforge l Mirror ] || Images [ Sourceforge l Mirror ]
🆘 Support : Telegram l Wiki
⚙️ Installation: Here
📸 Screenshots: Here
💵 Donate: Paypal | UPI: dyavanapellichandu@ybl
🔖 Tags : #ROM#CLO#Nameless#V#Official#NothingPhone2
✨Source Changelogs:
- Initial A15 Release based on CLO
✍️ Note:
- A clean flash is required if you're coming from Nameless-AOSP or any custom ROMs.
- You will not receive OTA updates in Nameless-AOSP for this build.
👤 Dev : Chandu Dyavanapell
🔔 Updates : @NothingPhone2Updates
💬 Chat : @NothingPhone2
Nameless AOSP - Official | Android 14 | Nothing Phone (2)
🗒 Details:
- Version: A14 - Final
- Codename: #Pong
- Released: 14/09/24
🔽 Download: Here | Mirror
🆘 Support : Here
⚙️ Installation: Here
📸 Screenshots: Here
💵 Donate: Paypal | UPI: dyavanapellichandu@ybl
🔖 Tags : #ROM#AOSP#Nameless#QPR3#U#Official#NothingPhone2
✨Source Changelogs:
- Merged September security patch
- Updated default wallpaper and boot animation
- Add navbar animation in pixel launcher
- Stability improvements and minor fixes
✍️ Note:
- This is the final A14 release and no OTA update exists for the same.
- Please update manually in recovery mode
👤 Dev : Chandu Dyavanapell
🔔 Updates : @NothingPhone2Updates
💬 Chat : @NothingPhone2