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

TGINSIGHT SIMILAR POSTS

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

Изворен канал @pythonotes · Post #411 · 9 фев.

reload_flag="" if [[ -n "${DEBUG}" ]]; then reload_flag="--reload" fi if [[ -n "${WORKER_COUNT}" ]]; then workers=${WORKER_COUNT} else workers=2 fi gunicorn --workers ${workers} \ --bind 0.0.0.0:8000 \ ${reload_flag} main.wsgi Писали такие конструкции чтобы проверить наличие флага и сформировать команду правильно? На самом деле можно сделать тоже самое проще. Для этого используются операторы условной подстановки, доступные в оболочках семейства POSIX. :- для установки значений по умолчанию ${WORKER_COUNT:-2} Если переменная не объявлена, то будет дефолтное значение 2. :+ подставляет указанный текст, если переменная не пуста ${DEBUG:+--reload} Если что-то есть в переменной то распечатается текст после символа +, в противном случае - ничего. Удобно для опциональных флагов, как в нашем примере. Итого наш скрипт может выглядеть так: gunicorn --workers ${WORKER_COUNT:-2} \ --bind 0.0.0.0:8000 \ ${DEBUG:+--reload} main.wsgi Есть еще два оператора. := не только подставить дефолтное значение, но и присвоить его переменной, если она пуста # никаких переменных еще нет VAL1=${VAL2:=hello} # теперь доступны обе echo $VAL1 $VAL2 # hello hello :? остановить выполнение с ошибкой, если переменной нет. echo ${MISS:?is required} bash: MISS: is required Код выхода будет 1. #tricks#linux

Резултати

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

Пребарај: #aigame

当前筛选 #aigame清除筛选
G-AGENTS AI 🤖 | News

@gametynews · Post #648 · 30.12.2024 г., 22:09

Why grind when Gamety’s AI does the hard work for you? 👍 Real gamers never pause! Show off your creativity in our Meme Competition and win amazing rewards: Gamety's Zealy! Join the fun here: https://t.me/GametyPlatform_bot/Gamety?startapp #aigame Spread the hype! Like, RT, and drop a comment: Tweet🕊

Hashtags

G-AGENTS AI 🤖 | News

@gametynews · Post #634 · 24.12.2024 г., 16:12

🇱🇷Gamety's $200 Christmas Contests – Creative Gameplay & Meme Challenge!🎄 Celebrate this Christmas with two exciting and rewarding contests: 🔢Creative Gameplay Videos: Creative Gameplay Videos: Showcase your gaming skills on the Gamety app in a fun and unique way! Post your video on X and let the creativity flow. 🔢Meme Contest: Bring on the holiday laughter by creating and sharing your funniest Gamety-themed memes! Special for Christmas Holidays! ➡️Prize Pool: $200 ➡️10 winners per contest ➡️ Duration: Dec 25 - Jan 5 Share on X using hashtags #Gamety & #AIGame Make this Christmas more exciting with creativity, fun, and rewards! Join now and spread the holiday joy! Spread the hype! Like, RT, and drop a comment: Tweet🕊 📎Important Links: Website | X | Chat (FULL) | Indonesian Chat | African Chat | Vietnamese Chat | CIS Chat | Discord | Announcement | YouTube | Medium | New Bot

ПретходнаСтраница 1 од 3Следна