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

Резултати

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

Пребарај: #zerospread

当前筛选 #zerospread清除筛选
SLEX NEWS

@slex_io · Post #74 · 04.08.2023 г., 12:32

🚀 Experience the Freedom of Trading! 📉With SLEX, you can enjoy affordable trading with ZERO spread. Trade your favorite cryptocurrencies as BTC, ETH and XRP without worrying about high fees eating your profits!💱 💰Say goodbye to excessive trading costs and register on SLEX Now and get 20$ welcome bonus till official launch - 17 of August! 💼 #SLEX#Trading#ZeroSpread#CryptoExchange Email | Telegram | Reddit | Facebook | Instagram | Medium | Linkedin | Twitter

SLEX NEWS

@slex_io · Post #84 · 02.09.2023 г., 09:32

🚀 SLEX Hits $10M Daily Trading Volumes Just 3 Days In! 🚀 📈Get ready to witness history in the making! Just three days after the official launch of the SLEX exchange, we're thrilled to announce an incredible milestone: our daily trading volumes have soared to an impressive 10 000 000 USDT!📊 ❤️The energy and enthusiasm from traders and investors like you have propelled us to new heights. This phenomenal achievement underscores our platform's immense potential and our community's unwavering support!🌈 🤝We invite you to join SLEX platform, deposit your account, and enjoy zero-spread trading on the spot market! #SLEX#CryptoTrading#zerospread#SLEXtrading Email | Telegram | Reddit | Facebook | Instagram | Medium | Linkedin | Twitter