Skip to content

Instantly share code, notes, and snippets.

View jk0's full-sized avatar

Josh Kearney jk0

  • GitHub Staff
  • Wisconsin
View GitHub Profile
diff --git a/svcshare/network.py b/svcshare/network.py
index 3abb688..7b1af2a 100644
--- a/svcshare/network.py
+++ b/svcshare/network.py
@@ -62,6 +62,8 @@ class Network(object):
return self._isolation
def isolationIs(self, iso):
+ if not hasattr(threading.Thread, "is_alive"):
+ threading.Thread.is_alive = threading.Thread.isAlive
import logging
def logger(name, debug=False):
"""Log handler"""
logging.basicConfig(
level=logging.DEBUG if debug else logging.INFO,
format="%(asctime)s [%(name)s] %(message)s",
datefmt="%H:%M:%S")
return logging.getLogger(name)
xml = minidom.parseString(response.read())
for i in xml.childNodes[0].childNodes[1].childNodes[0].childNodes:
title = i._attrs["title"].firstChild.data
title = re.sub(" ", "_", title)
def on_pubmsg(self, connection, event):
"""Handle public messages"""
print event.source()
self.source = event.source().split("@", 1)[0]
self.target = event.target()
nick = irclib.nm_to_n(event.source())
msg = event.arguments()[0]
self.log.info("%s <%s> %s" % (self.target, nick, msg))
self.poll_messages(msg)
#!/bin/sh
echo "Running PEP8..."
pep8 -r .
echo "Running pylint..."
pylint pyhole.py -f parseable -rno -dI
pylint plugins -f parseable -rno -dI
pylint pyhole -f parseable -rno -dI
@jk0
jk0 / gist:2762925
Created May 21, 2012 15:30
Boot a DevStack instance through the BOSH OpenStack CPI.
os = openstack
flavor = os.flavors.find { |f| f.name == "m1.tiny" }
image = os.images.find { |i| i.name == "cirros-0.3.0-x86_64-uec" }
# Boot instance using Fog
# server = os.servers.create(:name => agent_id, :image_ref => image.id, :flavor_ref => flavor.id)
server = cpi.create_vm("cpi-test", image.name, { "instance_type" => flavor.name }, {"default" => { "type" => "dynamic" }})
@jk0
jk0 / gist:2769329
Created May 22, 2012 14:12
OpenStack CPI Configuration Example
openstack:
auth_url: http://localhost:5000/v2.0/tokens
username: admin
api_key: nova
tenant: admin
registry:
endpoint: http://localhost:25777
user: admin
password: admin
@jk0
jk0 / gist:3739781
Created September 17, 2012 21:06
RouterOS Firewall
[jkearney@Router] > /ip firewall nat print
Flags: X - disabled, I - invalid, D - dynamic
0 chain=srcnat action=masquerade to-addresses=0.0.0.0 out-interface=ether1-gateway
[jkearney@Router] >
[jkearney@Router] > /ip firewall filter print
Flags: X - disabled, I - invalid, D - dynamic
0 chain=input action=accept protocol=icmp in-interface=ether1-gateway
1 chain=input action=accept protocol=udp in-interface=ether1-gateway dst-port=500,1701,4500
2 chain=input action=accept connection-state=established in-interface=ether1-gateway
3 chain=forward action=accept connection-state=established in-interface=ether1-gateway
@route("/video/amazoninstantvideo/getvideoobject")
def GetVideoObject(url, video_type, title=None, summary=None, thumb_url=None):
thumb = Resource.ContentsOfURLWithFallback(url=thumb_url, fallback=PLUGIN_ICON_DEFAULT)
if video_type == "episode":
return EpisodeObject(key=Callback(VideoDetails, url), rating_key=url, items=video_items(url), title=title, summary=summary, thumb=thumb)
else:
return MovieObject(key=Callback(VideoDetails, url), rating_key=url, items=video_items(url), title=title, summary=summary, thumb=thumb)
@route("/video/amazoninstantvideo/playvideo")
@indirect
def PlayVideo(url):
try:
flash_vars = utils.parse_flash_vars(url)
rtmp_url, clip_stream = utils.prepare_rtmp_info(flash_vars)
except KeyError:
return MessageContainer("Error", "Unable to load video.")
oc = ObjectContainer()