Re: Teaching Python
Hacking?? -- http://mail.python.org/mailman/listinfo/python-list
Re: Teaching Python
Lot of tutorials on net. Specially Python's own site. Dive into Python seems a good start -- http://mail.python.org/mailman/listinfo/python-list
request.post in If condition
Hi All, I'm trying to hit request.post with condition using if-else as below... I;m posting the full script here...as I've tried declaring post url details tested with multiple places. -- https://mail.python.org/mailman/listinfo/python-list
Re: request.post in If condition
Hi All,
I'm trying to hit request.post with condition using if-else as below...
I;m posting the full script here...as I've tried declaring post url details
tested with multiple places..
If condition for disk utiliztion is working perfect ,however request.post
is not hitting.
Please suggest any hint/clue as I'm a new learner in python.
Regards,
Sourav
-
#!/usr/bin/python
import re,sys,commands
import requests
# Set the request parameters
url = 'https://dev.service-now.com/api/now/table/incident'
# Eg. User name="admin", Password="admin" for this code sample.
user = 'admin'
pwd = ''
# Set proper headers
headers = {"Content-Type":"application/json","Accept":"application/json"}
#
#Set variables
command = "df /"
critical = 50.0
warning = 40.0
#
#build regex
dfPattern = re.compile('[0-9]+')
#get disk utilization
diskUtil = commands.getstatusoutput(command)
#split out the util %
diskUtil = diskUtil[1].split()[11]
#look for a match. If no match exit and return an
#UNKNOWN (3) state to Nagios
matchobj = dfPattern.match(diskUtil)
if (matchobj):
diskUtil = eval(matchobj.group(0))
else:
print "STATE UNKNOWN"
sys.exit(3)
#Determine state to pass to Nagios
#CRITICAL = 2
#WARNING = 1
#OK = 0
if diskUtil >= critical:
url = 'https://dev.service-now.com/api/now/table/incident'
user = 'admin'
pwd = ''
headers = {"Content-Type":"application/json","Accept":"application/
json"}
requests.post(url, auth=(user, pwd), headers=headers
,data="{\"assignment_group\":\Hardware\",\"short_description\":\"Threshold
critical\"}")
print "FREE SPACE CRITICAL: '/' is %.2f%% full" % (float(diskUtil))
sys.exit(2)
elif diskUtil >= warning:
requests.post(url, auth=(user, pwd), headers=headers
,data="{\"assignment_group\":\Hardware\",\"short_description\":\"Threshold
Warning\"}")
print "FREE SPACE WARNING: '/' is %.2f%% full" % (float(diskUtil))
sys.exit(1)
else:
print "FREE SPACE OK: '/' is %.2f%% full" % (float(diskUtil))
sys.exit(0)
On Mon, Oct 30, 2017 at 4:04 PM, sourav voip
wrote:
> Hi All,
>
> I'm trying to hit request.post with condition using if-else as below...
> I;m posting the full script here...as I've tried declaring post url
> details tested with multiple places.
>
>
>
>
>
--
https://mail.python.org/mailman/listinfo/python-list
Paramiko installation issue
Hello, I was using Python 3.8 32 bit ,but while trying to install the paramiko there is some wheel issue I'm facing. definitely it is due to version mismatching of the python and the paramiko. I have uninstalled 3.8 Could you please help me by providing the exact paramiko files for 3.8 then i will again try to install it other wise check the below paramiko files and let me know which python version is compatible with this. Paramiko files :- pycparser-2.20-py2.py3-none-any.whl -- Installed six-1.16.0-py2.py3-none-any.whl -- Installed PyNaCl-1.4.0-cp37-cp37m-win_amd64.whl -- error cryptography-3.4.7-cp36-abi3-win_amd64.whl --error cffi-1.14.5-cp37-cp37m-win_amd64.whl -- error bcrypt-3.2.0-cp36-abi3-win_amd64.whl -- error paramiko-2.7.2-py2.py3-none-any.whl --error Please help me to get the exact version. Thanks, Sourav 9836231860 -- Thanks & Regards, Sourav Bose, +919836231860 -- https://mail.python.org/mailman/listinfo/python-list
Need help for python on my pc.
Hello Python team, I'm using python 3.7(32 bit) for several months on my same laptop (x64 processor). I worked on some django project very swiftly without any problem. But for a few days I am facing a serious problem. My python files are not showing properly by the file manager. It is just showing 'python source file' without any logo. When I open my cmd to work on django, it is not also working though virtualenv is working properly I think. I'm sending some screenshots of cmd and files for your reference. I've tried reinstalling (64 bit) and repairing of python but nothing is working. I want your help to sort out this issue. From Sourav Banik, Dhaka,Bangladesh. -- https://mail.python.org/mailman/listinfo/python-list
Need help for python on my pc.
Hello Python team, I'm using python 3.7(32 bit) for several months on my same laptop (x64 processor). I worked on some django project very swiftly without any problem. But for a few days I am facing a serious problem. My python files are not showing properly by the file manager. It is just showing 'python source file' without any logo. When I open my cmd to work on django, it is not also working though virtualenv is working properly I think. I'm sending some screenshots of cmd and files for your reference. I've tried reinstalling (64 bit) and repairing of python but nothing is working. I want your help to sort out this issue. From Sourav Banik, Dhaka,Bangladesh. -- https://mail.python.org/mailman/listinfo/python-list
There is some problem in the python software it was not installing in my laptop
Sent from [1]Mail for Windows 10 References Visible links 1. https://go.microsoft.com/fwlink/?LinkId=550986 -- https://mail.python.org/mailman/listinfo/python-list
problem at the time of using editor
when I am using the editor to write a long program and trying to run it the python command line showing it syntax error -- https://mail.python.org/mailman/listinfo/python-list
