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
☕ **ETHIOPIA: WHERE COFFEE BECAME SACRED** 🇪🇹
*The Ancient Ritual That Gave Birth to a $15 Billion Industry*
In Ethiopia's highlands, where coffee was discovered 1,200 years ago, the traditional coffee ceremony remains unchanged. This sacred 3-hour ritual transforms green beans into liquid gold through patience and community.
**The Sacred Process:**
🌿 Hand-picked beans from ancient forests
🔥 Roasted over charcoal in clay pans
💨 Aromatic frankincense purifies the space
🏺 Traditional jebena pot brews perfection
👥 Three rounds: Abol, Tona, Baraka (blessing)
**Economic Impact:**
• Ethiopian coffee exports: $1.2B annually
• Premium beans: $45-65 per pound
• Coffee tourism: $50-150 per ceremony
In Ethiopia, coffee isn't just a drink - it's a sacred bond between earth and soul.
#EthiopianCoffee#CoffeeCeremony#CoffeeOrigin
Buna Qalaa: More Than Just Coffee ☕️
Did you know the Oromo homeland is the birthplace of Arabica coffee? For the Oromo people, coffee (Buna) is not just a drink; it's a sacred ceremony that binds families and communities.
The Buna Qalaa is a cherished ritual of hospitality and respect. The air fills with the sweet aroma of roasting beans, incense (ittana), and lively conversation. It's a slow, beautiful process where every step is deliberate and full of meaning.
To be invited to a coffee ceremony is to be welcomed into the heart of an Oromo home. It’s a moment to share stories, blessings, and build connections. It is a true taste of Oromo hospitality!
#Buna#CoffeeCeremony#OromoCulture#Hospitality#Community#Ethiopia#Africa
http://T.me/etbisahusen
✈️ ETHIOPIAN AIRLINES: AFRICA'S AVIATION CHAMPION
የኢትዮጵያ አየር መንገድ፡ የአፍሪካ የአየር ትራንስፖርት ጀግና
Not just an airline - an EXPERIENCE at 35,000 feet! 🌍☕
ከአየር መንገድ በላይ - በ 35,000 ጫማ ላይ ልምድ!
━━━━━━━━━━━━━━━━
🏆 AFRICA'S UNDISPUTED AVIATION HUB
🌍 THE NETWORK:
• 130+ destinations across 5 continents
• Africa's largest airline network
• Addis Ababa = The Gateway to Africa
• Direct flights: NYC, London, Beijing, Mumbai, São Paulo
• "We connect civilizations!"
━━━━━━━━━━━━━━━━
🇷🇺 ETHIOPIA ↔ RUSSIA: BRIDGE BETWEEN CIVILIZATIONS
ኢትዮጵያ ↔ ሩሲያ፡ የስልጣኔዎች ድልድይ
ЭФИОПИЯ ↔ РОССИЯ: МОСТ МЕЖДУ ЦИВИЛИЗАЦИЯМИ
✈️MOSCOW (SVO): 3-4 flights/week | ~7 hours | от $450
✈️SAINT PETERSBURG (LED): Seasonal flights
ለሩሲያውያን ጎብኝዎች:
✅ Visa on arrival (30 days!)
✅ Russian meals available
✅ Gateway to all East Africa
✅ Cheaper than via Dubai/Istanbul
"От Москвы до Аддис-Абебы за 7 часов!" ❄️→☀️
━━━━━━━━━━━━━━━━
✈️ FLEET OF THE FUTURE:
• 140+ modern aircraft (Boeing 787, Airbus A350)
• Average age: 7 years (younger than most!)
• First African airline with Dreamliner
• Full Wi-Fi on international flights
━━━━━━━━━━━━━━━━
☕ THE EXPERIENCE YOU'VE NEVER HAD
💎 ETHIOPIAN COFFEE CEREMONY AT 35,000 FEET!
Imagine: You wake up from comfortable sleep... ✨
Open your eyes... 👀
And there she is - beautiful Ethiopian flight attendant in traditional habesha dress 👰
With jebena (ጀበና) filled with freshly brewed coffee ☕
She performs the ancient coffee ceremony... in the sky! 🌤️
THIS IS NOT A DREAM. THIS IS ETHIOPIAN AIRLINES.🔥
ይህ ህልም አይደለም። ይህ የኢትዮጵያ አየር መንገድ ነው።
Only on Ethiopian Airlines:
✅ Traditional coffee ceremony on long-haul flights
✅ Fresh Ethiopian coffee (birthplace of coffee!)
✅ Served by crew in traditional attire
✅ The aroma of home at 35,000 feet
━━━━━━━━━━━━━━━━
👰 BEAUTY & PROFESSIONALISM
Ethiopian cabin crew - recognized worldwide:
• Traditional habesha kemis with embroidery
• Warm Ethiopian hospitality (የኢትዮጵያ እንግዳ መስተንግዶ)
• Multilingual service
• "Our crew welcomes you home"
━━━━━━━━━━━━━━━━
💺 CLOUD NINE BUSINESS CLASS
• Lie-flat seats (180° recline)
• Ethiopian-inspired design
• Authentic cuisine (injera, doro wat in the sky!)
• Premium amenity kits
• 1000+ entertainment options
━━━━━━━━━━━━━━━━
💰 SMART PRICES
Real examples:
• Addis ↔ London: from $450
• Addis ↔ New York: from $650
• Addis ↔ Johannesburg: from $280
ShebaMiles: Earn miles on Star Alliance, upgrade to business, lounge access!
━━━━━━━━━━━━━━━━
🌟 WHY WE LEAD AFRICA
✅ 4-star Skytrax (highest in Africa)
✅ "Best Airline in Africa" 2023
✅ Star Alliance member
✅ Ethiopian-owned and operated (Africa's pride! 🇪🇹)
✅ 77+ years of excellence (since 1946!)
"የአፍሪካ ኩራት በሰማይ" (Africa's pride in the sky)
━━━━━━━━━━━━━━━━
✈️ FUN FACTS:
🤯 Only profitable airline in Africa for decades
🤯 Coffee ceremony by popular passenger demand!
🤯 Boeing 787 burns 20% less fuel (eco-friendly!)
🤯 Addis hub: 2,355m altitude - flight starts high! 🏔️
━━━━━━━━━━━━━━━━
📱 BOOK NOW:
ethiopianairlines.com | 24/7 support | Digital boarding
Pro tip: Book direct for best prices + full ShebaMiles!
━━━━━━━━━━━━━━━━
🇪🇹 MORE THAN AVIATION
🌍 Connecting Africa to the world
💪 African excellence
☕ Ethiopian culture in the skies
🎓 Training Africa's next pilots
"When you fly Ethiopian, you fly with Africa's best."
ከኢትዮጵያ ጋር ስትበር፣ ከአፍሪካ ምርጥ ጋር ነው።
━━━━━━━━━━━━━━━━
Ready to experience aviation the Ethiopian way? ✈️☕
━━━━━━━━━━━━━━━━
🌍 ETHIOPIA | ЭФИОПИЯ | ኢትዮጵያ
📱 Join us: @ethiopia telegram
#EthiopianAirlines#FlyEthiopian#AfricanAviation#CoffeeCeremony#AddisAbaba#EthiopianHospitality#Boeing787