Skip to content

Commit

Permalink
Merge pull request #1 from mamei-tech/py3-with-requests-bs4
Browse files Browse the repository at this point in the history
add validation of the configuration file
  • Loading branch information
kmilodenisglez authored Feb 17, 2024
2 parents 6664148 + e319ad0 commit 2e9a359
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 9 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import argparse
import os
import sys

import requests
Expand All @@ -9,7 +10,12 @@
import configparser

config = configparser.ConfigParser()
config.read('config.cfg')

if os.path.exists('config.cfg'):
config.read('config.cfg')
else:
print("Config file does not exist or could not be read.")
sys.exit(1)


def execute_menu(parser):
Expand Down Expand Up @@ -168,8 +174,8 @@ def validate_config():
_info_options = ['attr_uuid', 'logger_id', 'wlanuserip']

if all(option in config.options('CREDENTIAL') for option in _cred_options) and \
all(option in config.options('INFO') for option in _info_options) and \
config.get('CREDENTIAL', 'username') and config.get('CREDENTIAL', 'password'):
all(option in config.options('INFO') for option in _info_options) and \
config.get('CREDENTIAL', 'username') and config.get('CREDENTIAL', 'password'):
return True
return False

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nauta portal"
version = "0.1.0"
version = "0.2.0"
description = "Access to the Nauta Portal"
authors = ["kmilo <kmilo.denis.glez@yandex.com>, dany <danif-mena@yandex.com>"]
readme = "README.md"
Expand Down

0 comments on commit 2e9a359

Please sign in to comment.