Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 5d55b0e358fdaca323cec038e95254269a38a788 @spicyj spicyj committed Jul 8, 2012
Showing with 57 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +3 −0 .gitmodules
  3. +1 −0 hipchat
  4. +49 −0 notify.py
  5. +1 −0 requirements.txt
  6. +1 −0 third_party/python-hipchat-src
@@ -0,0 +1,2 @@
+secrets.py
+*.py[co]
@@ -0,0 +1,3 @@
+[submodule "third_party/python-hipchat-src"]
+ path = third_party/python-hipchat-src
+ url = https://github.com/tagged/python-hipchat.git
@@ -0,0 +1,49 @@
+import json
+import time
+import urllib2
+
+import hipchat.config
+import hipchat.room
+
+import secrets
+
+hipchat.config.token = secrets.hipchat_token
+
+
+def hipchat_notify(room_id, message):
+ hipchat.room.Room.message(**{
+ 'room_id': room_id,
+ 'from': 'Mr Monkey',
@spicyj

spicyj Jul 8, 2012

Owner

pure kwargs don't work here because from is a Python keyword…

@divad12

divad12 Jul 9, 2012

OK, make that a comment then.

+ 'message': message,
+ 'color': 'purple',
+ })
+
+
+def get_version():
+ try:
+ f = urllib2.urlopen('http://www.khanacademy.org/api/v1/dev/version')
+ data = json.loads(f.read())
+ except urllib2.HTTPError, e:
+ print "Couldn't get version: %s\n%s" % (e, e.read())
+ return None
+ finally:
+ f.close()
+
+ # We only want the major version
+ return data['version_id'].split('.', 2)[0]
@divad12

divad12 Jul 9, 2012

What's the point of specifying max splits if we're just returning the first element?

@spicyj

spicyj Jul 9, 2012

Owner

No reason! :)

+
+
+last_version = None
@divad12

divad12 Jul 9, 2012

Could you make this not a global var?

@spicyj

spicyj Jul 9, 2012

Owner

Oops, good catch.

+
+if __name__ == '__main__':
+ while True:
+ version = get_version()
+
+ if version is not None:
+ if last_version is not None and version != last_version:
+ hipchat_notify(
+ 19528, ('App Engine (www.khanacademy.org) default version '
@spicyj

spicyj Jul 8, 2012

Owner

19528 is code for "1s and 0s"

@divad12

divad12 Jul 9, 2012

Could you make this comment into a constant then, like HIPCHAT_DEV_ROOM or something

@divad12

divad12 Jul 9, 2012

Ah, I see you commented in 722e84c

+ 'changed to %s' % version))
+ last_version = version
+
+ time.sleep(10)
@@ -0,0 +1 @@
+configobj
@divad12

divad12 Jul 9, 2012

Apologies for my ignorance, but what is this used for?

@spicyj

spicyj Jul 9, 2012

Owner

hipchat depends on it… :(

4 comments on commit 5d55b0e

Owner

spicyj commented on 5d55b0e Jul 8, 2012

@divad12 review?

Is this going to run on one of our EC2 instances? If so, have you edited the corresponding aws-config setup script?

Owner

spicyj replied Jul 9, 2012

Not yet! Will do that in a few minutes.

Nice! LGTM

Please sign in to comment.