diff --git a/Day-04/README.md b/Day-04/README.md index 381972ef..84221558 100644 --- a/Day-04/README.md +++ b/Day-04/README.md @@ -96,7 +96,7 @@ In this example, we import the `math` module and then use functions and variable Python workspaces refer to the environment in which you develop and run your Python code. They include the Python interpreter, installed libraries, and the current working directory. Understanding workspaces is essential for managing dependencies and code organization. -Python workspaces can be local or virtual environments. A local environment is the system-wide Python installation, while a virtual environment is an isolated environment for a specific project. You can create virtual environments using tools like `virtualenv` or `venv`. +Python workspaces can be local or virtual environments. A local environment is the system-wide Python installation, while a virtual environment is an isolated environment for a specific project. You can create virtual environments using tools like `virtualenv` or `venv`.(logical seperation for python packages on virtual machine). **Example:** @@ -111,4 +111,4 @@ myenv\Scripts\activate source myenv/bin/activate ``` -Once activated, you work in an isolated workspace with its Python interpreter and library dependencies. \ No newline at end of file +Once activated, you work in an isolated workspace with its Python interpreter and library dependencies. diff --git a/Day-04/calc.py b/Day-04/calc.py new file mode 100644 index 00000000..e38ed5d4 --- /dev/null +++ b/Day-04/calc.py @@ -0,0 +1,33 @@ +import sys +import os + + +def add(num1,num2): + add = num1 + num2 + return add + +def sub(num1, num2): + sub = num1 - num2 + return sub + +def mul(num1, num2): + m = num1 * num2 + return m + +num1= float(sys.argv[1]) +operation = sys.argv[2] +num2 = float(sys.argv[3]) + +if operation=='add': + output=add(num1,num2) + print(output) + +if operation =='sub': + output=sub(num1,num2) + print(output) + +if operation =='mul': + output=mul(num1,num2) + print(output) + +print(os.getenv("password")) \ No newline at end of file diff --git a/Day-06/02-Assignment/test.py b/Day-06/02-Assignment/test.py new file mode 100644 index 00000000..9d91f41d --- /dev/null +++ b/Day-06/02-Assignment/test.py @@ -0,0 +1,65 @@ +#a=3 +#b=4 + +#sum=a+b +#difference=a-b +#product=a*b +#quotient=a/b +#modulus=a%b +#exponentiation=a**b +#floor_division=a//b + +#greater=a>b +#less=a=b +#less_equal=a<=b +#equal=a==b +#not_equal=a!=b + +#x=True +#y=False + +#and_1=x and y +#or_1=x or y +#not_1= not y +#not_2= not x + +#total =10 + +#total +=4 +#total -=7 +#total *=8 +#total /=2 + +#print("Sum of function is=",sum) +#print("difference of function is=",difference) +#print("product of function is=",product) +#print("quotient of function is=",quotient) +#print("modulus of function is=",modulus) +#print("exponentiation of function is=",exponentiation) +#print("floor division of function is=",floor_division) + +#print("Greater than function is=",greater) +#print("Less than function is=",less) +#print("Greater than or equal to function is=",greater_equal) +#print("Less than or equal to function is=",less_equal) +#print("Equal to function is=",equal) +#print("Not equal to function is=",not_equal) + +#print("Logical and is", and_1) +#print("Logical or is", or_1) +#print("Logical not is", not_1 ) +#print("Logical not is", not_2 ) + +#print("final value of total is=",total) + +#my_list=["apple","grapes","rabbit",1,2,3,4] +#u="apple" + +#b="grapes" +#c="banana" + +#print(u is u) +#print(u is not my_list) +#print(b in my_list) +#print(c not in my_list) \ No newline at end of file diff --git a/Day-07/test.py b/Day-07/test.py new file mode 100644 index 00000000..d9834add --- /dev/null +++ b/Day-07/test.py @@ -0,0 +1,11 @@ +import sys +type= sys.argv[1] + +if type=="t2.micro": + print("charges are 2 dollar/tb data transfer") +elif type=="t2.medium": + print("charges are 8 dollar/tb data transfer") +elif type=="t2.xlarge": + print("charges are 10 dollar/tb data transfer") +else: + print("wrong type of instance provided") \ No newline at end of file diff --git a/Day-09/test.py b/Day-09/test.py new file mode 100644 index 00000000..fa65828c --- /dev/null +++ b/Day-09/test.py @@ -0,0 +1,10 @@ +log_file = [ + "INFO: Operation successful", + "ERROR: line 43-File not found", + "DEBUG: Connection established", + "ERROR: port-4385 Database connection failed", +] + +for line in log_file: + if "ERROR" in line: + print(line) \ No newline at end of file diff --git a/Day-09/test1.sh b/Day-09/test1.sh new file mode 100755 index 00000000..6f474575 --- /dev/null +++ b/Day-09/test1.sh @@ -0,0 +1,30 @@ + +servers=("server1" "server2" "server3") +for server in "${servers[@]}"; do + configure_monitoring_agent "$server" +done + +environments=("dev" "staging" "prod") +for env in "${environments[@]}"; do + deploy_configuration "$env" +done + +databases=("db1" "db2" "db3") +for db in "${databases[@]}"; do + create_backup "$db" +done + +log_files=("app.log" "access.log" "error.log") +for log_file in "${log_files[@]}"; do + rotate_and_cleanup_logs "$log_file" +done + +servers=("server1" "server2" "server3") +for server in "${servers[@]}"; do + check_resource_utilization "$server" +done + +servers=("server1" "server2" "server3") +for server in "${servers[@]}"; do + check_resource_utilization "$server" +done diff --git a/Day-09/test2.sh b/Day-09/test2.sh new file mode 100755 index 00000000..af810cb1 --- /dev/null +++ b/Day-09/test2.sh @@ -0,0 +1,31 @@ +servers=("server1" "server2" "server3") +for server in "${servers[@]}"; do + check_resource_utilization "$server" +done + +while ! aws ec2 describe-instance-status --instance-ids i-1234567890abcdef0 | grep -q "running"; do + echo "Waiting for the EC2 instance to be running..." + sleep 10 +done + +while true; do + if tail -n 1 /var/log/app.log | grep -q "ERROR"; then + send_alert "Error detected in the log." + fi + sleep 5 +done + +while true; do + replication_lag=$(mysql -e "SHOW SLAVE STATUS\G" | grep "Seconds_Behind_Master" | awk '{print $2}') + if [ "$replication_lag" -gt 60 ]; then + trigger_data_sync + fi + sleep 60 +done + +while true; do + if ! check_service_health; then + restart_service + fi + sleep 30 +done \ No newline at end of file diff --git a/Day-10/test.py b/Day-10/test.py new file mode 100644 index 00000000..befd0a25 --- /dev/null +++ b/Day-10/test.py @@ -0,0 +1,28 @@ +import os + +def list_files_in_folder(folder_path): + try: + files=os.listdir(folder_path) + return files, None + except FileNotFoundError: + return None, "folder not found" + except PermissionError: + return None, "persmission denied" + + +def main(): + folder_paths= input("Enter folder paths seperated by space:").split() + + for folder_path in folder_paths: + files, error_message=list_files_in_folder(folder_path) + if files: + print(f"files in {folder_path}") + for file in files: + print(file) + + else: + print(f"error in folder {folder_path}: {error_message}") + +if __name__=="__main__": + main() + diff --git a/Day-11/test.py b/Day-11/test.py new file mode 100644 index 00000000..fa821649 --- /dev/null +++ b/Day-11/test.py @@ -0,0 +1,9 @@ +import requests + +response= requests.get("https://api.github.com/repos/kubernetes/kubernetes/pulls") + +complete_detail = response.json() + +for i in range(len(complete_detail)): + print(complete_detail[i]) + diff --git a/Day-12/server.conf b/Day-12/server.conf index e9d46d83..be193449 100644 --- a/Day-12/server.conf +++ b/Day-12/server.conf @@ -2,7 +2,7 @@ # Network Settings PORT = 8080 -MAX_CONNECTIONS=600 +MAX_CONNECTIONS=1000 TIMEOUT = 30 # Security Settings diff --git a/Day-12/test.py b/Day-12/test.py new file mode 100644 index 00000000..9f3e58ea --- /dev/null +++ b/Day-12/test.py @@ -0,0 +1,13 @@ +def update_server_config(file_path, key, value): + + with open(file_path,"r") as file: + lines=file.readlines() + + with open(file_path,"w") as file: + for line in lines: + if key in line: + file.write(key + "=" + value + "\n") + else: + file.write(line) + +update_server_config("server.conf", "MAX_CONNECTIONS","1000") \ No newline at end of file