<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>python &#8211; Scott Mcintyre</title>
	<atom:link href="https://scott.cm/tag/python/feed/" rel="self" type="application/rss+xml" />
	<link>https://scott.cm</link>
	<description>Web Operations Engineer,  Linux Systems Administrator,  mySQL DBA,  MongoDB DBA,  Python+PHP Developer,  Performance Engineer</description>
	<lastBuildDate>Wed, 02 Jul 2014 11:17:06 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.2.2</generator>
	<item>
		<title>Varnish Nagios Check</title>
		<link>https://scott.cm/varnish-nagios-check/</link>
				<comments>https://scott.cm/varnish-nagios-check/#comments</comments>
				<pubDate>Thu, 19 Apr 2012 20:34:35 +0000</pubDate>
		<dc:creator><![CDATA[Scott Mcintyre]]></dc:creator>
				<category><![CDATA[System Administration]]></category>
		<category><![CDATA[icinga]]></category>
		<category><![CDATA[nagios]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[varnish]]></category>

		<guid isPermaLink="false">https://scott.cm/?p=157</guid>
				<description><![CDATA[**Update: 2 July 2014. Updated to new version 1.1 I have written a check for nagios/icinga to check the varnish backend health. You can get the latest version from github . The version at the time of posting at the bottom of this message. The defaults are RHEL defaults and]]></description>
								<content:encoded><![CDATA[<p><strong>**Update: 2 July 2014.  Updated to new version 1.1</strong></p>
<p>I have written a check for nagios/icinga to check the varnish backend health.  You can get the latest version from <a href="https://github.com/admingeekz/nagios-varnish" title="Check Varnish Backends" target="_blank">github </a>.  The version at the time of posting at the bottom of this message.</p>
<p>The defaults are RHEL defaults and ./check_varnishbackends.py should work without any options unless you want to override them.   Here is the Nagios/Icinga Setup,</p>
<p>Register the service</p><pre class="crayon-plain-tag">define service {
	register			0
	name				check_varnishbackends
	service_description		Varnish Backends
	use				generic-service
}</pre><p></p>
<p>Assign to host &#8220;server&#8221;</p><pre class="crayon-plain-tag">define service {
	service_description		Varnish Backend
	host_name			server
	use				check_varnishbackends
	check_command			remote_nrpe!check_varnishbackends -a &quot;127.0.0.1&quot; &quot;6082&quot; &quot;/etc/varnish/secret&quot; &quot;/usr/bin/varnishadm&quot;
}</pre><p></p>
<p>Setup NRPE (Make sure user has permission to varnish secret file or use sudo)</p><pre class="crayon-plain-tag">command[check_varnishbackends]=/usr/local/nagios/libexec/check_varnishbackends.py --host $ARG1$ --port $ARG2$ --secret $ARG3$ --path $ARG4$</pre><p></p>
<p>Version at time of posting,</p>
<p></p><pre class="crayon-plain-tag">#!/usr/bin/env python
# Nagios Varnish Backend Check
# v1.1
# URL: www.admingeekz.com
# Contact: sales@admingeekz.com
#
#
# Copyright (c) 2013, AdminGeekZ Ltd
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2, as
# published by the Free Software Foundation.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#

import sys
import optparse
import subprocess

def runcommand(command, exit_on_fail=True):
    try:
      process = subprocess.Popen(command.split(&quot; &quot;), stdout=subprocess.PIPE)
      output, unused_err = process.communicate()
      retcode = process.poll()
      return output

    except OSError, e:
      print &quot;Error: Executing command failed,  does it exist?&quot;
      sys.exit(2)


def main(argv):
  o = optparse.OptionParser(conflict_handler=&quot;resolve&quot;, description=&quot;Nagios plugin to check varnish backend health.&quot;)
  o.add_option('-H', '--host', action='store', type='string', dest='host', default='127.0.0.1', help='The ip varnishadm is listening on')
  o.add_option('-P', '--port', action='store', type='int', dest='port', default=6082, help='The port varnishadm is listening on')
  o.add_option('-s', '--secret', action='store', type='string', dest='secret', default='/etc/varnish/secret', help='The path to the secret file')
  o.add_option('-p', '--path', action='store', type='string', dest='path', default='/usr/bin/varnishadm', help='The path to the varnishadm binary')

  options=o.parse_args()[0]
  command = runcommand(&quot;%(path)s -S %(secret)s -T %(host)s:%(port)s debug.health&quot; % options.__dict__)
  backends = command.split(&quot;\n&quot;)
  backends_healthy, backends_sick = [], []
  for line in backends:
    if line.startswith(&quot;Backend&quot;) and line.find(&quot;test&quot;)==-1:
      if line.endswith(&quot;Healthy&quot;):
        backends_healthy.append(line.split(&quot; &quot;)[1])
      else:
        backends_sick.append(line.split(&quot; &quot;)[1])
 
  if backends_sick:
    print &quot;%s backends are down.  %s&quot; % (len(backends_sick), &quot;&quot;.join(backends_sick))
    sys.exit(2)

  if not backends_sick and not backends_healthy:
    print &quot;No backends detected.  If this is an error, see readme.txt&quot;
    sys.exit(1)

  print &quot;All %s backends are healthy&quot; % (len(backends_healthy))
  sys.exit(0)


if __name__ == &quot;__main__&quot;:
    main(sys.argv[1:])</pre><p></p>
]]></content:encoded>
							<wfw:commentRss>https://scott.cm/varnish-nagios-check/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
							</item>
		<item>
		<title>Learning Python</title>
		<link>https://scott.cm/learning_python/</link>
				<comments>https://scott.cm/learning_python/#respond</comments>
				<pubDate>Thu, 24 Nov 2011 12:24:02 +0000</pubDate>
		<dc:creator><![CDATA[Scott Mcintyre]]></dc:creator>
				<category><![CDATA[Me]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[football scores python]]></category>
		<category><![CDATA[learn python in 2 days]]></category>
		<category><![CDATA[learning python]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[python threading]]></category>
		<category><![CDATA[python youtube]]></category>
		<category><![CDATA[server version scraper]]></category>
		<category><![CDATA[top 100 charts]]></category>
		<category><![CDATA[youtube charts]]></category>

		<guid isPermaLink="false">https://scott.cm/?p=72</guid>
				<description><![CDATA[I had set myself a goal to make around 20 blog posts per year, it&#8217;s now almost December and I still have not bothered. It is safe to say I am not exactly prolific. I decided that I would learn python, surprisingly it&#8217;s been really easy to pick up and]]></description>
								<content:encoded><![CDATA[<p>I had set myself a goal to make around 20 blog posts per year, it&#8217;s now almost December and I still have not bothered. It is safe to say I am not exactly prolific.</p>
<p>I decided that I would learn python, surprisingly it&#8217;s been really easy to pick up and I thought I would share some of the things I made in my first 2 days of python.</p>
<p>The first I written was to phrase the results from yahoo&#8217;s football score page(http://uk.eurosport.yahoo.com/football/premier-league/2011-2012/results/2011_08.html). I was on this page anyway and thought why not!</p>
<blockquote><p>#!/usr/bin/python<br />
import urllib2<br />
import re<br />
response = urllib2.urlopen(&#8216;http://uk.eurosport.yahoo.com/football/premier-league/2011-2012/results/2011_08.html&#8217;)<br />
html = response.read()<br />
re_channel = re.compile(&#8220;&lt;td class=\&#8221;ko\&#8221;&gt;&lt;abbr class=\&#8221;dtstart\&#8221; title=\&#8221;\&#8221;&gt;([0-9a-zA-z ,:]*)&lt;/abbr&gt;&lt;/td&gt;&#8221; +<br />
 &#8220;\n &lt;td class=\&#8221;match.*?\n&#8221; +<br />
 &#8221; &lt;a href=.*?\&#8221;&gt;&#8221; +<br />
  &#8220;\n &lt;span class=\&#8221;home\&#8221;&gt;([a-zA-Z ]*)&lt;/span&gt;.*?&#8221; +<br />
  &#8220;\n &lt;span class=\&#8221;score\&#8221;&gt;([0-9 :-]*)&lt;/span&gt;.*?&#8221; +<br />
  &#8220;\n &lt;span class=\&#8221;away\&#8221;&gt;([a-zA-Z ]*)&lt;/span&gt;&#8221;, re.I | re.S | re.M)<br />
find_result = re_channel.findall(html)<br />
print find_result</p></blockquote>
<blockquote></blockquote>
<p>Sample output</p>
<p>[(&#8217;13 Aug, 15:00&#8242;, &#8216;Wigan Athletic&#8217;, &#8216;1 &#8211; 1&#8217;, &#8216;Norwich City&#8217;), (&#8217;13 Aug, 15:00&#8242;, &#8216;Fulham&#8217;, &#8216;0 &#8211; 0&#8217;, &#8216;Aston Villa&#8217;), (&#8217;13 Aug, 15:00&#8242;, &#8216;Blackburn Rovers&#8217;, &#8216;1 &#8211; 2&#8217;, &#8216;Wolverhampton Wanderers&#8217;), (&#8217;13 Aug, 15:00&#8242;, &#8216;Liverpool&#8217;, &#8216;1 &#8211; 1&#8217;, &#8216;Sunderland&#8217;), (&#8217;13 Aug, 15:00&#8242;, &#8216;Queens Park Rangers&#8217;, &#8216;0 &#8211; 4&#8217;, &#8216;Bolton Wanderers&#8217;), (&#8217;13 Aug, 17:30&#8242;, &#8216;Newcastle United&#8217;, &#8216;0 &#8211; 0&#8217;, &#8216;Arsenal&#8217;), (&#8217;14 Aug, 13:30&#8242;, &#8216;Stoke City&#8217;, &#8216;0 &#8211; 0&#8217;, &#8216;Chelsea&#8217;), (&#8217;14 Aug, 16:00&#8242;, &#8216;West Bromwich Albion&#8217;, &#8216;1 &#8211; 2&#8217;, &#8216;Manchester United&#8217;), (&#8217;15 Aug, 20:00&#8242;, &#8216;Manchester City&#8217;, &#8216;4 &#8211; 0&#8217;, &#8216;Swansea City&#8217;), (&#8217;20 Aug, 12:00&#8242;, &#8216;Sunderland&#8217;, &#8216;0 &#8211; 1&#8217;, &#8216;Newcastle United&#8217;), (&#8217;20 Aug, 12:45&#8242;, &#8216;Arsenal&#8217;, &#8216;0 &#8211; 2&#8217;, &#8216;Liverpool&#8217;), (&#8217;20 Aug, 15:00&#8242;, &#8216;Swansea City&#8217;, &#8216;0 &#8211; 0&#8217;, &#8216;Wigan Athletic&#8217;), (&#8217;20 Aug, 15:00&#8242;, &#8216;Aston Villa&#8217;, &#8216;3 &#8211; 1&#8217;, &#8216;Blackburn Rovers&#8217;), (&#8217;20 Aug, 15:00&#8242;, &#8216;Everton&#8217;, &#8216;0 &#8211; 1&#8217;, &#8216;Queens Park Rangers&#8217;), (&#8217;20 Aug, 17:30&#8242;, &#8216;Chelsea&#8217;, &#8216;2 &#8211; 1&#8217;, &#8216;West Bromwich Albion&#8217;), (&#8217;21 Aug, 13:30&#8242;, &#8216;Norwich City&#8217;, &#8216;1 &#8211; 1&#8217;, &#8216;Stoke City&#8217;), (&#8217;21 Aug, 14:05&#8242;, &#8216;Wolverhampton Wanderers&#8217;, &#8216;2 &#8211; 0&#8217;, &#8216;Fulham&#8217;), (&#8217;21 Aug, 16:00&#8242;, &#8216;Bolton Wanderers&#8217;, &#8216;2 &#8211; 3&#8217;, &#8216;Manchester City&#8217;), (&#8217;22 Aug, 20:00&#8242;, &#8216;Manchester United&#8217;, &#8216;3 &#8211; 0&#8217;, &#8216;Tottenham Hotspur&#8217;), (&#8217;27 Aug, 12:05&#8242;, &#8216;Aston Villa&#8217;, &#8216;0 &#8211; 0&#8217;, &#8216;Wolverhampton Wanderers&#8217;), (&#8217;27 Aug, 12:30&#8242;, &#8216;Wigan Athletic&#8217;, &#8216;2 &#8211; 0&#8217;, &#8216;Queens Park Rangers&#8217;), (&#8217;27 Aug, 15:00&#8242;, &#8216;Swansea City&#8217;, &#8216;0 &#8211; 0&#8217;, &#8216;Sunderland&#8217;), (&#8217;27 Aug, 15:00&#8242;, &#8216;Chelsea&#8217;, &#8216;3 &#8211; 1&#8217;, &#8216;Norwich City&#8217;), (&#8217;27 Aug, 15:00&#8242;, &#8216;Blackburn Rovers&#8217;, &#8216;0 &#8211; 1&#8217;, &#8216;Everton&#8217;), (&#8217;27 Aug, 17:30&#8242;, &#8216;Liverpool&#8217;, &#8216;3 &#8211; 1&#8217;, &#8216;Bolton Wanderers&#8217;), (&#8217;28 Aug, 13:00&#8242;, &#8216;Newcastle United&#8217;, &#8216;2 &#8211; 1&#8217;, &#8216;Fulham&#8217;), (&#8217;28 Aug, 13:30&#8242;, &#8216;Tottenham Hotspur&#8217;, &#8216;1 &#8211; 5&#8217;, &#8216;Manchester City&#8217;), (&#8217;28 Aug, 15:00&#8242;, &#8216;West Bromwich Albion&#8217;, &#8216;0 &#8211; 1&#8217;, &#8216;Stoke City&#8217;), (&#8217;28 Aug, 16:00&#8242;, &#8216;Manchester United&#8217;, &#8216;8 &#8211; 2&#8217;, &#8216;Arsenal&#8217;)]</p>
<p>The next was to obtain a list of the uk charts top 100 and find the youtube video for it.</p>
<blockquote><p>#!/usr/bin/python<br />
import urllib<br />
import urllib2<br />
import re<br />
import sys<br />
from BeautifulSoup import BeautifulStoneSoup  </p>
<p>def getvideolink(link):<br />
  request = urllib2.Request(link)<br />
  request.add_header(&#8216;User-Agent&#8217;, &#8220;Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/533.3 (KHTML, like Gecko) Qt/4.7.0 Safari/533.3&#8221;)<br />
  response = urllib2.urlopen(request)<br />
  text = response.read()<br />
  videos = re.findall(&#8220;&lt;a href=\&#8221;/watch\?v=([\w-]+)&#8221;, text)<br />
  return &#8220;http://www.youtube.com/watch?v=%s&#8221; % videos[0]</p>
<p>response = urllib2.urlopen(&#8216;http://localhost/test&#8217;)<br />
html = response.read()<br />
re_channel = re.compile(&#8220;&lt;h3&gt;(.*?)&lt;/h3&gt;&#8221; +<br />
 &#8220;\r\n.*?&lt;h4&gt;(.*?)&lt;/h4&gt;.*?&lt;h5&#8243;, re.I | re.S | re.M)<br />
find_result = re_channel.findall(html)<br />
#remove first entry as it&#8217;s a dup<br />
del find_result[0]<br />
for result in find_result:<br />
 title=unicode(BeautifulStoneSoup(result[0],convertEntities=BeautifulStoneSoup.HTML_ENTITIES ))<br />
 artist=unicode(BeautifulStoneSoup(result[1],convertEntities=BeautifulStoneSoup.HTML_ENTITIES ))<br />
 link=&#8221;http://www.youtube.com/results?search_query=&#8221; + urllib.quote_plus(title);<br />
 print getvideolink(link)</p></blockquote>
<blockquote></blockquote>
<blockquote><p>Sample output</p></blockquote>
<blockquote><p>RIHANNA FT CALVIN HARRIS &#8211; WE FOUND LOVE // http://www.youtube.com/watch?v=tg00YEETFzg<br />
FLO RIDA &#8211; GOOD FEELING // http://www.youtube.com/watch?v=3OnnDqH6Wj8<br />
ONE DIRECTION &#8211; GOTTA BE YOU // http://www.youtube.com/watch?v=nvfejaHz-o0<br />
LABRINTH FT TINIE TEMPAH &#8211; EARTHQUAKE // http://www.youtube.com/watch?v=u0fk6syQ7iY<br />
ED SHEERAN &#8211; LEGO HOUSE // http://www.youtube.com/watch?v=c4BLVznuWnU<br />
DAVID GUETTA FT USHER &#8211; WITHOUT YOU // http://www.youtube.com/watch?v=jUe8uoKdHao<br />
MAROON 5 FT CHRISTINA AGUILERA &#8211; MOVES LIKE JAGGER // http://www.youtube.com/watch?v=iEPTlhBmwRg<br />
JLS &#8211; TAKE A CHANCE ON ME // http://www.youtube.com/watch?v=djV11Xbc914<br />
PROFESSOR GREEN FT EMELI SANDE &#8211; READ ALL ABOUT IT // http://www.youtube.com/watch?v=-_oLfC5Z_Ys<br />
CHRISTINA PERRI &#8211; JAR OF HEARTS // http://www.youtube.com/watch?v=8v_4O44sfjM<br />
LMFAO &#8211; SEXY AND I KNOW IT // http://www.youtube.com/watch?v=wyx6JDQCslE<br />
DRAKE FT RIHANNA &#8211; TAKE CARE // http://www.youtube.com/watch?v=PaXslpx3MWY<br />
COLDPLAY &#8211; PARADISE // http://www.youtube.com/watch?v=1G4isv_Fylg<br />
CHARLENE SORAIA &#8211; WHEREVER YOU WILL GO // http://www.youtube.com/watch?v=iAP9AF6DCu4<br />
SATURDAYS &#8211; MY HEART TAKES OVER // http://www.youtube.com/watch?v=DgmoYgpMNX8<br />
CHER LLOYD FT MIKE POSNER &#8211; WITH UR LOVE // http://www.youtube.com/watch?v=axpO86pGHAM<br />
BRUNO MARS &#8211; IT WILL RAIN // http://www.youtube.com/watch?v=W-w3WfgpcGg<br />
LADY GAGA &#8211; MARRY THE NIGHT // http://www.youtube.com/watch?v=O4IgYxHEAuk<br />
LANA DEL REY &#8211; VIDEO GAMES // http://www.youtube.com/watch?v=HO1OV5B_JDw<br />
PIXIE LOTT FT PUSHA T &#8211; WHAT DO YOU TAKE ME FOR // http://www.youtube.com/watch?v=OQCcwNMp830<br />
KELLY CLARKSON &#8211; MR KNOW IT ALL // http://www.youtube.com/watch?v=0C_oNMH0GTk<br />
LOICK ESSIEN &#8211; ME WITHOUT YOU // http://www.youtube.com/watch?v=lKDmJwoZ4RA<br />
FLORENCE &amp; THE MACHINE &#8211; SHAKE IT OUT // http://www.youtube.com/watch?v=WbN0nX61rIs<br />
COLLECTIVE &#8211; TEARDROP // http://www.youtube.com/watch?v=u7K72X4eo_s<br />
ONE DIRECTION &#8211; WHAT MAKES YOU BEAUTIFUL // http://www.youtube.com/watch?v=QJO3ROT-A4E<br />
ED SHEERAN &#8211; THE A TEAM // http://www.youtube.com/watch?v=UAWcs5H-qgQ<br />
WANTED &#8211; LIGHTNING // http://www.youtube.com/watch?v=MQyHyfLp5NI<br />
JESSIE J &#8211; WHO YOU ARE // http://www.youtube.com/watch?v=j2WWrupMBAE<br />
LUCENZO &amp; QWOTE &#8211; DANZA KUDURO // http://www.youtube.com/watch?v=rUFgacK8sZ0<br />
GYM CLASS HEROES/ADAM LEVINE &#8211; STEREO HEARTS // http://www.youtube.com/watch?v=T3E9Wjbq44E<br />
MAVERICK SABRE &#8211; I NEED // http://www.youtube.com/watch?v=VA770wpLX-Q<br />
WESTLIFE &#8211; LIGHTHOUSE // http://www.youtube.com/watch?v=Tivph7mTku4<br />
SEAN PAUL FT ALEXIS JORDAN &#8211; GOT 2 LUV U // http://www.youtube.com/watch?v=tDq3fNew1rU<br />
LADY GAGA &#8211; THE EDGE OF GLORY // http://www.youtube.com/watch?v=QeWBS0JBNzQ<br />
GLEE CAST &#8211; RUMOUR HAS IT/SOMEONE LIKE YOU // http://www.youtube.com/watch?v=qb7zjKkLCoQ<br />
SLOW MOVING MILLIE &#8211; PLEASE PLEASE PLEASE LET ME GET WHAT I // http://www.youtube.com/watch?v=DMQbzLrvwlE<br />
KATY PERRY &#8211; THE ONE THAT GOT AWAY // http://www.youtube.com/watch?v=Ahha3Cqe_fk<br />
ELBOW &#8211; ONE DAY LIKE THIS // http://www.youtube.com/watch?v=0NFV8dHrZYM<br />
CHRISTINA PERRI &#8211; A THOUSAND YEARS // http://www.youtube.com/watch?v=z5Q8x1wYN4w<br />
SNOW PATROL &#8211; THIS ISN&#8217;T EVERYTHING YOU ARE // http://www.youtube.com/watch?v=Q-Gljs8Y3Q8<br />
RIZZLE KICKS &#8211; WHEN I WAS A YOUNGSTER // http://www.youtube.com/watch?v=Rc2iUwMpb8Y<br />
GOO GOO DOLLS &#8211; IRIS // http://www.youtube.com/watch?v=NdYWuo9OFAw<br />
DAPPY &#8211; NO REGRETS // http://www.youtube.com/watch?v=WoImizvsj5w<br />
BRUNO MARS &#8211; MARRY YOU // http://www.youtube.com/watch?v=xB40cQD677s<br />
ADELE &#8211; SET FIRE TO THE RAIN // http://www.youtube.com/watch?v=ss0HAdW1DnY<br />
NICKELBACK &#8211; WHEN WE STAND TOGETHER // http://www.youtube.com/watch?v=76RbWuFll0Y<br />
AFROJACK &amp; STEVE AOKI &#8211; NO BEEF // http://www.youtube.com/watch?v=ksocjhxX_DQ<br />
ADELE &#8211; SOMEONE LIKE YOU // http://www.youtube.com/watch?v=hLQl3WQQoQ0<br />
PIXIE LOTT &#8211; ALL ABOUT TONIGHT // http://www.youtube.com/watch?v=swcULf1ATyU<br />
NICKI MINAJ &#8211; SUPER BASS // http://www.youtube.com/watch?v=4JipHEz53sU<br />
CALLING &#8211; WHEREVER YOU WILL GO // http://www.youtube.com/watch?v=iAP9AF6DCu4<br />
JAMES MORRISON &#8211; I WON&#8217;T LET YOU GO // http://www.youtube.com/watch?v=sgRb_lfIZ6A<br />
OLLY MURS FT RIZZLE KICKS &#8211; HEART SKIPS A BEAT // http://www.youtube.com/watch?v=j5dFe-WKuPs<br />
EXAMPLE &#8211; MIDNIGHT RUN // http://www.youtube.com/watch?v=iwYGi7YG4Js<br />
TINCHY STRYDER/CALVIN HARRIS &#8211; OFF THE RECORD // http://www.youtube.com/watch?v=UknZiaIC9y8<br />
SAK NOEL &#8211; LOCA PEOPLE // http://www.youtube.com/watch?v=-d6b1yn-YhQ<br />
BRUNO MARS &#8211; RUNAWAY BABY // http://www.youtube.com/watch?v=UDG_CrqJV-0<br />
JASON DERULO &#8211; FIGHT FOR YOU // http://www.youtube.com/watch?v=2aSOQRih6WY<br />
CHER LLOYD &#8211; SWAGGER JAGGER // http://www.youtube.com/watch?v=sdbyG2MrBHk<br />
LADY GAGA &#8211; BORN THIS WAY // http://www.youtube.com/watch?v=wV1FrqwZyKw<br />
SNOW PATROL &#8211; CALLED OUT IN THE DARK // http://www.youtube.com/watch?v=GwTXwJg6_VE<br />
WANTED &#8211; WARZONE // http://www.youtube.com/watch?v=yMR382aefmQ<br />
JLS FT DEV &#8211; SHE MAKES ME WANNA // http://www.youtube.com/watch?v=FuwTgZOKcf8<br />
NICOLE SCHERZINGER &#8211; TRY WITH ME // http://www.youtube.com/watch?v=R7sYiTyBjTY<br />
COBRA STARSHIP FT SABI &#8211; YOU MAKE ME FEEL // http://www.youtube.com/watch?v=HpyZEzrDf4c<br />
JESSIE J &#8211; WHO&#8217;S LAUGHING NOW // http://www.youtube.com/watch?v=KsxSxF3JKeU<br />
NOEL GALLAGHER&#8217;S HIGH FLYING &#8211; AKA WHAT A LIFE // http://www.youtube.com/watch?v=lwHpLDgWonM<br />
FOSTER THE PEOPLE &#8211; PUMPED UP KICKS // http://www.youtube.com/watch?v=SDTZ7iX4vTQ<br />
WRETCH 32 FT JOSH KUMRA &#8211; DON&#8217;T GO // http://www.youtube.com/watch?v=bj1BMpUnzT8<br />
BIRDY &#8211; SKINNY LOVE // http://www.youtube.com/watch?v=aNzCDt2eidg<br />
WANTED &#8211; GLAD YOU CAME // http://www.youtube.com/watch?v=2ggzxInyzVE<br />
BIRDY &#8211; PEOPLE HELP THE PEOPLE // http://www.youtube.com/watch?v=OmLNs6zQIHo<br />
NICKI MINAJ FT RIHANNA &#8211; FLY // http://www.youtube.com/watch?v=3n71KUiWn1I<br />
SKREAM FT SAM FRANK &#8211; ANTICIPATE // http://www.youtube.com/watch?v=O3Z1X4MPsqk<br />
WILL YOUNG &#8211; JEALOUSY // http://www.youtube.com/watch?v=9MHtrM-jf9o<br />
ADELE &#8211; ROLLING IN THE DEEP // http://www.youtube.com/watch?v=rYEDA3JcQqw<br />
JESSIE J FT BOB &#8211; PRICE TAG // http://www.youtube.com/watch?v=qMxX-QOV9tI<br />
LMFAO/LAUREN BENNETT/GOONROCK &#8211; PARTY ROCK ANTHEM // http://www.youtube.com/watch?v=KQ6zr6kCPj8<br />
JASON DERULO &#8211; IT GIRL // http://www.youtube.com/watch?v=4oGUHRXT-wA<br />
BEYONCE &#8211; COUNTDOWN // http://www.youtube.com/watch?v=ACkBTqwxcUI<br />
RIZZLE KICKS &#8211; DOWN WITH THE TRUMPETS // http://www.youtube.com/watch?v=-aY92XgykhU<br />
COLDPLAY &#8211; EVERY TEARDROP IS A WATERFALL // http://www.youtube.com/watch?v=fyMhvkC3A84<br />
CALVIN HARRIS &#8211; FEEL SO CLOSE // http://www.youtube.com/watch?v=dGghkjpNCQ8<br />
ADELE &#8211; MAKE YOU FEEL MY LOVE // http://www.youtube.com/watch?v=LLoyNxjhTzc<br />
ONE DIRECTION &#8211; ANOTHER WORLD // http://www.youtube.com/watch?v=RyZfNBVX1q0<br />
COLDPLAY &#8211; VIVA LA VIDA // http://www.youtube.com/watch?v=dvgZkm1xWPE<br />
BEYONCE &#8211; LOVE ON TOP // http://www.youtube.com/watch?v=Ob7vObnFUJc<br />
EAGLE-EYE CHERRY &#8211; SAVE TONIGHT // http://www.youtube.com/watch?v=dTa2Bzlbjv0<br />
EN VOGUE &#8211; DONT LET GO (LOVE) // http://www.youtube.com/watch?v=QUdAT5Fwnvk<br />
KATY PERRY &#8211; FIREWORK // http://www.youtube.com/watch?v=QGJuMBdaqIw<br />
MODESTEP &#8211; TO THE STARS // http://www.youtube.com/watch?v=UTKSUlMbp9A<br />
DRAKE &#8211; HEADLINES // http://www.youtube.com/watch?v=cimoNqiulUE<br />
ED SHEERAN &#8211; YOU NEED ME I DON&#8217;T NEED YOU // http://www.youtube.com/watch?v=temYymFGSEc<br />
WOODKID &#8211; IRON // http://www.youtube.com/watch?v=vSkb0kDacjs<br />
DELILAH &#8211; GO // http://www.youtube.com/watch?v=cxNe9jWNuEU<br />
KATY PERRY FT KANYE WEST &#8211; ET // http://www.youtube.com/watch?v=t5Sd5c4o9UM<br />
JAMES VINCENT MCMORROW &#8211; HIGHER LOVE // http://www.youtube.com/watch?v=9Z-fE1l9SZ4<br />
BRUNO MARS &#8211; JUST THE WAY YOU ARE (AMAZING) // http://www.youtube.com/watch?v=LjhCEhWiKXk<br />
PITBULL/NE-YO/AFROJACK/NAYER &#8211; GIVE ME EVERYTHING // http://www.youtube.com/watch?v=EPo5wWmKEaI</p></blockquote>
<blockquote></blockquote>
<blockquote><p>Then I wanted to test threading so I came up with something to check a list of links and obtain the &#8220;Server:&#8221; header</p></blockquote>
<blockquote><p>#!/usr/bin/env python<br />
import urllib2<br />
import re<br />
import os<br />
import sys<br />
import time<br />
from multiprocessing import Pool</p>
<p>#Accept file name as input or use default<br />
try:<br />
  filename = sys.argv[1]<br />
except IndexError:<br />
  filename = &#8220;links&#8221;</p>
<p>#Function to load urls from file<br />
def loadurls(filename):<br />
  try:<br />
    inputdata = file(filename).readlines()<br />
    if len(inputdata) &gt; 0:<br />
      return inputdata<br />
  except:<br />
    print &#8220;ERROR &#8211; Unable to process url list&#8221;<br />
    sys.exit()</p>
<p>#Function to get SERVER header<br />
def getversion(url):<br />
  try:<br />
      request=urllib2.Request(url)<br />
      response=urllib2.urlopen(request)<br />
      version=response.info().getheader(&#8216;Server&#8217;)<br />
  except:<br />
      return &#8220;ERROR &#8211; Unable to fetch %s&#8221; % (url)</p>
<p>  if version: print &#8220;Url: %s Version: %s&#8221; % (url, version)</p>
<p>start = time.time()<br />
urls=loadurls(filename)<br />
p = Pool(15)<br />
data = p.map(getversion,urls)</p>
<p>elapsed = (time.time() &#8211; start)<br />
print &#8220;Processed %s urls in %0.2f seconds&#8221; % (len(urls), elapsed)</p></blockquote>
<blockquote><p>Sample output</p></blockquote>
<blockquote><p>scott@scott:~/python$ ./server-header.py list<br />
Url: http://www.bbc.co.uk<br />
 Version: Apache<br />
Url: http://www.google.co.uk<br />
 Version: gws<br />
Url: https://scott.cm<br />
 Version: Apache<br />
Processed 4 urls in 1.07 seconds</p></blockquote>
<blockquote></blockquote>
<blockquote><p>None of these really serve any purpose and were merely tests I thought I would share.   Overall things have been quite easy and feel reasonably confident after just 2 days.</p></blockquote>
]]></content:encoded>
							<wfw:commentRss>https://scott.cm/learning_python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
	</channel>
</rss>
