├── DB_Automation.py ├── Github.py ├── Org_Automation ├── Compare_list.py ├── Endpoint_Hit.py ├── Endpoint_hit2.py └── List_with_sort.py ├── Python-Speech ├── FILE_HANDLING.py ├── SLIDES_PYTHON.py ├── SPEECH.py ├── Text.txt ├── dummypdf.pdf ├── newText.txt └── test.py ├── Python ├── .DS_Store ├── Marks.csv ├── NEWS.py ├── OTP_VERIFICATION.py ├── PASSWORD_GENERATOR.py ├── Python_Cars_class.py ├── QR_CODE_WORKING.py ├── SCRAPE_WEBSITE_WORKING.py ├── finalmail.py ├── myyoutube.svg ├── news.csv └── template.txt └── kubernetes_Access.py /DB_Automation.py: -------------------------------------------------------------------------------- 1 | import mysql.connector 2 | # Establish the MySQL database connection 3 | def connect_to_mysql(host, user, password, database): 4 | try: 5 | connection = mysql.connector.connect( 6 | host=host, 7 | user=user, 8 | password=password, 9 | database=database 10 | ) 11 | print("Connection established successfully.") 12 | return connection 13 | except mysql.connector.Error as err: 14 | print(f"Error: {err}") 15 | return None 16 | 17 | # Function to fetch data from a table 18 | def fetch_data_from_table(connection, query): 19 | cursor = connection.cursor(dictionary=True) # Using dictionary cursor for easier access to columns by name 20 | try: 21 | cursor.execute(query) 22 | result = cursor.fetchall() # Fetch all rows 23 | return result 24 | except mysql.connector.Error as err: 25 | print(f"Error: {err}") 26 | return None 27 | finally: 28 | cursor.close() 29 | 30 | # Function to sort the data (by a specific column) 31 | def sort_data(data, sort_by_column): 32 | # Sort the data based on the column name (e.g., 'age') 33 | return sorted(data, key=lambda x: x[sort_by_column]) 34 | 35 | # Main function to run the process 36 | def main(): 37 | # MySQL connection parameters 38 | host = 'localhost' # Change this to your MySQL host 39 | user = 'root' # Change this to your MySQL username 40 | password = 'yourpassword' # Change this to your MySQL password 41 | database = 'yourdatabase' # Change this to your MySQL database name 42 | 43 | # Connect to MySQL database 44 | connection = connect_to_mysql(host, user, password, database) 45 | 46 | if connection: 47 | # Example query to get data from a table (change 'your_table' to your actual table name) 48 | query = "SELECT * FROM your_table" 49 | 50 | # Fetch the data 51 | data = fetch_data_from_table(connection, query) 52 | 53 | if data: 54 | print("Original Data:") 55 | for row in data: 56 | print(row) 57 | 58 | # Sort the data by a specific column, e.g., 'age' or 'name' 59 | sorted_data = sort_data(data, 'your_column_to_sort_by') # Replace with actual column name 60 | 61 | print("\nSorted Data:") 62 | for row in sorted_data: 63 | print(row) 64 | 65 | # Close the connection 66 | connection.close() 67 | 68 | # Run the main function 69 | if __name__ == "__main__": 70 | main() 71 | -------------------------------------------------------------------------------- /Github.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import json 3 | 4 | # Define the repository information 5 | owner = "your-username" # replace with the repo owner's GitHub username 6 | repo = "your-repo" # replace with the repository name 7 | 8 | # GitHub API URL for fetching branches 9 | url = f"https://api.github.com/repos/{owner}/{repo}/branches" 10 | 11 | # Optional: Provide a GitHub token for higher rate limits 12 | headers = { 13 | "Authorization": "token your-github-token" # replace with your GitHub token if needed 14 | } 15 | 16 | # Function to get branches from GitHub repository 17 | def get_branches(owner, repo, headers=None): 18 | response = requests.get(f"https://api.github.com/repos/{owner}/{repo}/branches", headers=headers) 19 | if response.status_code == 200: 20 | branches_data = response.json() 21 | return branches_data 22 | else: 23 | print(f"Error fetching branches: {response.status_code}") 24 | return None 25 | 26 | # Fetch branches 27 | branches_data = get_branches(owner, repo, headers) 28 | 29 | # Manipulating the branch data 30 | if branches_data: 31 | branch_names = [] 32 | for branch in branches_data: 33 | branch_name = branch['name'] # Extracting branch name 34 | commit_sha = branch['commit']['sha'] # Extracting the commit SHA for the branch 35 | protected = branch.get('protected', False) # Check if branch is protected 36 | branch_names.append({ 37 | 'branch_name': branch_name, 38 | 'commit_sha': commit_sha, 39 | 'protected': protected 40 | }) 41 | 42 | # Example: Print out all branch names and their statuses 43 | print("Branch Information:") 44 | for branch in branch_names: 45 | print(f"Branch: {branch['branch_name']}, SHA: {branch['commit_sha']}, Protected: {branch['protected']}") 46 | 47 | # Example: Filter branches with a specific pattern in the name 48 | filtered_branches = [branch for branch in branch_names if 'feature' in branch['branch_name'].lower()] 49 | print("\nFiltered Branches (contain 'feature'):") 50 | for branch in filtered_branches: 51 | print(f"Branch: {branch['branch_name']}, SHA: {branch['commit_sha']}, Protected: {branch['protected']}") 52 | 53 | # Example: Sorting branches alphabetically by name 54 | sorted_branches = sorted(branch_names, key=lambda x: x['branch_name']) 55 | print("\nSorted Branches:") 56 | for branch in sorted_branches: 57 | print(f"Branch: {branch['branch_name']}, SHA: {branch['commit_sha']}, Protected: {branch['protected']}") 58 | else: 59 | print("No data available.") 60 | -------------------------------------------------------------------------------- /Org_Automation/Compare_list.py: -------------------------------------------------------------------------------- 1 | list = ["V1_abcd","V2_cejn","V300_dnmewx","V300_cenjc","V301_ceiknce"] 2 | j=0 3 | list2=[] 4 | count=len(list2) 5 | list3=[] 6 | count=len(list) 7 | def file_read(): 8 | if len(list)!="null": 9 | for i in list: 10 | k=i.split("_") 11 | list2.append(k[0]) 12 | #v1 / v300 13 | #print(list2) 14 | else: 15 | print("list is empty") 16 | list2=['V1', 'V2', 'V300', 'V300', 'V301','V301'] 17 | for i in range(len(list2)): 18 | for j in range(i+1,len(list2)): 19 | if(list2[i]==list2[j]): 20 | print("SAME") 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Org_Automation/Endpoint_Hit.py: -------------------------------------------------------------------------------- 1 | import json 2 | import requests 3 | from socket import timeout 4 | import logging 5 | 6 | def hit_endpoint(url): 7 | list=[] 8 | if(url!="null"): 9 | data = requests.get(url) 10 | #print(data.json()) 11 | dump = data.json() 12 | print(dump["count"]) 13 | for link in dump["entries"]: 14 | print(link['Link']) 15 | try: 16 | data2 = requests.get(link['Link'],timeout=10) 17 | if (data2.status_code==200): 18 | list.append(link['Link']) 19 | print(list) 20 | else: 21 | print("Status Code is not 200") 22 | except requests.exceptions.Timeout: 23 | logging.error("timeout") 24 | 25 | else: 26 | print("Error loading the url") 27 | 28 | hit_endpoint("https://api.publicapis.org/entries") 29 | -------------------------------------------------------------------------------- /Org_Automation/Endpoint_hit2.py: -------------------------------------------------------------------------------- 1 | import json 2 | import requests 3 | person_ISS=[] 4 | person_Tiangong=[] 5 | def space_data(url): 6 | data = requests.get(url) 7 | # print(data.json()) 8 | dump = data.json() 9 | for person in dump["people"]: 10 | print(person["craft"]) 11 | if (person["craft"] == "ISS"): 12 | person_ISS.append(person["name"]) 13 | else: 14 | person_Tiangong.append(person["name"]) 15 | 16 | 17 | print("Total number of persons in ISS" + str(len(person_ISS))) 18 | print("Total number of persons in ISS" + str(len(person_Tiangong))) 19 | 20 | space_data("http://api.open-notify.org/astros.json") 21 | -------------------------------------------------------------------------------- /Org_Automation/List_with_sort.py: -------------------------------------------------------------------------------- 1 | 2 | list1=[-10, -8, 2, 4, 6] 3 | list2=[ 4, 16, 36, 64, 100] 4 | list3=[] 5 | j=0 6 | def data(list1): 7 | if(len(list1)!=0): 8 | for i in list1: 9 | j= i*i 10 | list3.append(j) 11 | print(sorted(list3)) 12 | 13 | else: 14 | print("Input list is empty") 15 | data(list1) 16 | -------------------------------------------------------------------------------- /Python-Speech/FILE_HANDLING.py: -------------------------------------------------------------------------------- 1 | file = open("test.py") 2 | print(file.read()) 3 | 4 | #Create a File: 5 | 6 | file = open("Text2.txt", "x") 7 | 8 | 9 | 10 | #write to a file 11 | 12 | file = open("Text.txt", "w") 13 | file.write("This is an example of file creation.") 14 | file.close 15 | 16 | #Read a File: 17 | 18 | file = open("Text.txt", "r") 19 | print(file.read()) 20 | file.close 21 | 22 | #Append a File: 23 | 24 | file = open("newText.txt", "a") 25 | file.write("This is an example of file appending.") 26 | file.close -------------------------------------------------------------------------------- /Python-Speech/SLIDES_PYTHON.py: -------------------------------------------------------------------------------- 1 | #SLIDE VARIABLES ################################################## 2 | 3 | def f(): 4 | #local variable 5 | s = "DevOps course." 6 | print(s) 7 | 8 | 9 | # Global variable 10 | s = "Python Data" 11 | f() 12 | print(s) 13 | 14 | 15 | 16 | #SLIDE DATA TYPES ################################################# 17 | 18 | tuple1 = (("cicd", "Jenkins"), ("security", "fortify")) 19 | print(tuple1) 20 | 21 | list_data = [9, 2.9, [-3, 5], ["jenkins", "Jira"]] 22 | print(list_data) 23 | 24 | 25 | 26 | letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' 27 | 28 | string_letters = str(letters) 29 | lists_letters = list(letters) 30 | tuples_letters = tuple(letters) 31 | sets_letters = set(letters) 32 | 33 | 34 | print("String: ", string_letters) 35 | print() # for new line 36 | print("Lists: ", lists_letters) 37 | print() # for new line 38 | print("Tuples: ", tuples_letters) 39 | print() # for new line 40 | print("Sets: ", sets_letters) 41 | 42 | 43 | 44 | 45 | dict1 = {"name":"Devops", "batch":1.0, "canVote":True,"name":"test"} 46 | print(dict1) 47 | 48 | print(dict1["name"]) 49 | 50 | 51 | ######SLIDE Numbers/Operators ################################################# 52 | 53 | x = 13 54 | if(x>=13): 55 | print("Met the condition") 56 | else: 57 | print("Didn't met the condition") 58 | 59 | 60 | print("Zero:",bool(0)) 61 | print("Integer:",bool(23)) 62 | print("Float:",bool(3.142)) 63 | print("Complex:",bool(5+2j)) 64 | 65 | 66 | ######## OPERTATIONS ON STRINGS ##### 67 | 68 | 69 | #1 70 | Tool = "SONAR" 71 | len1 = len(Tool) 72 | print(len1) 73 | print("Code analysis tool is", Tool, ".Its part of devops") 74 | 75 | #2 76 | IAAS = "TERRAFORM" 77 | print(IAAS[:5]) #Slicing from Start 78 | print(IAAS[5:]) #Slicing till End 79 | print(IAAS[2:6]) #Slicing in between 80 | 81 | #3 82 | Name = "AMAZON WEB SERVICES" 83 | for i in Name: 84 | print(i) 85 | 86 | 87 | 88 | ######SLIDE LIST ################################################# 89 | 90 | ToolsData = ["Maven", "Ansible", "Jenkins", "Sonar"] 91 | if "Maven" in ToolsData: 92 | print("Maven is present.") 93 | else: 94 | print("Maven is absent.") 95 | 96 | 97 | ToolsData.append("Fortify") 98 | 99 | #print(ToolsData) 100 | 101 | 102 | del ToolsData[3] 103 | 104 | print(ToolsData) 105 | 106 | 107 | ########LIST ITERATION ####################################### 108 | 109 | 110 | ToolsData = ["Maven","Ansible","Jenkins","Sonar"] 111 | ToolsData.sort() 112 | print(ToolsData) 113 | 114 | 115 | ############CONDITIONAL STATEMENTS ########################### 116 | 117 | 118 | applePrice = 180 119 | budget = 200 120 | if (applePrice <= budget): 121 | print("Alexa, add 1kg Apples to the cart.") 122 | 123 | 124 | 125 | VERSION = 18 126 | if (VERSION < 0): 127 | print("Version is negative.") 128 | elif (VERSION > 0): 129 | if (VERSION <= 10): 130 | print("Version is between 1-10") 131 | elif (VERSION > 10 and VERSION <= 20): 132 | print("Version is between 11-20") 133 | else: 134 | print("Version is greater than 20") 135 | else: 136 | print("Version is zero") 137 | 138 | 139 | #FOR LOOP 140 | 141 | #Iterating over string 142 | name = 'SINGAM' 143 | for i in name: 144 | print(i) 145 | 146 | 147 | #iterating over a tuple 148 | 149 | tools = ("Maven", "Jenkins", "sonar", "jira") 150 | for x in tools: 151 | print(x) 152 | 153 | 154 | #PYTHON WHILE LOOP 155 | 156 | count = 5 157 | while (count > 0): 158 | print(count) 159 | count = count - 1 160 | 161 | 162 | 163 | #NESTED LOOPS 164 | i=1 165 | while (i<=3): 166 | #for loop will run till end 167 | for k in range(1, 4): 168 | print(i, "*", k, "=", (i*k)) 169 | i = i + 1 170 | print() 171 | 172 | 173 | for i in range(1, 4): 174 | k = 1 175 | while (k<=3): 176 | print(i, "*", k, "=", (i*k)) 177 | k = k + 1 178 | print() 179 | 180 | 181 | 182 | ##### PYTHON FUNCTIONS ############################### 183 | 184 | def toolname(security, analysis): 185 | print("Tools,", security, analysis) 186 | 187 | toolname("Fortify", "Sonar") 188 | 189 | 190 | def name(fname, mtame = "Jenkins", boardname = "Jira"): 191 | print("Hello,", fname, mtame, boardname) 192 | 193 | name("Sonar") 194 | 195 | 196 | def name(firsttool, secondtool, thirdtool): 197 | print("Hello,", firsttool, secondtool, thirdtool) 198 | 199 | name(thirdtool = "Ansible", firsttool = "Terraform", secondtool = "Jmeter") 200 | 201 | 202 | def name(firsttool, secondtool, thirdtool): 203 | print("Hello,", firsttool, secondtool, thirdtool) 204 | 205 | name("Ansible", "Terraform", "Jmeter") 206 | 207 | 208 | 209 | def name(*name): 210 | print("Hello,", name[0], name[1], name[2]) 211 | 212 | name("Ansible", "Terraform", "Jmeter") 213 | 214 | 215 | 216 | ########### RECURSION SLIDE ######################################## 217 | 218 | 219 | def factorial(num): 220 | if (num == 1 or num == 0): 221 | return 1 222 | else: 223 | return (num * factorial(num - 1)) ########FUNCTION IS FACTORIAL 224 | 225 | # Driver Code 226 | num = 7; 227 | print("number: ",num) 228 | print("Factorial: ",factorial(num)) 229 | 230 | 231 | 232 | 233 | from math import * 234 | print(pi) 235 | print(factorial(6)) 236 | 237 | 238 | 239 | #############PYTHON OOPS ########################## 240 | 241 | ###CREATE A CLASS 242 | 243 | class Tools: 244 | name = "Jenkins" 245 | version = 20 246 | 247 | T1 = Tools() 248 | print(T1.name) 249 | print(T1.version) 250 | 251 | 252 | ####CREATE AN OBJECT 253 | class Tools: 254 | name = "Jenkins" 255 | version = 20 256 | 257 | def toolsdes(self): 258 | print(self.version, self.name + "\tTOOLS") 259 | 260 | T1 = Tools() 261 | T1.toolsdes() 262 | 263 | print(T1.name) 264 | print(T1.version) 265 | 266 | 267 | #####INITIALIZE 268 | 269 | # A Sample class with init method 270 | class Data: 271 | 272 | # init method or constructor 273 | def __init__(self, name): 274 | self.name = name 275 | 276 | # Sample Method 277 | def say_hi(self): 278 | print('Hello, my name is', self.name) 279 | 280 | 281 | p = Data('PowerBI') 282 | p.say_hi() 283 | 284 | 285 | #######PYTHON INHERITENCE ################ 286 | 287 | 288 | 289 | # Python program to 290 | # demonstrate init with 291 | # inheritance 292 | 293 | class A(object): 294 | def __init__(self, something): 295 | print("A init called") 296 | self.something = something 297 | 298 | 299 | class B(A): 300 | def __init__(self, something): 301 | # Calling init of parent class 302 | A.__init__(self, something) 303 | print("B init called") 304 | self.something = something 305 | 306 | 307 | obj = B("Something") 308 | 309 | 310 | 311 | # Python program to 312 | # demonstrate init with 313 | # inheritance 314 | 315 | class A(object): 316 | def __init__(self, something): 317 | print("A init called") 318 | self.something = something 319 | 320 | 321 | class B(A): 322 | def __init__(self, something): 323 | print("B init called") 324 | self.something = something 325 | # Calling init of parent class 326 | A.__init__(self, something) 327 | 328 | 329 | obj = B("Something") 330 | 331 | 332 | ############JSON SLIDE ############################### 333 | 334 | 335 | 336 | import json 337 | 338 | # JSON String: 339 | tools = '["Maven", "Jira", "Kubernetes", "Docker"]' 340 | 341 | # JSON string to python dictionary: 342 | lst1 = json.loads(tools) 343 | print(lst1) 344 | 345 | 346 | import json 347 | 348 | # python dictionary 349 | lst1 = ['Maven', 'Jira', 'Kubernetes', 'Docker'] 350 | 351 | # Convert Python dict to JSON 352 | jsonObj = json.dumps(lst1) 353 | print(jsonObj) 354 | 355 | 356 | ######PYTHON TRY CATCH ############# 357 | 358 | 359 | try: 360 | num = int(input("Enter an integer: ")) 361 | except ValueError: 362 | print("Number entered is not an integer.") 363 | else: 364 | print("Integer Accepted.") 365 | finally: 366 | print("This block is always executed.") -------------------------------------------------------------------------------- /Python-Speech/SPEECH.py: -------------------------------------------------------------------------------- 1 | #yPDF2 is a free and open-source pure-python 2 | # pip install PyPDF2 3 | # PDF library capable of splitting, merging, cropping, and transforming the pages of PDF files 4 | 5 | 6 | #pyttsx3 is a text-to-speech conversion library in Python 7 | 8 | 9 | #pip install pyttsx3 10 | 11 | 12 | import PyPDF2 13 | 14 | import pyttsx3 15 | 16 | pdfReader = PyPDF2.PdfFileReader(open('dummypdf.pdf', 'rb')) 17 | 18 | #######CASE 1 PDF READ 19 | # Initialize the Pyttsx3 engine 20 | 21 | speaker = pyttsx3.init() 22 | 23 | for page_num in range(pdfReader.numPages): 24 | text = pdfReader.getPage(page_num).extractText() 25 | speaker.say(text) 26 | speaker.runAndWait() 27 | speaker.stop() 28 | 29 | 30 | 31 | speaker.save_to_file(text, 'audio.mp3') 32 | 33 | 34 | 35 | ####CASE 2 READ A STRING ########### 36 | # Create a string 37 | string = "Lorem Ipsum is simply dummy text " \ 38 | + "of the printing and typesetting industry." 39 | 40 | # Initialize the Pyttsx3 engine 41 | engine = pyttsx3.init() 42 | 43 | # We can use file extension as mp3 and wav, both will work 44 | engine.save_to_file(string, 'speech.mp3') 45 | 46 | # Wait until above command is not finished. 47 | engine.runAndWait() 48 | 49 | 50 | -------------------------------------------------------------------------------- /Python-Speech/Text.txt: -------------------------------------------------------------------------------- 1 | This is an example of file creation. -------------------------------------------------------------------------------- /Python-Speech/dummypdf.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/praveen1994dec/python_automation/6b988bd26c586b358a264aa2cb9cb8553bc2f07d/Python-Speech/dummypdf.pdf -------------------------------------------------------------------------------- /Python-Speech/newText.txt: -------------------------------------------------------------------------------- 1 | This is an example of file appending.This is an example of file appending. -------------------------------------------------------------------------------- /Python-Speech/test.py: -------------------------------------------------------------------------------- 1 | ToolsData = ["Maven","Ansible","Jenkins","Sonar"] 2 | ToolsData.sort() 3 | print(ToolsData) 4 | 5 | colors = ["voilet", "indigo", "blue", "green"] 6 | colors.sort() 7 | print(colors) 8 | 9 | num = [4,2,5,3,6,1,2,1,2,8,9,7] 10 | num.sort() 11 | print(num) -------------------------------------------------------------------------------- /Python/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/praveen1994dec/python_automation/6b988bd26c586b358a264aa2cb9cb8553bc2f07d/Python/.DS_Store -------------------------------------------------------------------------------- /Python/Marks.csv: -------------------------------------------------------------------------------- 1 | NAME,EMAIL ID ,MATH,ENGLISH,SCIENCE 2 | AMAN,,81,90,98 3 | HARITHA,,56,67,87 4 | KUSUMA,,78,75,76 -------------------------------------------------------------------------------- /Python/NEWS.py: -------------------------------------------------------------------------------- 1 | ##pip install -U scikit-learn 2 | 3 | import numpy as np 4 | import pandas as pd 5 | import itertools 6 | 7 | 8 | 9 | from sklearn.model_selection import train_test_split 10 | from sklearn.feature_extraction.text import TfidfVectorizer 11 | from sklearn.linear_model import PassiveAggressiveClassifier 12 | from sklearn.metrics import accuracy_score, confusion_matrix 13 | 14 | 15 | #Read the data 16 | df=pd.read_csv('/Users/praveensingampalli/Documents/BOOTCAMP2_FINAL/Python/news.csv') 17 | 18 | 19 | #Get shape and head 20 | df.shape 21 | cat = df.head() 22 | 23 | print(cat) 24 | -------------------------------------------------------------------------------- /Python/OTP_VERIFICATION.py: -------------------------------------------------------------------------------- 1 | import os 2 | import math 3 | import random 4 | 5 | 6 | 7 | digits="0123456789" 8 | OTP="" 9 | #Six digit password 10 | for i in range(6): 11 | OTP+=digits[math.floor(random.random()*10)] 12 | otp = OTP + " is your OTP" 13 | msg= otp 14 | 15 | print(msg) 16 | -------------------------------------------------------------------------------- /Python/PASSWORD_GENERATOR.py: -------------------------------------------------------------------------------- 1 | #brew install python-tk@3.9 . 2 | # // pip install pyperclip 3 | ##curl https://files.pythonhosted.org/packages/a7/2c/4c64579f847bd5d539803c8b909e54ba087a79d01bb3aba433a95879a6c5/pyperclip-1.8.2.tar.gz > pyperclip.tar.gz 4 | 5 | ## tar -xzvf pyperclip.tar.gz 6 | ##cd pyperclip-1.8.2 7 | ##python3 setup.py install 8 | 9 | #Pyperclip is a cross-platform Python module for copy and paste clipboard functions 10 | 11 | 12 | import random 13 | from tkinter import * 14 | from tkinter import messagebox 15 | import pyperclip 16 | 17 | gui = Tk() 18 | gui.title('Password Generator') 19 | gui.geometry('250x200') 20 | gui.resizable(0,0) 21 | 22 | def process(): 23 | length = int(string_pass.get()) 24 | 25 | lower = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] 26 | upper = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] 27 | num = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] 28 | special = ['@', '#', '$', '%', '&', '*'] 29 | all = lower + upper + num + special 30 | ran = random.sample(all,length) 31 | password = "".join(ran) 32 | messagebox.showinfo('Result', 'Your password {} \n\nPassword copied to clipboard'.format(password)) 33 | pyperclip.copy(password) 34 | 35 | string_pass = StringVar() 36 | label = Label(text="Password Length").pack(pady=10) 37 | txt = Entry(textvariable=string_pass).pack() 38 | btn = Button(text="Generator", command=process).pack(pady=10) 39 | 40 | gui.mainloop() -------------------------------------------------------------------------------- /Python/Python_Cars_class.py: -------------------------------------------------------------------------------- 1 | ####CREATE AN OBJECT 2 | class Tools: 3 | car_list=[] 4 | name = "Jenkins" 5 | version = 20 6 | date = "20/11" 7 | cartyres=4 8 | car_name="toyota" 9 | 10 | def cartyres1(self): 11 | if self.cartyres==4: 12 | self.car_list.append(self.car_name) 13 | print(self.car_list) 14 | else: 15 | print("Only two wheelers are there") 16 | 17 | Toyota = Tools() 18 | Toyota.cartyres1() 19 | -------------------------------------------------------------------------------- /Python/QR_CODE_WORKING.py: -------------------------------------------------------------------------------- 1 | #pip install pyqrcode 2 | 3 | import pyqrcode 4 | from pyqrcode import QRCode 5 | 6 | # String which represent the QR code 7 | s = "https://www.youtube.com/channel/UCBz4yaxNxfiz1XYh-07UfWQ" 8 | 9 | # Generate QR code 10 | url = pyqrcode.create(s) 11 | 12 | # Create and save the png file naming "myqr.png" 13 | #Scalable Vector Graphics 14 | url.svg("myyoutube.svg", scale = 8) -------------------------------------------------------------------------------- /Python/SCRAPE_WEBSITE_WORKING.py: -------------------------------------------------------------------------------- 1 | #In DevOps it is used for log analysis/processing 2 | #pip install beautifulsoup4 3 | 4 | 5 | import urllib.request 6 | from bs4 import BeautifulSoup 7 | import requests 8 | 9 | 10 | class Scraper: 11 | def __init__(self, site): 12 | self.site = site 13 | 14 | def scrape(self): 15 | r = urllib.request.urlopen(self.site) 16 | html = r.read() 17 | parser = "html.parser" 18 | sp = BeautifulSoup(html,parser) 19 | print(sp) 20 | for tag in sp.find_all("a"): 21 | url = tag.get("href") 22 | if url is None: 23 | continue 24 | if "articles" in url: 25 | print("\n" + url) 26 | 27 | news = "https://news.google.com/" 28 | Scraper(news).scrape() 29 | 30 | 31 | #Creating a class 32 | class cloud: 33 | def __init__(self, value): 34 | self.value = value 35 | 36 | #Method inside a class 37 | def hello(self): 38 | print(self.value) 39 | 40 | #calling aclass with method 41 | test="DevOps a gaya" 42 | cloud(test).hello() -------------------------------------------------------------------------------- /Python/finalmail.py: -------------------------------------------------------------------------------- 1 | import smtplib 2 | import csv 3 | from string import Template 4 | from email.mime.multipart import MIMEMultipart 5 | from email.mime.text import MIMEText 6 | 7 | gmail_user = "test@gmail.com" 8 | gmail_pwd = "demo" 9 | TO = 'test1@gmail.com' 10 | SUBJECT = "Testing sending using gmail" 11 | TEXT = "Testing sending mail using gmail servers" 12 | server = smtplib.SMTP('smtp.gmail.com', 587) 13 | server.ehlo() 14 | server.starttls() 15 | server.login(gmail_user, gmail_pwd) 16 | BODY = '\r\n'.join(['To: %s' % TO, 17 | 'From: %s' % gmail_user, 18 | 'Subject: %s' % SUBJECT, 19 | '', TEXT]) 20 | 21 | server.sendmail(gmail_user, [TO], BODY) 22 | print ('email sent') 23 | -------------------------------------------------------------------------------- /Python/myyoutube.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /Python/template.txt: -------------------------------------------------------------------------------- 1 | Dear ${PERSON_NAME}, 2 | You have secured the following marks in your mid-term exams: 3 | Math - ${MATH} 4 | English - ${ENG} 5 | Science - ${SCI} -------------------------------------------------------------------------------- /kubernetes_Access.py: -------------------------------------------------------------------------------- 1 | import csv 2 | import pandas as pd 3 | from kubernetes import client, config 4 | 5 | # Function to load Kubernetes configuration (from kubeconfig file or in-cluster) 6 | def load_k8s_config(): 7 | try: 8 | # Try loading the kubeconfig from the default location (e.g., ~/.kube/config) 9 | config.load_kube_config() 10 | except Exception as e: 11 | print(f"Error loading Kubernetes config: {e}") 12 | exit(1) 13 | 14 | # Function to fetch pod data from Kubernetes cluster 15 | def fetch_pod_data(): 16 | # Create the Kubernetes API client for Pod resources 17 | v1 = client.CoreV1Api() 18 | 19 | # Fetch pod information across all namespaces 20 | pod_list = v1.list_pod_for_all_namespaces(watch=False) 21 | 22 | # Prepare a list of dictionaries to store pod data 23 | pod_data = [] 24 | for pod in pod_list.items: 25 | pod_data.append({ 26 | "namespace": pod.metadata.namespace, 27 | "name": pod.metadata.name, 28 | "status": pod.status.phase, 29 | "created_at": pod.metadata.creation_timestamp, 30 | "node_name": pod.spec.node_name, 31 | }) 32 | 33 | return pod_data 34 | 35 | # Function to write data to a CSV file 36 | def write_data_to_csv(data, filename): 37 | # Define column headers 38 | headers = ["namespace", "name", "status", "created_at", "node_name"] 39 | 40 | # Open CSV file in write mode and write the data 41 | with open(filename, mode='w', newline='') as file: 42 | writer = csv.DictWriter(file, fieldnames=headers) 43 | writer.writeheader() 44 | writer.writerows(data) 45 | print(f"Data written to {filename}") 46 | 47 | # Function to read data from the CSV file and load it into a Pandas DataFrame 48 | def read_data_from_csv(filename): 49 | # Use Pandas to read the CSV file into a DataFrame 50 | df = pd.read_csv(filename) 51 | return df 52 | 53 | # Main function to run the process 54 | def main(): 55 | # Load Kubernetes configuration 56 | load_k8s_config() 57 | 58 | # Fetch pod data from Kubernetes 59 | pod_data = fetch_pod_data() 60 | 61 | # Write the pod data to a CSV file 62 | csv_filename = 'k8s_pod_data.csv' 63 | write_data_to_csv(pod_data, csv_filename) 64 | 65 | # Read the data back from the CSV file using Pandas 66 | df = read_data_from_csv(csv_filename) 67 | 68 | # Print the DataFrame to see the loaded data 69 | print("\nData extracted from the CSV file:") 70 | print(df) 71 | 72 | # Run the main function 73 | if __name__ == "__main__": 74 | main() 75 | --------------------------------------------------------------------------------