Re: [Tutor] Help with python 2.7

2017-10-30 Thread Mike Miller
This is a mailing list, so the best way to get help is to send a request
with code examples and most importantly what you have already tried. That
being said, there are some smart people on here, much more experienced than
I am on Python so I would say you can get help with any problem you may
have.

I have taken the MIT course you are talking about and it is quite
challenging (perhaps a little more than it should be) and my oldest son at
one point took the Microsoft MVA course on the subject of python and he
said it was very good (surprisingly enough)..he is a Java programmer
primarily and said that for someone with even average skill and ability,
the MS course is actually great and easy to follow on. Good luck, and
welcome.

Mike

On Mon, Oct 30, 2017, 7:24 PM Alchemy  wrote:

> Hello,
>
> I am in the midst of a career change from renovations to computers.
> I’m used to working conceptually and understand coding is that.
> I am taking an online opencourseare classfrom MIT “Introduction to
> computer science and programming”.
> The class uses python 2.7, has video lectures and homework assignments
> that are coding exercises.
> Python seems like the root to everything in the computers possabilities
> and I want to internalize it.
> I’m stuck on the homework ,butmore importantly stuck on the concepts
> behind the homework.
>
> Can your orginazation help?
>
> gratefully,
>
> Ian
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help with python 2.7

2017-10-30 Thread Alan Gauld via Tutor
On 30/10/17 21:02, Alchemy wrote:

> I’m stuck on the homework ,butmore importantly stuck on the concepts behind 
> the homework.
> 
> Can your orginazation help?

Yes, we are happy to help with homework although we won't
usually give you the full answer. We will make suggestions
and are happy to review or comment on code.

To make life easier:

Always post any code in plain text (email messes up the
formatting of html/rtf) And put it inline not as an attachment.

Always post the full text of any error messages.

Mention the OS and Python versions.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Help with python 2.7

2017-10-30 Thread Alchemy
Hello,

I am in the midst of a career change from renovations to computers.
I’m used to working conceptually and understand coding is that.
I am taking an online opencourseare classfrom MIT “Introduction to computer 
science and programming”.
The class uses python 2.7, has video lectures and homework assignments that are 
coding exercises.
Python seems like the root to everything in the computers possabilities and I 
want to internalize it.
I’m stuck on the homework ,butmore importantly stuck on the concepts behind the 
homework.

Can your orginazation help?

gratefully,

Ian 

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] request.post in If condition

2017-10-30 Thread sourav voip
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.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] request.post in If condition

2017-10-30 Thread sourav voip
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.
>
>
>
>
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor