From db4318a3da6861f447eff3735e6af767dce84b29 Mon Sep 17 00:00:00 2001 From: peshal2404 Date: Fri, 10 Apr 2020 17:23:01 -0500 Subject: [PATCH 1/8] save --- .../inspectionProfiles/profiles_settings.xml | 6 +++++ .idea/modules.xml | 8 +++++++ Test.py | 22 +++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/modules.xml create mode 100644 Test.py diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..ebcc356 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Test.py b/Test.py new file mode 100644 index 0000000..7b17d26 --- /dev/null +++ b/Test.py @@ -0,0 +1,22 @@ +#!/usr/bin/python +import mysql.connector +import os +import subprocess +import sys + +#subprocess.call("date") + +f = os.popen('date') +now = f.read() +print ("Today is ", now) +##subprocess.call(["cat", "/etc/resolv.conf"]) + +cmdping = "ping -c2 peshal.com.np" +p = subprocess.Popen(cmdping, shell=True, stderr=subprocess.PIPE) +while True: + out = p.stderr.read(1) + if out == '' and p.poll() != None: + break + if out != '': + sys.stdout.write(out) + sys.stdout.flush() From f5165d8bcab3bd63d663438a742c705a4d159e14 Mon Sep 17 00:00:00 2001 From: peshal2404 Date: Fri, 10 Apr 2020 17:26:19 -0500 Subject: [PATCH 2/8] save --- .idea/misc.xml | 4 ++++ .idea/python-tutorial.iml | 8 ++++++++ .idea/workspace.xml | 7 +++++++ Test.py | 11 +---------- 4 files changed, 20 insertions(+), 10 deletions(-) create mode 100644 .idea/misc.xml create mode 100644 .idea/python-tutorial.iml create mode 100644 .idea/workspace.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..d1e22ec --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/python-tutorial.iml b/.idea/python-tutorial.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/python-tutorial.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..a35a6fe --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Test.py b/Test.py index 7b17d26..2a1f23e 100644 --- a/Test.py +++ b/Test.py @@ -9,14 +9,5 @@ f = os.popen('date') now = f.read() print ("Today is ", now) -##subprocess.call(["cat", "/etc/resolv.conf"]) +subprocess.call(["cat", "/etc/resolv.conf"]) -cmdping = "ping -c2 peshal.com.np" -p = subprocess.Popen(cmdping, shell=True, stderr=subprocess.PIPE) -while True: - out = p.stderr.read(1) - if out == '' and p.poll() != None: - break - if out != '': - sys.stdout.write(out) - sys.stdout.flush() From ea9a088b28febbe92fc78f4b95b6071a118325a8 Mon Sep 17 00:00:00 2001 From: peshal2404 Date: Fri, 10 Apr 2020 17:29:55 -0500 Subject: [PATCH 3/8] save1 --- Test.py | 1 + 1 file changed, 1 insertion(+) diff --git a/Test.py b/Test.py index 2a1f23e..cf431cb 100644 --- a/Test.py +++ b/Test.py @@ -11,3 +11,4 @@ print ("Today is ", now) subprocess.call(["cat", "/etc/resolv.conf"]) +eee \ No newline at end of file From 0c1051fbd29ee21bfdb4dedad0181d9a6cb7fb4e Mon Sep 17 00:00:00 2001 From: peshal2404 Date: Fri, 10 Apr 2020 17:32:45 -0500 Subject: [PATCH 4/8] save1 --- Test.py | 1 - 1 file changed, 1 deletion(-) diff --git a/Test.py b/Test.py index cf431cb..2a1f23e 100644 --- a/Test.py +++ b/Test.py @@ -11,4 +11,3 @@ print ("Today is ", now) subprocess.call(["cat", "/etc/resolv.conf"]) -eee \ No newline at end of file From d460d8a26bf56cb272d776f36ad3b3cb1506df8b Mon Sep 17 00:00:00 2001 From: peshal2404 Date: Fri, 10 Apr 2020 17:33:29 -0500 Subject: [PATCH 5/8] save1 --- Test.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Test.py b/Test.py index 2a1f23e..a04a7d7 100644 --- a/Test.py +++ b/Test.py @@ -11,3 +11,21 @@ print ("Today is ", now) subprocess.call(["cat", "/etc/resolv.conf"]) +###MySQL### + +import mysql.connector + +from mysql.connector import errorcode + +try: + cnx = mysql.connector.connect(user='scott', + database='employ') +except mysql.connector.Error as err: + if err.errno == errorcode.ER_ACCESS_DENIED_ERROR: + print("Something is wrong with your user name or password") + elif err.errno == errorcode.ER_BAD_DB_ERROR: + print("Database does not exist") + else: + print(err) +else: + cnx.close() \ No newline at end of file From a99145aba68b7693fd25fb49061c90b50f1f4ea1 Mon Sep 17 00:00:00 2001 From: peshal2404 Date: Tue, 14 Apr 2020 20:45:13 -0500 Subject: [PATCH 6/8] save1 --- Test.py | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/Test.py b/Test.py index a04a7d7..b16b6f9 100644 --- a/Test.py +++ b/Test.py @@ -2,30 +2,32 @@ import mysql.connector import os import subprocess +import requests import sys - -#subprocess.call("date") - f = os.popen('date') now = f.read() print ("Today is ", now) subprocess.call(["cat", "/etc/resolv.conf"]) - ###MySQL### -import mysql.connector +# import mysql.connector +# +# from mysql.connector import errorcode +# +# try: +# cnx = mysql.connector.connect(user='scott', +# database='employ') +# except mysql.connector.Error as err: +# if err.errno == errorcode.ER_ACCESS_DENIED_ERROR: +# print("Something is wrong with your user name or password") +# elif err.errno == errorcode.ER_BAD_DB_ERROR: +# print("Database does not exist") +# else: +# print(err) +# else: +# cnx.close() + +Home_Dir = /Users/peshal/Downloads + -from mysql.connector import errorcode -try: - cnx = mysql.connector.connect(user='scott', - database='employ') -except mysql.connector.Error as err: - if err.errno == errorcode.ER_ACCESS_DENIED_ERROR: - print("Something is wrong with your user name or password") - elif err.errno == errorcode.ER_BAD_DB_ERROR: - print("Database does not exist") - else: - print(err) -else: - cnx.close() \ No newline at end of file From aff22efd572fe21fefa68d7435122b5817fc68a2 Mon Sep 17 00:00:00 2001 From: peshal2404 Date: Tue, 14 Apr 2020 20:56:19 -0500 Subject: [PATCH 7/8] save1 --- Test.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Test.py b/Test.py index b16b6f9..0264ef5 100644 --- a/Test.py +++ b/Test.py @@ -2,18 +2,27 @@ import mysql.connector import os import subprocess -import requests +import requests import sys +# response = requests.get("http://api.open-notify.org/this-api-doesnt-exist") +# print(response.status_code) +response = requests.get("http://api.open-notify.org/astros.json") +print(response.status_code) +print(response.json()) f = os.popen('date') now = f.read() print ("Today is ", now) -subprocess.call(["cat", "/etc/resolv.conf"]) -###MySQL### +import json +def jprint(obj): + # create a formatted string of the Python JSON object + text = json.dumps(obj, sort_keys=True, indent=4) + print(text) +jprint(response.json()) +#subprocess.call(["cat", "/etc/resolv.conf"]) +###MySQL### # import mysql.connector -# # from mysql.connector import errorcode -# # try: # cnx = mysql.connector.connect(user='scott', # database='employ') @@ -27,7 +36,7 @@ # else: # cnx.close() -Home_Dir = /Users/peshal/Downloads +#Home_Dir = /Users/peshal/Downloads From 911da427fb43c855fe6ad0ae3e0355bc4e8c2691 Mon Sep 17 00:00:00 2001 From: peshal2404 Date: Tue, 14 Apr 2020 22:47:44 -0500 Subject: [PATCH 8/8] save1 --- Test.py | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/Test.py b/Test.py index 0264ef5..0afb070 100644 --- a/Test.py +++ b/Test.py @@ -1,24 +1,24 @@ #!/usr/bin/python +## Written by Peshal Oli import mysql.connector +import json import os import subprocess import requests import sys # response = requests.get("http://api.open-notify.org/this-api-doesnt-exist") # print(response.status_code) -response = requests.get("http://api.open-notify.org/astros.json") -print(response.status_code) -print(response.json()) -f = os.popen('date') -now = f.read() -print ("Today is ", now) - -import json -def jprint(obj): - # create a formatted string of the Python JSON object - text = json.dumps(obj, sort_keys=True, indent=4) - print(text) -jprint(response.json()) +# response = requests.get("http://api.open-notify.org/astros.json") +# print(response.status_code) +# print(response.json()) +# f = os.popen('date') +# now = f.read() +# print ("Today is ", now) +# def jprint(obj): +# # create a formatted string of the Python JSON object +# text = json.dumps(obj, sort_keys=True, indent=4) +# print(text) +# jprint(response.json()) #subprocess.call(["cat", "/etc/resolv.conf"]) ###MySQL### # import mysql.connector @@ -37,6 +37,13 @@ def jprint(obj): # cnx.close() #Home_Dir = /Users/peshal/Downloads +subprocess.call(["ls", "-l", "/Users/peshal/Downloads/"]) + +##For API +import urllib +import json + +