A learning-focused repository for Python automation, API integration, networking, and PostgreSQL database workflows tailored to DevOps and infrastructure practitioners. It contains sample scripts for Python fundamentals, file operations, HTTP APIs, scheduling, web scraping, socket programming, and database automation.
Target Audience: DevOps Engineers, Python Developers, Automation Specialists
Skill Level: Beginner to Intermediate
Python Version: 3.12+
devops-python/
├── 1-hello.py
├── 2-fileread.py
├── 2-filewrite.py
├── 3-fileoperations.py
├── 4-ifelse.py
├── 4-loops.py
├── 4-break-continue.py
├── 4-oddeven.py
├── 5-functions.py
├── 5-modules.py
├── math_operations.py
├── networking/
│ ├── 6-networking-client.py
│ ├── 6-networking-request.py
│ ├── 6-networking-scap.py
│ └── 6-networking-server.py
├── sockets/
│ ├── client.py
│ ├── server.py
│ └── soc.py
├── apis/
│ ├── api-ex.py
│ └── api-req.py
├── automation/
│ ├── getlinks.py
│ ├── par.py
│ ├── par2.py
│ ├── task_schedule.py
│ └── output.json
├── python-postgres/
│ └── postgres-python.py
├── requirements.txt
├── devops-python-venv/
├── arjun.txt
└── README.md
| File | Topic | Key Concepts |
|---|---|---|
1-hello.py |
Basic Syntax | Variables, data types, print output |
2-fileread.py |
File Reading | File opening, reading, closing |
2-filewrite.py |
File Writing | Writing text files, file persistence |
3-fileoperations.py |
File Utilities | Rename, delete, and filesystem checks |
4-ifelse.py |
Conditionals | If/elif/else logic, boolean evaluation |
4-loops.py |
Iteration | For loops, while loops, sequence iteration |
4-break-continue.py |
Loop Control | break, continue, loop termination |
4-oddeven.py |
Conditional Logic | Even/odd checks and branching |
| File | Purpose |
|---|---|
5-functions.py |
Defining and calling functions, return values |
5-modules.py |
Importing modules and using shared utilities |
math_operations.py |
Mathematical helper functions |
| File | Purpose |
|---|---|
networking/6-networking-client.py |
TCP client socket communication |
networking/6-networking-server.py |
TCP server socket communication |
networking/6-networking-request.py |
HTTP request handling example |
networking/6-networking-scap.py |
Packet analysis with Scapy |
sockets/client.py |
Socket client implementation |
sockets/server.py |
Socket server implementation |
sockets/soc.py |
Socket utilities and helpers |
| File | Purpose |
|---|---|
apis/api-ex.py |
HTTP GET request example using requests |
apis/api-req.py |
HTTP PUT and DELETE request examples |
automation/getlinks.py |
Web scraping with BeautifulSoup |
automation/par.py |
JSON parsing and manipulation |
automation/par2.py |
Additional parsing utilities |
automation/task_schedule.py |
Scheduled task execution with schedule |
| File | Purpose |
|---|---|
python-postgres/postgres-python.py |
PostgreSQL connection and database automation using psycopg2 |
- Python: 3.12 or higher
- pip: Python package manager
- Virtual environment: Recommended for dependency isolation
-
Clone the repository:
git clone <repository-url> cd devops-python
-
Create and activate a virtual environment:
python3.12 -m venv devops-python-venv source devops-python-venv/bin/activate # Linux/macOS # or devops-python-venv\Scripts\activate # Windows
-
Install dependencies:
pip install -r requirements.txt
-
Install optional extras used by some examples:
pip install beautifulsoup4 schedule psycopg2-binary
python 1-hello.py
python 2-fileread.py
python 5-functions.pypython apis/api-ex.py
python apis/api-req.pypython automation/getlinks.py
python automation/par.py
python automation/task_schedule.pypython python-postgres/postgres-python.pypython networking/6-networking-server.py
python networking/6-networking-client.pypython sockets/server.py
python sockets/client.pyVariables & Data Types
- Integers, floats, strings
- Variable assignment and printing
- Basic expressions and formatting
File Operations
- Open, read, write, and close files
- File system checks
- Data persistence
Control Structures
- Conditional branching (
if,elif,else) - Iterative loops (
for,while) - Loop control with
breakandcontinue
Functions
- Defining reusable functions
- Passing arguments and returning values
- Reuse across scripts
Modules
- Built-in and custom module imports
- Encapsulation of shared logic
- Code organization and reuse
API & Automation
- REST API calls with
requests - JSON serialization and parsing
- HTML parsing with BeautifulSoup
- Task scheduling with
schedule
Database Automation
- PostgreSQL connection management
- Query execution and result handling
- Database creation and metadata inspection
Network Programming
- TCP socket communication
- Server/client lifecycle management
- Data send/receive workflows
- Packet inspection with Scapy
The devops-python-venv/ virtual environment contains:
- Python 3.12 interpreter
- pip package manager
- Standard build tools such as
setuptoolsandwheel
requestsbeautifulsoup4schedulepsycopg2-binaryscapy
✅ Modular code organization
✅ Proper file handling
✅ Function reuse and abstraction
✅ API request workflows
✅ JSON parsing and automation scripting
✅ Scheduled task execution
✅ PostgreSQL database automation
✅ Socket-based network communication
✅ Clean dependency and environment management
- Start with
1-hello.py - Continue through file I/O and control flow examples
- Learn function and module structure in
5-functions.pyand5-modules.py - Practice API and automation flows in
apis/andautomation/ - Explore sockets and networking scripts in
networking/andsockets/ - Review the database automation example in
python-postgres/postgres-python.py
| Concept | Files | Level |
|---|---|---|
| Variables & Types | 1-hello.py | Beginner |
| File I/O | 2-fileread.py, 2-filewrite.py, 3-fileoperations.py | Beginner |
| Conditionals | 4-ifelse.py, 4-oddeven.py | Beginner |
| Loops | 4-loops.py, 4-break-continue.py | Beginner |
| Functions | 5-functions.py | Beginner |
| Modules | 5-modules.py, math_operations.py | Intermediate |
| HTTP APIs | apis/api-ex.py, apis/api-req.py | Intermediate |
| Automation | automation/*.py | Intermediate |
| PostgreSQL | python-postgres/postgres-python.py | Intermediate |
| Networking | networking/, sockets/ | Intermediate |
- Ensure
arjun.txtexists for file I/O examples. - Run server scripts before client scripts in networking examples.
- Update PostgreSQL credentials in
python-postgres/postgres-python.pybefore execution. - Install optional packages when using BeautifulSoup, scheduling, or PostgreSQL examples.
- Some network and Scapy examples may require elevated permissions.
| Issue | Solution |
|---|---|
ModuleNotFoundError |
Activate virtual environment and install dependencies |
FileNotFoundError |
Confirm the working directory and file path |
ConnectionRefusedError |
Start the network server before the client |
| PostgreSQL connection error | Verify host, port, user, and password |
| Permission denied | Use a non-privileged port or run with elevated privileges |
- Python Documentation
- Requests Documentation
- BeautifulSoup Documentation
- psycopg2 Documentation
- Scapy Documentation
- Socket Programming Guide
Arjun
DevOps Python Learning Project
This project is provided as-is for educational purposes.
Last Updated: May 2026
Status: Active Learning Project