From f605aed64ca12ed8edc84eaf4c4b2f23572c2452 Mon Sep 17 00:00:00 2001 From: Gustavo Soares Date: Sun, 3 Dec 2023 12:59:18 -0300 Subject: [PATCH] fix lint --- .github/workflows/pylint.yml | 4 ++-- README.md | 3 +++ consumer.py | 7 +++++-- producer.py | 14 +++++++++----- requirements.txt | 3 ++- 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 383e65c..e29ff72 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10"] + python-version: ["3.11"] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} @@ -17,7 +17,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install pylint + pip install -r requirements.txt - name: Analysing the code with pylint run: | pylint $(git ls-files '*.py') diff --git a/README.md b/README.md index 4c260aa..1b1f7d8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # Simple Queue +[![Pylint](https://github.com/GussSoares/simple_queue/actions/workflows/pylint.yml/badge.svg?branch=main)](https://github.com/GussSoares/simple_queue/actions/workflows/pylint.yml) + + Este projeto consiste em uma implementação simples apresenta o funcionamento de dois serviços. - [Producer](/producer.py) diff --git a/consumer.py b/consumer.py index df35d04..7a72ef6 100644 --- a/consumer.py +++ b/consumer.py @@ -1,3 +1,6 @@ +"""Consumer file +""" + import os import json import time @@ -19,8 +22,8 @@ ) for msg in messages: parse_message = json.loads(msg.body) - + message = json.loads(parse_message['Message'])['message'] - + print(f"Mensagem recebida: {message}") msg.delete() diff --git a/producer.py b/producer.py index 8abe4b6..6b562fb 100644 --- a/producer.py +++ b/producer.py @@ -1,3 +1,5 @@ +"""Producer file +""" import json import os @@ -10,15 +12,17 @@ def create_queue(): + """Create initial sns topic and sqs queue + """ sns_sqs_list = [ 'simple-queue', ] - sns = local_boto3(localstack_host='localstack').resource("sns") - sqs = local_boto3(localstack_host='localstack').resource("sqs") + _sns = local_boto3(localstack_host='localstack').resource("sns") + _sqs = local_boto3(localstack_host='localstack').resource("sqs") sns_client = local_boto3(localstack_host='localstack').client('sns') for sns_sqs in sns_sqs_list: - sns.create_topic(Name=sns_sqs) - sqs.create_queue(QueueName=sns_sqs) + _sns.create_topic(Name=sns_sqs) + _sqs.create_queue(QueueName=sns_sqs) sns_client.subscribe( TopicArn=f'arn:aws:sns:us-east-1:000000000000:{sns_sqs}', Protocol='sqs', @@ -31,7 +35,7 @@ def create_queue(): while True: sns = boto3.client('sns') topic = json.loads(os.environ.get('COPILOT_SNS_TOPIC_ARNS')) - + message = {"message": f'Eu sou o produtor! Esta é a mensagem {uuid.uuid4()}!'} response = sns.publish( TopicArn=topic.get('simple_queue'), diff --git a/requirements.txt b/requirements.txt index 907c6f1..fe5f85a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -localstack-client==1.39 \ No newline at end of file +localstack-client==1.39 +pylint==3.0.2 \ No newline at end of file