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
🔎Telegram May Be Quietly Testing a Feed like Feature
Telegram has recently introduced a new ‘Posts’ tab in Search, allowing users to easily discover content from public channels. This update comes roughly a year after the launch of #hashtagsearch, signaling Telegram’s continued focus on improving content discoverability.
This appears to be a soft launch of a potential future ‘Feed’ feature — offering users a scrollable stream of relevant #posts, possibly influenced by engagement metrics such as stars.
If fully implemented, this feature could significantly boost post visibility for channels, increase ad exposure for advertisers, and enhance ad revenue opportunities for creators. All indications suggest that Telegram is gearing up to roll out a #feed-based content experience, a move that could reshape how users browse and interact on the platform.
When the chat reaches 4,000 members or the channel 90,000, 10 group members will be allowed to create a post each, about a sfw topic of their own chosing. You must give @googlefactss permission to use your post and add it to the channel, with or without your username.
More details will come after we hit these numbers. Invite friends, family, and coworkers to join.
Do not spam/send links without permission of the place you send them in!!
Our group links are:
Main channel https://t.me/googlefactss
Group:
https://t.me/googlefactssgroup
@googlefactss📢👥
#Community#Permission#Posts#Growth#KeepTrackOfThisPost
@channely_bot
Qué puede hacer este bot?
Este bot es el mejor asistente para la gestión de canales en Telegram. Conecto los canales al servicio principal. ¡Incluyendo un rico entorno webUI de edición!
https://app.channely.co/
Idioma: Inglés
(visto en @BotsGram.cu)
#canales, #canal, #gestión, # administración, #richeditor, #posts, #schedule, #polls, #comment, #commenting, #reactions, #editor, #share, #buttons, #webui, #subscribe, #stats, #users, #trial, #limited, #proaccount