From 53bcf285539228bf4f9a4b921343c90dd2de9ac3 Mon Sep 17 00:00:00 2001 From: vijay patel Date: Tue, 22 Oct 2019 11:23:35 +0530 Subject: [PATCH 01/22] added python class example --- Python-with-class/Class_with_attribute.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Python-with-class/Class_with_attribute.py diff --git a/Python-with-class/Class_with_attribute.py b/Python-with-class/Class_with_attribute.py new file mode 100644 index 0000000..fa961bf --- /dev/null +++ b/Python-with-class/Class_with_attribute.py @@ -0,0 +1,23 @@ + +################################################# +# Python Class with Attribute Example +################################################# + +class class_with_Attribute: +#class attribute Declaration + type="Normal" + +t1 = class_with_Attribute() +t2 = class_with_Attribute() + +#Getting Output of Class Attribute +print (t1.type,t2.type) +#Output would be +# Normal Normal + +#updating class Attribute value +testing.type="Advance" + +print (t1.type,t2.type) +#Output would be +# Advance Advance From 8e264c651704bf984598b89a2007ece018a76888 Mon Sep 17 00:00:00 2001 From: Vijay Patel <35554905+easyawslearn@users.noreply.github.com> Date: Mon, 18 Nov 2019 20:02:52 +0530 Subject: [PATCH 02/22] Create sample.py --- sample.py | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 sample.py diff --git a/sample.py b/sample.py new file mode 100644 index 0000000..b1e8cf0 --- /dev/null +++ b/sample.py @@ -0,0 +1,5 @@ +################ +# Sample Python program +################### + +pritn ("THIS IS SAMPLE PYTHON PROGRAM") From 6367bdc206c0158f7beb44a80ce841ca3b407bb6 Mon Sep 17 00:00:00 2001 From: Vijay Patel <35554905+easyawslearn@users.noreply.github.com> Date: Mon, 18 Nov 2019 20:07:45 +0530 Subject: [PATCH 03/22] Update sample.py --- sample.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sample.py b/sample.py index b1e8cf0..2fe3b05 100644 --- a/sample.py +++ b/sample.py @@ -2,4 +2,4 @@ # Sample Python program ################### -pritn ("THIS IS SAMPLE PYTHON PROGRAM") +print ("THIS IS SAMPLE PYTHON PROGRAM") From 6885da43133f2ab6a1b05677bac5079ebf5eafa4 Mon Sep 17 00:00:00 2001 From: Vijay Patel <35554905+easyawslearn@users.noreply.github.com> Date: Mon, 18 Nov 2019 22:44:44 +0530 Subject: [PATCH 04/22] Update sample.py --- sample.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sample.py b/sample.py index 2fe3b05..f8bdd15 100644 --- a/sample.py +++ b/sample.py @@ -3,3 +3,5 @@ ################### print ("THIS IS SAMPLE PYTHON PROGRAM") + +print ("\n") From 92d6992ea4c3618fdb308d46aaf50a0a01131da9 Mon Sep 17 00:00:00 2001 From: Vijay Patel <35554905+easyawslearn@users.noreply.github.com> Date: Mon, 18 Nov 2019 23:11:02 +0530 Subject: [PATCH 05/22] Update sample.py --- sample.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sample.py b/sample.py index f8bdd15..95e592c 100644 --- a/sample.py +++ b/sample.py @@ -5,3 +5,5 @@ print ("THIS IS SAMPLE PYTHON PROGRAM") print ("\n") + +print ("THIS IS JENKINS Integration") From 990a67840296503195d25c997e9756d62bc43085 Mon Sep 17 00:00:00 2001 From: "Patel, VijayKumar" Date: Fri, 3 Apr 2020 17:03:13 +0530 Subject: [PATCH 06/22] nested paramiko example added --- Python-Paramiko/nested-paramiko.py | 30 +++++++++++++++++++++++++++ Python-Paramiko/subprocess-example.py | 12 +++++++++++ 2 files changed, 42 insertions(+) create mode 100644 Python-Paramiko/nested-paramiko.py create mode 100644 Python-Paramiko/subprocess-example.py diff --git a/Python-Paramiko/nested-paramiko.py b/Python-Paramiko/nested-paramiko.py new file mode 100644 index 0000000..aa74953 --- /dev/null +++ b/Python-Paramiko/nested-paramiko.py @@ -0,0 +1,30 @@ +import paramiko +import sys +import subprocess +# +# we instantiate a new object referencing paramiko's SSHClient class +# +jumphost = "192.168.1.10" +server = "192.168.1.11" + +vm = paramiko.SSHClient() +vm.set_missing_host_key_policy(paramiko.AutoAddPolicy()) +vm.connect(jumphost, username='root', password='a') +# +vmtransport = vm.get_transport() +server_addr = (server, 22) #edited# +jump_host = (jumphost, 22) #edited# +vmchannel = vmtransport.open_channel("direct-tcpip", server_addr, jump_host) +# +jhost = paramiko.SSHClient() +jhost.set_missing_host_key_policy(paramiko.AutoAddPolicy()) +#jhost.load_host_keys('/home/osmanl/.ssh/known_hosts') #disabled# +jhost.connect(server, username='root', password='a', sock=vmchannel) +# +stdin, stdout, stderr = jhost.exec_command("show version | no-more") #edited# +stdin, stdout, stderr = jhost.exec_command("ifconfig") #edited# +# +print stdout.read() #edited# +# +jhost.close() +vm.close() diff --git a/Python-Paramiko/subprocess-example.py b/Python-Paramiko/subprocess-example.py new file mode 100644 index 0000000..e4fcbb5 --- /dev/null +++ b/Python-Paramiko/subprocess-example.py @@ -0,0 +1,12 @@ +import subprocess + +logile="subprocess.log" +def subprocess_cmd(command): + print (command) + process = subprocess.Popen(command,stdout=subprocess.PIPE, shell=True) + proc_stdout = process.communicate()[0].strip() + with open(logile,'w') as f: + f.writelines(proc_stdout.split(' ')) + return logile + +subprocess_cmd("uname") From 5b0b965273075968330b335bbdab7245160c6a7c Mon Sep 17 00:00:00 2001 From: "Patel, VijayKumar" Date: Fri, 3 Apr 2020 17:26:58 +0530 Subject: [PATCH 07/22] updated --- Python-Paramiko/nested-paramiko.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Python-Paramiko/nested-paramiko.py b/Python-Paramiko/nested-paramiko.py index aa74953..0bc71f8 100644 --- a/Python-Paramiko/nested-paramiko.py +++ b/Python-Paramiko/nested-paramiko.py @@ -10,19 +10,18 @@ vm = paramiko.SSHClient() vm.set_missing_host_key_policy(paramiko.AutoAddPolicy()) vm.connect(jumphost, username='root', password='a') + # vmtransport = vm.get_transport() server_addr = (server, 22) #edited# jump_host = (jumphost, 22) #edited# -vmchannel = vmtransport.open_channel("direct-tcpip", server_addr, jump_host) -# + jhost = paramiko.SSHClient() jhost.set_missing_host_key_policy(paramiko.AutoAddPolicy()) #jhost.load_host_keys('/home/osmanl/.ssh/known_hosts') #disabled# jhost.connect(server, username='root', password='a', sock=vmchannel) -# -stdin, stdout, stderr = jhost.exec_command("show version | no-more") #edited# -stdin, stdout, stderr = jhost.exec_command("ifconfig") #edited# + +stdin, stdout, stderr = jhost.exec_command("cat /home/server") # print stdout.read() #edited# # From 2c91ea16822a67f23a192272dcf3bb08bc821c65 Mon Sep 17 00:00:00 2001 From: "Patel, VijayKumar" Date: Sun, 12 Jul 2020 22:33:28 +0530 Subject: [PATCH 08/22] sonarqube sample added --- pylint/demo.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 pylint/demo.py diff --git a/pylint/demo.py b/pylint/demo.py new file mode 100644 index 0000000..5b8c703 --- /dev/null +++ b/pylint/demo.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python +import string + +shift = 3 +choice = "encode" +word = "Hello" +letters = string.ascii_letters + string.punctuation + string.digits +encoded = '' +if choice == "encode": + for letter in word: + if letter == ' ': + encoded = encoded + ' ' + else: + x = letters.index(letter) + shift + encoded=encoded + letters[x] +print encoded From 9b4d1ad764fb38d23b98f1a6c8799649e56d7060 Mon Sep 17 00:00:00 2001 From: "Patel, VijayKumar" Date: Sun, 12 Jul 2020 23:10:40 +0530 Subject: [PATCH 09/22] sonarqube properties file added --- sonar-project.properties | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 sonar-project.properties diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..29626b0 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,14 @@ +sonar.projectKey= +sonar.projectName= +sonar.projectVersion=1.0 +sonar.sources= +sonar.language=py +sonar.sourceEncoding=UTF-8 +# Test Results +sonar.python.xunit.reportPath=nosetests.xml +# Coverage +sonar.python.coverage.reportPath=coverage.xml +# Linter (https://docs.sonarqube.org/display/PLUG/Pylint+Report) +#sonar.python.pylint=/usr/local/bin/pylint +#sonar.python.pylint_config=.pylintrc +#sonar.python.pylint.reportPath=pylint-report.txt From e9ba29c9acbe57e58cb3a69ba2199d66b304cf08 Mon Sep 17 00:00:00 2001 From: "Patel, VijayKumar" Date: Sun, 12 Jul 2020 23:23:54 +0530 Subject: [PATCH 10/22] sonarqube properties file added --- sonar-project.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sonar-project.properties b/sonar-project.properties index 29626b0..42ec5f6 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,5 +1,5 @@ -sonar.projectKey= -sonar.projectName= +sonar.projectKey=project:sonarqube-sample +sonar.projectName=sonarqube-sample sonar.projectVersion=1.0 sonar.sources= sonar.language=py From 231098570e26956ba7e96e625913b9a1f8731076 Mon Sep 17 00:00:00 2001 From: "Patel, VijayKumar" Date: Mon, 13 Jul 2020 13:56:23 +0530 Subject: [PATCH 11/22] sonarqube properties file added --- sonar-project.properties | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 42ec5f6..b4ec736 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,5 +1,5 @@ sonar.projectKey=project:sonarqube-sample -sonar.projectName=sonarqube-sample +sonar.projectName=sonarqube-sample1 sonar.projectVersion=1.0 sonar.sources= sonar.language=py @@ -12,3 +12,4 @@ sonar.python.coverage.reportPath=coverage.xml #sonar.python.pylint=/usr/local/bin/pylint #sonar.python.pylint_config=.pylintrc #sonar.python.pylint.reportPath=pylint-report.txt +sonar.host.url=http://10.29.41.148:9000 From 465797540c015ad918f459d255002512d1c9fbb6 Mon Sep 17 00:00:00 2001 From: Vijay Patel <35554905+easyawslearn@users.noreply.github.com> Date: Fri, 4 Sep 2020 22:53:02 +0530 Subject: [PATCH 12/22] Create SECURITY.md --- SECURITY.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..034e848 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,21 @@ +# Security Policy + +## Supported Versions + +Use this section to tell people about which versions of your project are +currently being supported with security updates. + +| Version | Supported | +| ------- | ------------------ | +| 5.1.x | :white_check_mark: | +| 5.0.x | :x: | +| 4.0.x | :white_check_mark: | +| < 4.0 | :x: | + +## Reporting a Vulnerability + +Use this section to tell people how to report a vulnerability. + +Tell them where to go, how often they can expect to get an update on a +reported vulnerability, what to expect if the vulnerability is accepted or +declined, etc. From 47fdd22780fba35b63d620e960d3dd726a78ddfc Mon Sep 17 00:00:00 2001 From: Vijay Patel <35554905+easyawslearn@users.noreply.github.com> Date: Thu, 31 Mar 2022 09:09:18 +0530 Subject: [PATCH 13/22] Create fibonacci.py --- fibonacci.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 fibonacci.py diff --git a/fibonacci.py b/fibonacci.py new file mode 100644 index 0000000..c8224a2 --- /dev/null +++ b/fibonacci.py @@ -0,0 +1,11 @@ +a, b = 0, 1 +count = 0 +input_count=10 + +print("Fibonacci sequence:") +while count < input_count: + print(a) + new = a + b + a = b + b = new + count += 1 From 07096a71ddeef2f6c9f3d2e4928ccc9f0b08662c Mon Sep 17 00:00:00 2001 From: norvel Date: Fri, 30 Sep 2022 17:05:04 +0530 Subject: [PATCH 14/22] nested stetment scop exampel --- nested_stetment_and_scop/example.py | 56 +++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 nested_stetment_and_scop/example.py diff --git a/nested_stetment_and_scop/example.py b/nested_stetment_and_scop/example.py new file mode 100644 index 0000000..87fe844 --- /dev/null +++ b/nested_stetment_and_scop/example.py @@ -0,0 +1,56 @@ +x=25 #globel +def p(): + x=50 # local + print(x) + +print(x) + +p() + + +x = 100 #global + +def p(): + global x + x=50 # local + return x + + +print(x) + +p() + +x=50 +def fun(): + global x + print(f"x is {x}") + + #Local Reassigment! + x=200 + print(f"just localy change x to {x}") + +fun() + +x=50 +def fun(): + print(f"x is {x}") + + #Local Reassigment! + x=200 + print(f"just localy change x to {x}") + +fun() + +name = "this is " + +def new(): + #ENclossing + name="summy" + print(name) + + def new1(): + name="gimmy" + print(name) + + + From 5cdd47436eda79a24c26c7dd34813f4e724d94b4 Mon Sep 17 00:00:00 2001 From: savan Date: Fri, 30 Sep 2022 17:08:13 +0530 Subject: [PATCH 15/22] lambda example added --- lambda /example1.py | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 lambda /example1.py diff --git a/lambda /example1.py b/lambda /example1.py new file mode 100644 index 0000000..aa8f492 --- /dev/null +++ b/lambda /example1.py @@ -0,0 +1,2 @@ +square= lambda num: num**2 +print(square(8)) \ No newline at end of file From 3b6a5b0d593f6ce90d659c99c99fc14d624389aa Mon Sep 17 00:00:00 2001 From: savan Date: Wed, 5 Oct 2022 13:29:42 +0530 Subject: [PATCH 16/22] example updated --- lambda /example1.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lambda /example1.py b/lambda /example1.py index aa8f492..7c51499 100644 --- a/lambda /example1.py +++ b/lambda /example1.py @@ -1,2 +1,25 @@ +## FIND THE SQUARE OF A NUMBER USING LEMBDA FUNCTION + square= lambda num: num**2 -print(square(8)) \ No newline at end of file +print(square(8)) + +## REVERSE A STRING USING LAMBDA FUNCTION + +str = 'hello guys' +# lambda returns a function object +rev_upper = lambda string: string.upper()[::-1] +print(rev_upper(str)) + +## MAP OUT THE EVEN NUMBER FROM THE LIST USING LEMBDA FUNCTION + +mynums=[1,2,3,4,5] +print(list(map(lambda num: num%2==0,mynums))) + +## FILTER OUT THE EVEN NUMBER FROM THE LIST USING LEMBDA FUNCTION +mynums=[1,2,3,4,5] +print(list(filter(lambda num: num%2==0,mynums))) + +# FIND MAXIMUM NUMBER BETWEEN TWO NUMBERS USING LEMBDA FUNCTION +Max = lambda a, b : a if(a > b) else b +print(Max(8, 4)) + From 5820d06b911acc00e6be01bf29fd3fab3274e086 Mon Sep 17 00:00:00 2001 From: savan Date: Wed, 5 Oct 2022 13:39:56 +0530 Subject: [PATCH 17/22] space issue resolve --- {lambda => lambda}/example1.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {lambda => lambda}/example1.py (100%) diff --git a/lambda /example1.py b/lambda/example1.py similarity index 100% rename from lambda /example1.py rename to lambda/example1.py From cc4b078bda4e14a3bc062f0412423848337ce185 Mon Sep 17 00:00:00 2001 From: norvel Date: Wed, 5 Oct 2022 13:53:25 +0530 Subject: [PATCH 18/22] example2_added --- lambda/example2.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lambda/example2.py diff --git a/lambda/example2.py b/lambda/example2.py new file mode 100644 index 0000000..1f98602 --- /dev/null +++ b/lambda/example2.py @@ -0,0 +1,25 @@ +# Add 10 to argument a, and return the result: +x = lambda a : a + 10 +print(x(5)) + +# square of number +squ = lambda num: num**2 +print(squ(5)) + +# Summarize argument a, b, and c and return the result: +x = lambda a, b, c : a + b + c +print(x(5, 6, 2)) + + +# reverse a string with the help of list, map, lamda +fun=["pthon","is","fun"] +ans=(list(map(lambda x:x[::-1],fun))) +print(ans) + +# first latter of word of list +name=["python","with","s3cloudehub"] +(print(list(map(lambda n:n[0],name)))) + +# print even number +mynum=[1,2,3,4,5,6] +print(list(filter(lambda num:num%2==0,mynum))) From 88d5b5cf173f85350d23495ce4bc8b4c88884660 Mon Sep 17 00:00:00 2001 From: norvel Date: Wed, 5 Oct 2022 14:05:27 +0530 Subject: [PATCH 19/22] nested_scop_local_veriabel_example --- nested_stetment_and_scop/local_example.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 nested_stetment_and_scop/local_example.py diff --git a/nested_stetment_and_scop/local_example.py b/nested_stetment_and_scop/local_example.py new file mode 100644 index 0000000..a4d408e --- /dev/null +++ b/nested_stetment_and_scop/local_example.py @@ -0,0 +1,17 @@ +# Local Reassigment! +x=200 +print(f"just localy change x to {x}") + +# How To Run +# local_ocal_example.py" +# output just localy change x to 200 + +def myfunc(): + x = 300 #local veriabal + print(x) + +myfunc() + +# How To Run +# local_ocal_example.py" +# output 300 \ No newline at end of file From 2643ce4b145c1cbfff033bac047d8d6f2e816598 Mon Sep 17 00:00:00 2001 From: savan Date: Wed, 5 Oct 2022 14:13:47 +0530 Subject: [PATCH 20/22] lambda_map_example --- lambda/example_lambda_map.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lambda/example_lambda_map.py diff --git a/lambda/example_lambda_map.py b/lambda/example_lambda_map.py new file mode 100644 index 0000000..4ad2766 --- /dev/null +++ b/lambda/example_lambda_map.py @@ -0,0 +1,19 @@ +## RETURN THE 'EVEN' IF STRING IS EVEN OTHERWISE RETURN FIRST LETTER OF A STRING + +# SLICER FUNCTION DEFINE +def slicer(mystring): +# FIND THE LENGTH OF MYSTRING VARIABLE + if len(mystring)%2 == 0: +# IF THE LENGTH OF MYSTRING IS EVEN IT RETURNS EVEN + return 'even' + else: +# OTHERWISE RETURNS THE FIRST LETTER OF THE STRING + return mystring[0] +names = ['adam','eve','sla','rock','rio'] +# HERE WE PRINT WITH THE MAP AND IN LIST FORMAT +print(list(map(slicer,names))) + +## HOW TO RUN + +# python: example_lambda_map.py +# ['even', 'e', 's', 'even', 'r'] From 7373f4f29b8c15296d0fd4d3d6895b8dcefc92d9 Mon Sep 17 00:00:00 2001 From: savan Date: Wed, 5 Oct 2022 14:23:00 +0530 Subject: [PATCH 21/22] test --- lambda/example_lambda_filter.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 lambda/example_lambda_filter.py diff --git a/lambda/example_lambda_filter.py b/lambda/example_lambda_filter.py new file mode 100644 index 0000000..8c6c459 --- /dev/null +++ b/lambda/example_lambda_filter.py @@ -0,0 +1,28 @@ +## RETURN THE NUMBER IF IT IS EVEN + +# CHECK_EVEN FUNCTION DEFINE +def check_even(num): + +# RETURN THE NUMBER IF THE CONDITION IS TRUE + return num%2==0 + +# GIVING INPUTS TO THE NUMS +nums = [1,2,3,4,5,6] + +# HERE WE PRINT WITH THE FILTER AND IN LIST FORMAT +print(list(filter(check_even,nums))) + +# PRINT USING FOR LOOP +for i in filter(check_even,nums): + print(i) + +## SIMPLE OUTPUT +# HOW TO RUN +# PYTHON: example_lambda_filter.py +# [2, 4, 6] + +## OUTPUT AFTER USING THE FOR LOOP +# PYTHON: example_lambda_filter.py +# 2 +# 4 +# 6 \ No newline at end of file From 71c591fcbb6ba51e3fd5a7f01771aee89e762007 Mon Sep 17 00:00:00 2001 From: norvel Date: Fri, 7 Oct 2022 15:27:25 +0530 Subject: [PATCH 22/22] python_input --- python_input/python_input.py | 70 ++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 python_input/python_input.py diff --git a/python_input/python_input.py b/python_input/python_input.py new file mode 100644 index 0000000..7141ed0 --- /dev/null +++ b/python_input/python_input.py @@ -0,0 +1,70 @@ +user = input("enter a any key : >>>") #input from user + +if (type(user)) == int: # chack type + print("it is a number") +else: + print("it is not a number") + +# ///////output///////// + # enter a any key : >>>q + # it is not a number + + +user = input("enter a number:>>>>") #input from user +try: + val = int(user) # pass if number +except ValueError: + print("that is not a number") # if not message print + +# ///////output///////// +# enter a number:>>>>q +# that is not a input + + +user = input("enter a number:>>") #input from user +if user.isdigit(): + print("it is a digit") +else: + print("it is not a digit:") + +# ///////output///////// +# enter a number:>>1 +# it is a digit + +# enter a number:>>a +# it is not a digit: + + +def user(): + choice ="worng" + while choice.isdigit() == False: + choice = input("plese enter a number:") + return int(choice) +user() + +# output 1 +# plese enter a number:12 + +# output 2 +# enter a number:>>q +# it is not a digit: + + +def user(): + choice = "worng" + acceptable_rang = range(0,10) + with_rang = False + + while choice.isdigit() == False or with_rang==False: + choice = input("enter a number (0,10):") + + if choice.isdigit() == False: + print("sorry this is not a digit") + + if choice.isdigit() == True: + if int(choice) in acceptable_rang: + with_rang = True + else: + with_rang = False + + return int(choice) \ No newline at end of file