This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import multiprocessing | |
import time | |
import mplog | |
FORMAT = '%(asctime)s - %(processName)s - %(levelname)s - %(message)s' | |
logging.basicConfig(level=logging.DEBUG, format=FORMAT) | |
existing_logger = logging.getLogger('x') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import logging | |
import xml.etree.ElementTree as ET | |
import re | |
import types | |
from uuid import uuid4 | |
import cyclone.httpclient | |
import cyclone.jsonrpc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
logging.basicConfig(level=logging.INFO, | |
format='%(asctime)s %(levelname)s %(message)s', | |
datefmt='%Y-%m-%d %H:%M:%S') | |
log = logging.getLogger(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ping(server, port): | |
''' Check if a server accepts connections on a specific TCP port ''' | |
try: | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.connect((server, port)) | |
s.close() | |
return True | |
except socket.error: | |
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
#coding=utf-8 | |
import gevent | |
from gevent.subprocess import Popen, PIPE | |
import sys | |
def run(cmd,name="",index=1,color=True): | |
fc = 32 + index%5 | |
if name: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from multiprocessing import Pool | |
from pprint import pprint | |
from optopus import Client, OPTOPUS_ENDPOINT | |
from jnpr.junos import Device | |
# work in progress | |
class MetaStore(object): | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# | |
#author: rex | |
#blog: http://iregex.org | |
# | |
import re | |
from os.path import dirname as dirname |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- encoding: utf-8 -*- | |
"""xml2json.py Convert XML to JSON | |
Relies on ElementTree for the XML parsing. This is based on | |
pesterfish.py but uses a different XML->JSON mapping. | |
The XML->JSON mapping is described at | |
http://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- encoding: utf-8 -*- | |
"""xml2json.py Convert XML to JSON | |
Relies on ElementTree for the XML parsing. This is based on | |
pesterfish.py but uses a different XML->JSON mapping. | |
The XML->JSON mapping is described at | |
http://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# test with | |
# curl -X POST -H "Content-Type: application/json" -d '{ "action" : "RUN"}' | |
# http://127.0.0.1:5000/example/ | |
import json | |
from flask import request, url_for | |
from flask.ext.api import FlaskAPI, status, exceptions | |
app = FlaskAPI(__name__) |