Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master #23

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Linguagem Utilizada para Desenvolver a Aplicação
language: python

# Versão que a aplicação suporta.
python:
- "3.7"

# Faz a instalação com Sudo, para ter privilégio de Super Usuário.
sudo: required

# Instalação de Módulos que são necessários para a Aplicação.
install:
- pip install flask

# Defini o script de Teste que deve rodar toda vez que o código for alterado.
script:
- python test.py

# Defini que o processo de Deploy será na Plataforma Heroku. É necessário informar o nome da APP criada no Heroku
provider: heroku
app: jeferson-beta
api_key:
secure: dku10lQMRzv2v7rfW9sYU6qgf/iPZ5+VN6Fsn//STuRZxd8qCcWAc0FCIXC+k7KNEUHzfWSHFFlqYjjlvqwKXEvtk9mksTDTnbHBdD8c2K/vfw2xhk2cjveJROXftUaopI5QSHXdm+5zi8C2Qk/LwLgV8A9YbACs+/u0nShRVaepBSRDY4Ex0rdenzZ9cRdQzc4foPW8Kpa90OISbRVT/sVjDk7G6a9h15dn9+unrmmrHHEl3iXxUolZTCtNc6UX9IlxI7MgZDuy2U5zKnHXx3yqieCyNYWP7ntWUgOwnpVNMo/GPdPgBn4EW4A8BHXW1ojID5DjWbX+4eY6/bHDG0DM5tOjADFrcKaWwkvB/gOYXDmj01Pl48bZ+GaOtvyxgdwD5GEtVHZG2QbsJiYOQl1P9n+AM+uOxJaCmtdj7RwKdtGfgd4wMKi36VxVhdpdXiwe4SIZ9v9pCsCdMZFLvHDPAGXFJhrf82krxLPU/kFH94LiaNsarm+poU4nr0gDXNJVExOz5AfophpZEnD3JcmFBcS0Rf+JBwUgMdIYgVkKWJZMC1v2jpaEWC8xevLy3yHBqTCSVntfU3UlxAdS2LOo9PAsgAp2sk+PHvGeT3F6wpcIuAFc7hNEqlRz76v/Ydi6L6V/evxwjoOQi7dhWuMJ/p4V5nTtoaEuigWXAi4=
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Trilha DevOps da 4Linux

