Skip to content

Instantly share code, notes, and snippets.

@shuantsu
Last active July 2, 2023 02:28
Show Gist options
  • Save shuantsu/18005fbf53429e8e71bd090e2354ba23 to your computer and use it in GitHub Desktop.
Save shuantsu/18005fbf53429e8e71bd090e2354ba23 to your computer and use it in GitHub Desktop.
Create Python App
#!/usr/bin/bash
log_file="/home/$USER/Projects/log.txt"
export LC_ALL="en_US.UTF-8"
exec > >(tee -a "$log_file") 2>&1
function create-python-app() {
echo "Creating and entering folder..."
mkdir $1
cd $1
echo "Activating environment..."
python -m venv venv
source venv/bin/activate
if [ "$#" -gt 1 ]; then
shift
pip install $@
pip freeze > requirements.txt
else
echo "No modules to install on pip."
fi
echo $'#!/usr/bin/env python' > app.py
chmod 777 app.py
code .
}
argumentos=$(zenity --entry --title "Informe um argumento" --text "Pasta e modulos opcionalmente")
zenity_exit_code=$?
if [ "$zenity_exit_code" -eq 1 ]; then
zenity --error --title "Operação cancelada" --text "A operação foi cancelada pelo usuário."
exit
fi
tail -f "$log_file" | zenity --text-info --width=800 --height=600 &
text_view_pid=$!
eval create-python-app $argumentos
kill "$text_view_pid"
rm "$log_file"
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment