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
Nod for Vizag Metro hinges on State's financial clearance.
Visakhapatnam district administration seeks ₹600 crore from the State government for private land acquisition under the ₹11,498 crore Metro Rail project
#Infrastructure#Infra
🇮🇷🇺🇸🇮🇱 L’infrastructure pétrolière et gazière iranienne sur les sites de South Pars et d’Assalouyeh a été frappée par les États-Unis et Israël, a rapporté l’agence Tasnim.
#infrastructure#frappe#iran
Fanton EN: Game Unavailability Due to Technical Issues
#infrastructure#Yandex
Fanton EN is currently facing a service disruption due to issues with their infrastructure provider, Yandex. The Yandex team is working to restore the system, and the game will be relaunched as soon as stability is confirmed.
Source: link
@tonlines
🇺🇸🚨BIDEN ANNOUNCES MAJOR INFRASTRUCTURE INVESTMENT
🔹 President unveils $2.1 trillion infrastructure package targeting roads, bridges, and broadband expansion across 50 states 🛣️💰
🔹 Plan includes 500,000 new jobs over next 4 years, focusing on union workers and American-made materials only 👷♂️🇺🇸
🔹 Republicans slam proposal as "reckless spending spree" while Democrats call it "essential for competitiveness" 💸🔥
🔹 Package requires Congressional approval — heated debates expected over tax increases to fund the massive investment 🏛️⚖️
This could reshape America's economy or bankrupt the nation. Which side is right? 🤔💭
#USNews#infrastructure#Biden
@america
👆Cruising down the highway of prosperity!
Experience a remarkable surge in capital expenditure on National Highways, paving the way for a journey towards high growth.
#NationalHighway
#NewIndia
#Infrastructure
Ukrainian Forces Strike Key Russian Oil Infrastructure
On the night of April 7, Ukrainian forces attacked the Ust-Luga Oil terminal in Leningrad region, destroying three Transneft-Baltika tanks. Earlier, on April 5, three RVSN-20000 tanks were damaged at the Primorsk port. Additionally, primary processing units at Lukoil’s refinery in Kstovo were hit. These strikes occurred via Baltic airspace following Moscow’s warnings.
#Russia#Oil#UAF#Infrastructure
The main news of Russia and the world ishere.
Кризис DRAM меняет рынок и подход к обучению современного ИИ.
✔️ Рынок захлестнул дефицит оперативной памяти и других накопителей: ИИ-гиганты выкупили огромные объёмы DRAM, HBM и NAND. Nvidia, по слухам, прекращает поставлять дистрибьюторам видеопамять в комплекте с GPU — теперь её нужно закупать отдельно. На текущий момент цены на SSD и оперативную память выросли на 50-100% по сравнению с началом года. Производители ноутбуков и смартфонов фиксируют задержки поставок, а комплект DDR5 на 64 ГБ уже стоит дороже PS5. 🤯
✔️ Мы спросили Гигачат, как кризис повлияет на развитие нейросетей и обучение моделей. ИИ-помощник формулирует так: "Дефицит памяти — это временный дисбаланс между взрывным ростом ИИ-индустрии и производственными мощностями, которые просто не успели масштабироваться под такой спрос. Высокая стоимость памяти заставляет компании переосмыслить подходы к обучению: вместо наращивания "железа напролом" фокус смещается на эффективные архитектуры и методы.". Подробнее — в видео.
@ai_machinelearning_big_data
#ai#llm#ml#ramcrisis#infrastructure
🌍 In the Alps, some villages rely on cable cars not just for tourists but for everyday transport. Steep slopes and deep valleys make cableways a crucial link for goods and people in remote mountain areas. ✨
#transport⚡#geography⚡#mountains⚡#infrastructure⚡#nature⚡#earth
👉subscribe Amazing Geography
👉more Channels
UK Invests Big in AI Development
The UK has announced a substantial investment plan aimed at enhancing its AI capabilities. This initiative, part of a national renewal concept, will focus on developing neural networks for government efficiency, establishing AI growth zones, and bolstering essential infrastructure like data centers and research clusters. More details can be found in the article on ForkLog.
#AI#Investment#UK#Infrastructure#Tech