<!-- Altere a Flag abaixo com sua URL do seu usuário do Github -->
<!--
![Pipeline Status](https://github.com/<USER>/DevOpsLab-HelloWorld/actions/workflows/pipeline.yml/badge.svg)
-->

## Aplicação criada para exemplificar o Ciclo de uma PipeLine DevOps
![Pipeline Status](https://github.com/Jefersonbeta/DevOpsLab-HelloWorld/actions/workflows/pipeline.yml/badge.svg)

[![Build Status](https://app.travis-ci.com/Jefersonbeta/DevOpsLab-HelloWorld.svg?branch=master)](https://app.travis-ci.com/Jefersonbeta/DevOpsLab-HelloWorld)

## Aplicação criada para exemplificar o Ciclo de uma PipeLine DevOps2


Para maiores informações acesse o [Site da 4Linux](https://www.4linux.com.br/cursos/devops)
3 changes: 3 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
def index():
return render_template('index.html')

@app.route("/cappuccino")
def cappuccino():
return render_template('cappuccino.py')

if __name__ == '__main__':
app.run(debug=True)
25 changes: 25 additions & 0 deletions langs/eng.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[translation]
language_name = English

enter_cup_size = Enter cup size (ml):
enter_cups = Enter how many cups:

ingredients = Ingredients for {cup_qnt} cups of {cup_size}ml:{n}
[+] {soup_spoons} soup spoons of cappuccino.
[+] {water}ml of water.
[+] {milk}ml of milk.{n}

how_to_prepare = How to prepare:{n}
[!] Warm up {water}ml of water (don't let it boil!).
[!] Add {soup_spoons} soup spoons of cappuccino and mix it.
[!] Take that mix and put it in the fridge until it gets cold.
[!] After it got cold, put it in the blender and blend it with {milk}ml of milk.
[!] All set, your iced cappuccino is ready to drink!!{n}

observation = Observations:
[+] The blender leaves it creamier.
[+] Use metal, wood or paper straws. We have to save the turtles SZ.
[!] Recipe by: Rafa Ballerini!
[!] Script by: Arthur Ottoni{n}

exit = Press ENTER to quit
25 changes: 25 additions & 0 deletions langs/por.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[translation]
language_name = Português

enter_cup_size = Digite o tamanho do copo em ml:
enter_cups = Digite a quantidade de copos:

ingredients = Ingredientes para {cup_qnt} copos de {cup_size}ml:{n}
[+] {soup_spoons} colheres de pó de capuccino. (Tamanho_da_colher = "sopa")
[+] {water}ml de água.
[+] {milk}ml de leite.{n}

how_to_prepare = Modo de Preparo:{n}
[!] Esquente {water}ml de água (sem deixar ferver!).
[!] Adicione {soup_spoons} colheres (de sopa) de pó de capuccino e misture bem.
[!] Pegue essa mistura e coloque na geladeira, até que esfrie.
[!] Após esfriar, coloque no liquidificador e bata junto com {milk}ml de leite.
[!] E pronto, seu capuccino gelado está pronto para beber!!{n}

observation = OBS:
[+] O liquidificador deixa mais cremoso
[+] Use canudo de metal, bambu, madeira e papel. Temos que salvar as tartaruguinhas SZ.
[!] Receita by: Rafa Ballerini!
[!] Script by: Arthur Ottoni!

exit = Pressione ENTER para sair...
84 changes: 84 additions & 0 deletions templates/cappuccino.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import os

from configparser import ConfigParser, SectionProxy

def clear_screen():
os.system('cls' if os.name == 'nt' else 'clear')

def get_languages() -> dict:
languages = {}
config = ConfigParser()
for f in os.listdir("./langs/"):
if "ini" in f:
config.read("./langs/" + f)
languages[f.split(".")[0]] = config["translation"]["language_name"]
return languages

def get_language(languages: dict) -> SectionProxy:
config = ConfigParser()
print("Available languages: ")
for k, v in languages.items():
print(f" [-] {k} -> {v}")
while True:
language = input('Choose a language: ').lower()
if language in languages:
config.read(f"./langs/{language}.ini")
return config["translation"]
else:
print("Invalid language key! Try again...")

def get_message(message: str, language: SectionProxy) -> str:
return language[message].replace("{n}", "\n")

def get_spoons(cup_qnt: float) -> float:
return (14 * cup_qnt) / 7

def get_water(cup_qnt: float, cup_size: float) -> float:
if cup_qnt > 1:
return (float(14.285714285714) * cup_size / 100) * cup_qnt
else:
return cup_size / 7

def get_milk(cup_qnt: float, cup_size: float) -> float:
if cup_qnt > 1:
return (float(85.714285714286) * cup_size / 100) * cup_qnt
else:
return cup_size - get_water(cup_qnt, cup_size)

def show_recipe(cup_qnt: float, cup_size: float, language: SectionProxy) -> None:
text = get_message("ingredients", language)\
.replace("{cup_qnt}", str(cup_qnt))\
.replace("{cup_size}", str(cup_size))\
.replace("{soup_spoons}", f"{get_spoons(cup_qnt):.0f}")\
.replace("{water}", f"{get_water(cup_qnt, cup_size):.2f}")\
.replace("{milk}", f"{get_milk(cup_qnt, cup_size):.2f}")
print(text)

def show_steps(cup_qnt, cup_size, language) -> None:
text = get_message("how_to_prepare", language) \
.replace("{soup_spoons}", f"{get_spoons(cup_qnt):.0f}") \
.replace("{water}", f"{get_water(cup_qnt, cup_size):.2f}") \
.replace("{milk}", f"{get_milk(cup_qnt, cup_size):.2f}")
print(text)
print(get_message("observation", language))

def main():
clear_screen()

languages = get_languages()
language = get_language(languages)

clear_screen()

cup_size = float(input(get_message("enter_cup_size", language) + " "))
cup_qnt = int(input(get_message("enter_cups", language) + " "))

clear_screen()

show_recipe(cup_qnt, cup_size, language)
show_steps(cup_qnt, cup_size, language)

input(get_message("exit", language))

if __name__ == '__main__':
main()
2 changes: 1 addition & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</head>

<body>
<div class="alert">Escreva uma Mensagem para o Cabecalho da Pagina.</div>
<div class="alert">Minha pagina (DevOps 3.0)</div>

<div class="container">
<div class="logo">
Expand Down
2 changes: 1 addition & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def test_conteudo(self):
result = self.app.get('/')

# verifica o retorno do conteudo da pagina
self.assertRegex(result.data.decode(), "Escreva uma Mensagem para o Cabecalho da Pagina.")
self.assertRegex(result.data.decode(), "Minha pagina (DevOps 3.0)")


if __name__ == "__main__":
Expand Down