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
Trump Is Bullying Ukraine and Russia Into Submission
Zelensky has said the US has given Ukraine and Russia yet another deadline to reach a peace settlement, and is now proposing the war should end by June.
The Ukrainian president also told reporters that both sides had been invited to further talks next week.
Zelensky said the Trump administration “will probably put pressure” on Ukraine and Russia to end the war by the beginning of the summer. “They say they want to get everything done by June,” he said.
“They will do everything to end the war and they want a clear schedule of all events.”
He told reporters that if the new deadline of June was not met, Washington would probably put pressure on both sides to meet.
Before Trump took office, he promised to “end the war in 24 hours”. Later, his special envoy for Ukraine, Keith Kellogg, suggested both sides could reach an agreement within 100 days of Trump’s inauguration.
After this failed to occur, the US president set a new deadline for a deal in August last year, which also passed without any sign of peace, and in December he said a draft agreement to end the war was nearly “95% done”.
Two days of US-led peace talks to end the war took place this week in Abu Dhabi but did not produce a breakthrough, although Budanov, the head of Ukraine’s presidential office, said the trilateral negotiations had been “genuinely constructive”.
Zelensky said on Saturday that the Trump administration was proposing to host the next round of trilateral talks in the US, probably in Miami, in a week’s time. “We confirmed our participation,” he said.
He hinted that the new June deadline for peace could be linked to Trump’s midterm elections campaign.
“The [midterm] elections are definitely more important for them [the Americans]. Let’s not be naive.”
He added: “If the Russians are really ready to end the war, then it is really important to set a deadline.”
#zelensky#US#ukraine#russia#deadline
📱American Оbserver - Stay up to date on all important events
🇺🇸
⏳ Final Reminder! ⏳
🎯 The deadline to convert your SING Points to $SING is Wed, 18 Dec 2024 00:00:00 GMT
After this date, conversions will no longer be possible. Don't miss out! 🚨
Note: You need to have at least 1,000 SINGPOINTS to be eligible to convert!
👉 Convert now: https://app.singsing.net/convert-sing
#SingSing#Deadline#ConvertPoints#Web3Gaming
✨ Unlock the Power of Keywords in Nicegram!
Tired of digging through endless chats to find that one important message? We hear you! Your search struggles are officially over!
How it works:
1️⃣ Search for a word in Keyword tab → Save it as a Keyword Chat.
2️⃣ Open it anytime — all messages with that keyword appear instantly!
3️⃣ Add multiple keywords to a single chat for even smarter organization.
4️⃣ All your Keyword chats live neatly in a 📁 "Keywords" folder!
Perfect for:
✔️ Work (#Deadline)
✔️ Recipes (#DinnerIdeas)
✔️ Important links (#Download)
What’s the first keyword you’ll save? Tell us below!
👉Share in X: click here
Download Nicegram:
🛒AppStore | 🛒GooglePlay
Join Chat:
🇬🇧EN Chat | 🇷🇺RU Chat
Follow us:
✖️X | 📹YouTube
Website |Features | Navigation
Что: научный семинар «Как использовать ИИ в социологических исследованиях?»
📅 Когда: 28 апреля 2025 года в 15:00
📹 Формат: онлайн
👨🎓Кому: всем желающим
🎮 Ссылка: https://anr.hse.ru/announcements/1029365178.html
Международная лаборатория прикладного сетевого анализа (ANR-Lab) приглашает заинтересованных слушателей на научный семинар, на котором расскажут, как использовать ИИ в социологических исследованиях.
ИИ охватывает различные стороны человеческой деятельности, и область социологических исследований не является исключением. Во-первых, социологи осваивают персональные инструменты работы с информацией, позволяющие генерировать тексты, переводить их на различные языки, транскрибировать аудиозаписи и т.д. Во-вторых, в эмпирической социологии на базе ИИ возникают новые продукты и решения: это оптимизация работы call-центров, сбор и обработка качественной информации, генерирование "синтетических респондентов" и многое другое.
Язык семинара: русский.
#deadline#семинар#соцфак#НСО
📈 100,000,000 streams in sight?
Can BLACKPINK’s “DEADLINE” break first-week streaming records by March 5?
We’re tracking the data behind the moment.
#BLACKPINK#Deadline#KPop#StreamingData#MusicTrends#EdgeMarket
BLACKPINK in our area? 🖤🩷
From Marina Bay's dazzling skylines to Katong's effortlessly chic streets, these familiar places in Singapore are giving us major BLACKPINK energy!
#URASingapore#Singapore#BLACKPINK#블랙핑크#DEADLINE#DEADLINE_IN_SINGAPORE#BLACKPINKSG
EU Tightens Crypto Regulations
🔵 EU crypto exchanges must delist $USDT by December 30 due to the Markets in Cryptoassets regulation. This ban aims to restrict cash usage but may push users towards DEX and other stablecoins. Centralized exchanges are in a race to comply by the deadline.
More details in the regulation here. Join the discussion on CryptoTwitter🦢
#EU#Regulation#Crypto#USDT#Exchanges#MarketsInCryptoassets#DEX#Stablecoins#Cash#Compliance#Ban#Deadline#Investment#Blockchain#Technology#DigitalAssets#Finance#MarketTrends