TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #183 · 23 ное.

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

Hashtags

Резултати

Пронајдени 1 слични објави

Пребарај: #antonrupert

当前筛选 #antonrupert清除筛选

🎂 October 4 — Birthday of Anton Edward Rupert (1916 – 2006), South African businessman, philanthropist, and conservationist. 🏛 Museums in South Africa connected to his legacy: • Rupert Museum (Stellenbosch) — home to one of the most important private collections of 20th-century South African art, assembled by Rupert and his wife Huberte. • La Motte Museum — located on the family’s wine estate, known for its collection of Pierneef works and Cape Dutch cultural heritage. • Hester Rupert Art Museum (Graaff-Reinet) — named after Rupert’s mother, showcasing works of South African artists from the mid-20th century. • Jan Rupert Art Centre (Graaff-Reinet) — a venue for rotating exhibitions under the Rupert Art Foundation. • Franschhoek Motor Museum 🚗 — a world-class collection of automobiles, motorcycles, and bicycles spanning over 100 years of motoring history, founded by Rupert and later expanded by his son Johann. 🕊 Anton Rupert left a remarkable cultural and environmental legacy, bridging business, art, and nature conservation. #AntonRupert#SouthAfrica#RupertMuseum#Art#Culture#Heritage#Philanthropy#MotorMuseum