python-docraptor is a python interface to the Doc Raptor document generation API. It is designed to mirror (well almost) the behaviour of the doc-raptor-gem, including asynchronous support. Here’s an example of it in action: from docraptor import DocRaptor docraptor = DocRaptor() resp = docraptor.create({ ‘document_content’: ‘<p>python-docraptor Test</p>’, ‘test’: True }) # PDF data is now [...]
If you are a web developer or a web designer, you will have run a local web server as part of your design or development process. Two of the most common ways to do this on OS X are with MAMP or the bundled Apache installation. One of the problems with this approach is that [...]
Small itch scratched. import csv from xlrd import open_workbook def excel_to_csv(excel_file, include=None): “”" Convert the data in the excel_file to CSV. If include is specified, only those named columns will be included in the CSV. “”" # open the Excel file wb = open_workbook(excel_file) # read each sheet in the file for s in wb.sheets(): [...]
I need to extract the maximum vserver id and the maximum source id from a Cherokee configuration file, so I can auto-generate configuration for test instances. The following is the solution I came up with: import os import re def increpl(matchobj): “”" Replace the include statement with the contnet of the file. “”" inc = [...]
find_unbound_port returns a (pseudo-)random unbound port on localhost. import random import socket # range of ports where available ports can be found PORT_RANGE = [33000,60000] def find_unbound_port(): “”" Returns an unbound port number on 127.0.0.1. “”" port = random.randint(*PORT_RANGE) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: sock.bind((“127.0.0.1″, port)) except socket.error: port = get_port() return port if __name__ [...]