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 urllib3 | |
pool = urllib3.PoolManager(num_pools=10) | |
for i in range(100): | |
resp = pool.urlopen('POST', 'your-url.com', headers = {...}, body = '...') | |
print(resp.data) |
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 cx_Oracle | |
def perform_query(query, bind_variables): | |
connection = db_pool.acquire() | |
cursor = connection.cursor() | |
cursor.execute(query, bind_variables) | |
result = cursor.fetchall() | |
cursor.close() | |
db_pool.release(connection) | |
return result |
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
from logging.handlers import TimedRotatingFileHandler | |
import logging | |
logHandler = TimedRotatingFileHandler('file_name.log', when="midnight") | |
logFormatter = logging.Formatter('%(asctime)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S') | |
logHandler.setFormatter(logFormatter) | |
logger = logging.getLogger('time_rotate_logger') | |
logger.addHandler(logHandler) | |
logger.setLevel(logging.DEBUG) |
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
from bottle import get, request, run | |
@get('/') | |
def index(): | |
name = request.GET.get('name') | |
return 'Hello %s!' % name | |
run(host='0.0.0.0', port=8080) |
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 urllib2 | |
REQUEST_URL = 'url do server' | |
HEADERS = {'content-type':'text/x-xml'} | |
def post_soap(msg): | |
req = urllib2.Request(REQUEST_URL, msg, HEADERS) | |
r = urllib2.urlopen(req) | |
returned_line = ''.join(r.readlines()) | |
return returned_line |
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
from unidecode import unidecode | |
no_diacritics = unidecode('á') | |
print no_diacritics |
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
print('Ola mundo!') |