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 слични објави

Пребарај: #antd

当前筛选 #antd清除筛选
GitHub Trends

@githubtrending · Post #15034 · 07.08.2025 г., 11:30

#javascript#antd#music#music_player#nodejs#react#react_router#redux#webapp#webpack Copper Bell is a free website app focused on listening to music. It offers many songs and has a simple, clean design that makes it easy to find and play your favorite music. You can search for songs, make playlists, read scrolling lyrics, save songs, and create your own song lists. It does not have live broadcasts, social features, or ads, so there are no distractions and you get a pure music experience. You can use it on any modern web browser without installing anything. It works on many devices, including tablets. This way, you can enjoy music, manage your songs, and discover new tunes easily anytime and anywhere. https://github.com/enzeberg/tonzhon-music

GitHub Trends

@githubtrending · Post #14894 · 02.07.2025 г., 11:30

#typescript#antd#antd_design#docker#go#golang#guacamole#rdp#react#ssh#vnc Next Terminal is a simple and secure system that lets you access and manage remote computers using protocols like RDP, SSH, VNC, Telnet, and HTTP. It is designed for businesses to record sessions, track audits, and help with compliance reporting, making IT management easier and safer. Using Next Terminal can improve security by monitoring remote access and help ensure your company meets regulatory requirements. It is user-friendly and supports multiple connection types, which saves time and effort in managing remote systems securely. Consulting your IT administrator before use is recommended for safe deployment. This tool benefits you by enhancing control and oversight of remote IT activities. https://github.com/dushixiang/next-terminal