Skip to content

Avinjay/Python_Assignments

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Assignments

This repository contains Python scripts developed as part of a DevOps certification. The assignments cover various functionalities, including configuration file parsing, MongoDB integration, system monitoring, and password strength validation.


Project Structure

  • Configuration.txt - Stores database and server configurations.
  • Configuration_mongo.txt - Stores MongoDB connection URI.
  • Confpar.py - Parses configuration files and inserts data into MongoDB.
  • CPU.py - Monitors CPU usage and triggers alerts when usage exceeds a set threshold.
  • Sp.py - Checks password strength based on predefined security criteria.

Installation

  1. Install Python

    Ensure Python is installed on your system (Python 3.6 or higher is recommended).

    • Download and install from the official Python website.
    • Verify installation by running:
      python --version
  2. Clone the repository

    git clone git@github.com:Avinjay/Python_Assignments.git

    cd Python_Assignments

Install dependencies

pip install -r requirements.txt

Usage

  1. Configuration Parser (Confpar.py) INI File and ConfigParser: INI files are plain-text configuration files consisting of sections, each containing key-value pairs. The Python configparser module provides a ConfigParser class to read and parse INI files.

  2. Constructor and Nested Dictionary Usage: The script uses the ConfigParser() constructor to create a parser object. The parsed data is converted to a nested dictionary structure where each section in the INI file is represented as a dictionary of key-value pairs. This allows easy manipulation of the configuration as a Python object.

python Confpar.py

This script reads the configuration from Configuration.txt, inserts the data into MongoDB, and fetches the stored data for display.

Input File

image

Output

image

  1. CPU Monitoring (CPU.py) psutil Module: psutil (Python System and Process Utilities) is a cross-platform library for retrieving information on system utilization, such as CPU, memory, disk, and network usage. The cpu_percent(interval=1) method is used to monitor CPU usage at 1-second intervals.

python CPU.py

The script continuously monitors CPU usage and raises an alert if the usage exceeds a defined threshold (15% in this case).

The program takes threshold from user & throws alert when CPU breaches that threshold, it also throws keyboard interruption error image

  1. Password Strength Checker (Sp.py)

re Module: The re (regular expression) module is used for pattern matching in strings. The script uses the compile method to precompile regular expressions for uppercase letters, lowercase letters, digits, and special characters to improve performance. The search method checks whether the provided password contains characters that match the specified patterns.

python Sp.py

Length, Digit & Special Chararacter Validation

image

Digit Validation image

Success Pattern

image

About

These are python programs given as assignments, part of Dev Ops certification

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages