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
⭐️#Nodepay Airdrop: Learn To ai And Earn #Airdrop
1. Register At NodePay
2. download the chrome extension in. pc/android (kiwi/mises browser)
3. login with your account
4. Browse Internet to earn
5.Enjoy
@AirdropGoldChannel
#Nodepay Airdrop: Learn To ai And Earn #Airdrop
1. Register
2. download the chrome extension in. pc/android (kiwi/mises browser)
3. login with your account
4. Browse Internet to earn
5.Enjoy
NodePay Airdrop Listing Date: Latest 2024 Release Details
Discover when NodePay airdrop listing date will be announced and stay updated on this promising DeFi project's token distribution and exchange availability in 2024 Contact admin if you have any questions : @Riley_Fe
#airdrops#bitcoin#blockchain#crypto#Nodepay#technology
When Will New Nodepay Listing Date Be Announced?
Discover when Nodepay listing date will be announced and learn about this innovative payment platform's journey toward public trading. Stay updated on market entrance details Contact admin if you have any questions : @Riley_Fe
#airdrops#bitcoin#blockchain#crypto#Nodepay#technology
NodePay Airdrop Date: New Token Distribution Info
Stay informed about the nodepay airdrop date and distribution schedule. Get essential details on eligibility criteria, token allocation, and how to participate in this upcoming crypto event Contact admin if you have any questions : @Riley_Fe
#airdrops#bitcoin#blockchain#crypto#Nodepay#technology
NodePay Airdrop: Claim Free Crypto Rewards Now
Join the NodePay airdrop and earn free crypto rewards by participating in simple tasks. Get your share of tokens by completing social media activities and community engagement Contact admin if you have any questions : @Riley_Fe
#airdrops#bitcoin#blockchain#crypto#Nodepay#technology
NodePay Airdrop Listing Date: New Upcoming 2024
Stay updated on the nodepay airdrop listing date and upcoming schedule for 2024. Get ready to participate in this highly anticipated token distribution event and secure your rewards Contact admin if you have any questions : @Riley_Fe
#airdrops#blockchain#crypto#defi#Nodepay#technology
AI Startups Secure Major Funding Deals
🚀
1. Inferix: Decentralized GPU network raising $2.60M led by DePIN X.
2. PoSciDonDAO: Receives undisclosed funding from BoostVC for personalized medicine.
3. Skynet: Autonomous AI agent protocol secures $1.20M in Pre-seed funding.
4. Nodepay: AI training decentralized network raises $7M, led by IDG Capital and MVP.
5. The Grid: Web3 metadata directory collects $624K in Angel funding.
For more on the funding rounds: source
#AI#Funding#Inferix#PoSciDonDAO#Skynet#Nodepay#TheGrid#DeFi#Crypto#VC
January Listing 🔥
✅#Nodepay: 6 January
✅#MomoAi: 6 January
✅#Xterio: 8 January
✅#Sidekick : 8 January
✅ $Vertus :13 January
✅#Seed : 15 January
✅#Xcoin : 20 January
✅#Tapswap : 23 January
✅#Wcoin : 25 January
✅#CommunityGaming : 28 January
Unofficial Listing
✅#PAWS
✅#UXUY
✅#Yuligo
✅#MemeWar
✅#DuckChain
✅#Celia
Stay connected