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
#java#gale#java#keyi#minecraft#minecraft_performance#minecraft_server_software#mirai#paper
Leaf is a high-performance, customizable Minecraft server software based on Paper, designed to improve game speed and flexibility. It supports asynchronous pathfinding, mob spawning, and entity tracking, making gameplay smoother. Leaf is compatible with Spigot and Paper plugins, supports all username characters, fixes some Minecraft bugs, and uses a disk-saving file format. It integrates error tracking for easier server maintenance and keeps dependencies up-to-date. This means you get a faster, more stable Minecraft server with better plugin support and easier management, enhancing your overall gaming experience. Java 21 or higher is required to run it.
https://github.com/Winds-Studio/Leaf
🇯🇵 Elezioni #Giappone – Clamoroso exit poll di TBS: Il Partito Liberal Democratico della premier #Takaichi potrebbe da solo ottenere per la prima volta nella storia la super maggioranza dei 2/3 per cambiare la Costituzione.
Governo: 356
#LDP (conservatori): 321
#Ishin (destra libertaria): 35
Opposizione: 109
#CRA (centro): 50
#DPFP (centrodestra): 29
#Sanseito (estrema destra): 11
#Mirai (democrazia digitale): 8
#JCP (comunisti): 3
Altri: 8
@UltimoraPolitics24
#go#coolq#cqhttp#cqhttp_mirai#go#go_cqhttp#golang#group_manager#mirai#mirai_bot#nonebot#onebot#onebot_plugin#onebot_sdk#plugin#qq#qq_bot#qqbot#qqrobot#websocket#zerobot
ZeroBot-Plugin is a comprehensive utility plugin collection for the ZeroBot chatbot framework, offering over 100 features across entertainment, management, and productivity categories. The system provides high-priority functions like chat management, sleep tracking, and group administration, alongside mid-tier features such as image generation, music streaming, and game simulations. Users benefit from flexible plugin control—enabling or disabling specific features per group—and dynamic loading capabilities that reduce program size. The platform supports multiple deployment methods, from pre-compiled releases to local compilation, making it accessible whether you prefer ready-to-use binaries or customized builds. With extensive command options, scheduled task triggers, and AI integration, ZeroBot-Plugin transforms group chat management into an automated, entertaining experience while maintaining user control over which features activate in specific communities.
https://github.com/FloatTech/ZeroBot-Plugin