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
🔥NEW RELEASE🔥
😁My Evolution Your Revolution ADCC 2024 By Gordon Ryan😁
➡️Take a front-row seat into the mind of the most dominant no-gi grappler in history. In My Evolution, Your Revolution: ADCC 2024, Gordon Ryan peels back the curtain on his historic 2024 ADCC performance — and gives you the exact blueprint that made him the most successful ADCC competitor of all time.
➡️This is more than just match footage. This is the most in-depth instructional Gordon has ever released, combining technical mastery, strategic commentary, and championship mindset.
$197😍$14.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
🌈UFC Picks
👑MasterClass
✈️@bjjfanaticsinstructionals
#GordonRyan#NewWave#NoGi#ADCC
💁♀️Buy
💁♀️
🔥NEW RELEASE🔥
😁Dynamically Combining Inside & Outside Passing by Jason Rau😁
➡️Unlock a truly adaptive guard passing game with Jason Rau’s groundbreaking system that seamlessly blends tight inside pressure passing with loose outside movement.
➡️Learn how to fluidly switch between styles depending on your opponent’s reactions, making your passing game feel unpredictable, overwhelming, and unshakable.
$127😍$11.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
🌈UFC Picks
👑MasterClass
✈️@bjjfanaticsinstructionals
#JasonRau#Passing#NoGi#ADCC
💁♀️Buy
💁♀️
😁The 6 Most Essential Skills: Base Top By Dima Murovanni😁
➡️Are you ready to take your Brazilian Jiu-Jitsu to the next level? The 6 Most Essential Skills: Base Top by B Team’s head coach, Dima Murovanni, is the perfect roadmap to accelerate your growth on the mats.
➡️With years of experience coaching the world’s top grapplers, he’s distilled his insights into a series that answers the most common question he gets: How can I improve my BJJ fast?
$127😍$11.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
👑MasterClass
✈️@bjjfanaticsinstructionals
#DimaMurovanni#Passing#NoGi#ADCC
💁♀️Buy
💁♀️
😁Gringo Guard Passing Knee Shield by Faris Ben-Lamkadem😁
➡️In Gringo Guard Passing: Knee Shield, elite competitor and coach Faris Ben-Lamkadem breaks down a complete system for dismantling the knee shield with precision, pressure, and purpose.
➡️This isn’t just a collection of random techniques — it’s a structured roadmap that shows you how to shut down frames, neutralize underhooks, and flow seamlessly into dominant passing positions.
$79😍$9.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
👑MasterClass
✈️@bjjfanaticsinstructionals
#FarisBenlamkadem#Passing#NoGi#ADCC
💁♀️Buy
💁♀️
🔥NEW RELEASE🔥
😁Pillars Of Defense: Guillotines By Gordon Ryan😁
➡️Unlock the secrets to defending one of the most dangerous and common submissions in No-Gi Brazilian Jiu-Jitsu—the Guillotine—with Gordon Ryan, the most accomplished No-Gi competitor in the history of the sport.
➡️With years of experience under the guidance of John Danaher, Gordon has developed an unparalleled skill set in both executing and teaching BJJ techniques.
➡️In this highly anticipated instructional, Gordon dives deep into the art of defending against the guillotine choke, providing you with the tools and strategies to maintain position, escape, and turn the tables on your opponent.
$349😍$24.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
🌈UFC Picks
👑MasterClass
✈️@bjjfanaticsinstructionals
#GordonRyan#ADCC#NoGi#Guillotines
💁♀️Buy
💁♀️
🐈⬛NEW RELEASE
🐈⬛
🐈⬛Woj Lock 2.0 - Completing The Leg Lock Game by Chris Wojcik
🐈⬛
🐈⬛Chris Wojcik isn’t just a leg locker—he’s one of the most innovative finishers in modern grappling, known for catching high-level opponents with his signature “Woj Lock” system.
🐈⬛From foundational concepts to advanced 50/50 systems, cross ashi, inside ashi, and beyond—Wojcik shows you how to connect entries, control, and finishing mechanics into one seamless chain.
$79
🐈⬛$9.99
🐈⬛
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱📱
💰Submeta FOR FREE
👑MasterClass
✈️@bjjfanaticsinstructionals
#ChrisWojcik#Submissions#NoGi#ADCC
🐈⬛Buy
🐈⬛
😁Z locks and the Diagonal Ashi:
the Complete Guide by Robert Degle😁
➡️More than any other leglocking strategy the Diagonal Ashi and Z lock allow us to remain safe from counter leglocks and solve the problem of defensive hip movement by allowing us to adhere to the principle of double trouble while we execute devastating leglock submissions.
$97😍$9.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
👑MasterClass
✈️@bjjfanaticsinstructionals
#RobertDegle#Submissions#NoGi#ADCC
🔥NEW RELEASE🔥
😁Dynamically Taking The Back (Turtle) by Jason Rau😁
➡️Unlock the Ultimate Back-Taking Blueprint from Turtle with Dynamically Taking the Back (Turtle) — the revolutionary course by elite BJJ black belt Jason Rao, designed to take your control, timing, and back-attack game to a whole new level.
➡️From gripping strategies and handfighting to dynamic movement and pressure mechanics, you’ll learn how to turn every turtle situation into a back take with confidence and precision.
$99😍$9.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
👑MasterClass
✈️@bjjfanaticsinstructionals
#JasonRau#Turtle#NoGi#ADCC
💁♀️Buy
💁♀️
😁The 6 Most Essential Skills: Connection Top By Dima Murovanni😁
➡️The latest installment in Dima Murovanni’s best-selling “6 Most Essential Skills” series dives deep into what many elite grapplers consider the cornerstone of effective guard passing: connection from the top.
➡️In "Connection – Top", Dima breaks down how to establish and maintain dynamic connection while staying mobile, heavy, and in complete control.
$127😍$11.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
👑MasterClass
✈️@bjjfanaticsinstructionals
#DimaMurovanni#Control#NoGi#ADCC
💁♀️Buy
💁♀️
🔥DEAL OF THE WEEK🔥
😁Systematically Attacking The Arm Bar by Gordon Ryan😁
➡️DEAL ENDS ON APRIL 7TH
$349😍$9.99😍
❗️Channel Info and FAQ (MUST CHECK BEFORE BUY)❗️
📱Payment: 📱📱📱
💰Submeta FOR FREE
🌈UFC Picks
👑MasterClass
✈️@bjjfanaticsinstructionals
#GordonRyan#ADCC#Submission#FloGrappling
💁♀️Buy
💁♀️