PYME.ParallelTasks.dataserver_wsgi module

Created on Sat Feb 13 18:12:18 2016

@author: david

This is a very simple HTTP server which allows data to be saved to the server using PUT

Security note:

The code as it stands lets any client write arbitrary data to the server. The only concessions we make to security are:

  1. paths are vetted to make sure that they reside under out root (i.e. no escape through .. etc)
  2. we enforce a write-once scheme (if a file exists it can’t be overridden)

This protects against people accidentally or maliciously altering data, or discovering server settings, but leaves us open to denial of service type attacks in which a malicious client could fill up our storage.

THE CODE AS IT STANDS SHOULD ONLY BE USED ON A TRUSTED NETWORK

TODO: Add some form of authentication. Needs to be low overhead (e.g. digest based)

PYME.ParallelTasks.dataserver_wsgi.ResponseNotAllowed(content='', status='405 Method Not Allowed', headers=[])
PYME.ParallelTasks.dataserver_wsgi.ResponseNotFound(content='', status='404 Not Found', headers=[])
PYME.ParallelTasks.dataserver_wsgi.ResponseOK(content='', status='200 OK', headers=[])
PYME.ParallelTasks.dataserver_wsgi.cherrypy_server(options)
class PYME.ParallelTasks.dataserver_wsgi.dataserver

Bases: object

Methods

__call__(environ, start_response)
do_GET(path, data, environ[, head]) Common code for GET and HEAD commands.
do_HEAD(path, data, environ) Serve a HEAD request.
do_PUT(path, data, environ)
get_status()
guess_type(path) Guess the type of a file.
list_directory(path) Helper to produce a directory listing (absent index.html).
translate_path(path) Translate a /-separated PATH to the local filename syntax.
bandwidthTesting = False
do_GET(path, data, environ, head=False)

Common code for GET and HEAD commands.

This sends the response code and MIME headers.

Return value is either a file object (which has to be copied to the outputfile by the caller unless the command was HEAD, and must be closed by the caller under all circumstances), or None, in which case the caller has nothing further to do.

do_HEAD(path, data, environ)

Serve a HEAD request.

do_PUT(path, data, environ)
extensions_map = {'': 'application/octet-stream', '.pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation', '.obd': 'application/x-msbinder', '.obj': 'application/x-tgif', '.cpio': 'application/x-cpio', '.a': 'application/octet-stream', '.silo': 'model/mesh', '.cryptonote': 'application/vnd.rig.cryptonote', '.xer': 'application/patch-ops-error+xml', '.mobipocket-ebook': 'application/octet-stream', '.pml': 'application/vnd.ctc-posml', '.f4v': 'video/x-f4v', '.efif': 'application/vnd.picsel', '.iso': 'application/x-iso9660-image', '.rl': 'application/resource-lists+xml', '.ras': 'image/x-cmu-raster', '.rar': 'application/x-rar-compressed', '.rgb': 'image/x-rgb', '.mrc': 'application/marc', '.sdkd': 'application/vnd.solent.sdkm+xml', '.bcpio': 'application/x-bcpio', '.opml': 'text/x-opml', '.sdkm': 'application/vnd.solent.sdkm+xml', '.list3820': 'application/vnd.ibm.modcap', '.ecelp7470': 'audio/vnd.nuera.ecelp7470', '.vsd': 'application/vnd.visio', '.bz': 'application/x-bzip', '.fcdt': 'application/vnd.adobe.formscentral.fcdt', '.onetoc2': 'application/onenote', '.ait': 'application/vnd.dvb.ait', '.onetmp': 'application/onenote', '.bmp': 'image/bmp', '.geo': 'application/vnd.dynageo', '.air': 'application/vnd.adobe.air-application-installer-package+zip', '.clkw': 'application/vnd.crick.clicker.wordbank', '.bmi': 'application/vnd.bmi', '.tcl': 'application/x-tcl', '.dvi': 'application/x-dvi', '.aif': 'audio/x-aiff', '.grxml': 'application/srgs+xml', '.taglet': 'application/vnd.mynfc', '.hpid': 'application/vnd.hp-hpid', '.ott': 'application/vnd.oasis.opendocument.text-template', '.clkt': 'application/vnd.crick.clicker.template', '.rss': 'application/rss+xml', '.ots': 'application/vnd.oasis.opendocument.spreadsheet-template', '.cst': 'application/x-director', '.p10': 'application/pkcs10', '.csv': 'text/csv', '.p12': 'application/x-pkcs12', '.csp': 'application/vnd.commonspace', '.sus': 'application/vnd.sus-calendar', '.css': 'text/css', '.otg': 'application/vnd.oasis.opendocument.graphics-template', '.otf': 'application/x-font-otf', '.csh': 'application/x-csh', '.otc': 'application/vnd.oasis.opendocument.chart-template', '.aw': 'application/applixware', '.pdb': 'application/vnd.palm', '.clkp': 'application/vnd.crick.clicker.palette', '.pdf': 'application/pdf', '.hal': 'application/vnd.hal+xml', '.pl': 'text/plain', '.atomsvc': 'application/atomsvc+xml', '.acc': 'application/vnd.americandynamics.acc', '.chm': 'application/vnd.ms-htmlhelp', '.djv': 'image/vnd.djvu', '.py': 'text/plain', '.xml': 'application/xml', '.ps': 'application/postscript', '.htm': 'text/html', '.wav': 'audio/x-wav', '.fig': 'application/x-xfig', '.sig': 'application/pgp-signature', '.sid': 'image/x-mrsid-image', '.cab': 'application/vnd.ms-cab-compressed', '.tsv': 'text/tab-separated-values', '.so': 'application/octet-stream', '.caf': 'audio/x-caf', '.sil': 'audio/silk', '.ltf': 'application/vnd.frogans.ltf', '.sis': 'application/vnd.symbian.install', '.prc': 'application/x-mobipocket-ebook', '.pre': 'application/vnd.lotus-freelance', '.prf': 'application/pics-rules', '.oprc': 'application/vnd.palm', '.car': 'application/vnd.curl.car', '.cap': 'application/vnd.tcpdump.pcap', '.tsd': 'application/timestamped-data', '.dd2': 'application/vnd.oma.dd2+xml', '.cat': 'application/vnd.ms-pki.seccat', '.uvvx': 'application/vnd.dece.unspecified', '.metalink': 'application/metalink+xml', '.dms': 'application/octet-stream', '.xla': 'application/vnd.ms-excel', '.fti': 'application/vnd.anser-web-funds-transfer-initiation', '.ief': 'image/ief', '.mp4s': 'application/mp4', '.cdf': 'application/x-netcdf', '.c4d': 'application/vnd.clonk.c4group', '.c4g': 'application/vnd.clonk.c4group', '.c4f': 'application/vnd.clonk.c4group', '.texinfo': 'application/x-texinfo', '.p8': 'application/pkcs8', '.dmg': 'application/x-apple-diskimage', '.c4p': 'application/vnd.clonk.c4group', '.c4u': 'application/vnd.clonk.c4group', '.vis': 'application/vnd.visionary', '.viv': 'video/vnd.vivo', '.ddd': 'application/vnd.fujixerox.ddd', '.link66': 'application/vnd.route66.link66+xml', '.tmo': 'application/vnd.tmobile-livetv', '.ext': 'application/vnd.novadigm.ext', '.xaml': 'application/xaml+xml', '.exi': 'application/exi', '.omdoc': 'application/omdoc+xml', '.csml': 'chemical/x-csml', '.mus': 'application/vnd.musician', '.mlp': 'application/vnd.dolby.mlp', '.exe': 'application/x-msdownload', '.xpw': 'application/vnd.intercon.formnet', '.xpr': 'application/vnd.is-xpr', '.xps': 'application/vnd.ms-xpsdocument', '.dsc': 'text/prs.lines.tag', '.xpx': 'application/vnd.intercon.formnet', '.mscml': 'application/mediaservercontrol+xml', '.rep': 'application/vnd.businessobjects', '.xpl': 'application/xproc+xml', '.xpm': 'image/x-xpixmap', '.mpeg': 'video/mpeg', '.blorb': 'application/x-blorb', '.m21': 'application/mp21', '.sisx': 'application/vnd.symbian.install', '.spq': 'application/scvp-vp-request', '.fxpl': 'application/vnd.adobe.fxp', '.ami': 'application/vnd.amiga.ami', '.fm': 'application/vnd.framemaker', '.ram': 'audio/x-pn-realaudio', '.dssc': 'application/dssc+der', '.fh': 'image/x-freehand', '.sgml': 'text/sgml', '.spf': 'application/vnd.yamaha.smaf-phrase', '.cil': 'application/vnd.ms-artgalry', '.spc': 'application/x-pkcs7-certificates', '.spl': 'application/x-futuresplash', '.bat': 'application/x-msdownload', '.clkx': 'application/vnd.crick.clicker', '.mgp': 'application/vnd.osgeo.mapguide.package', '.emma': 'application/emma+xml', '.eml': 'message/rfc822', '.cct': 'application/x-director', '.nitf': 'application/vnd.nitf', '.wks': 'application/vnd.ms-works', '.gac': 'application/vnd.groove-account', '.cww': 'application/prs.cww', '.box': 'application/vnd.previewsystems.box', '.gam': 'application/x-tads', '.yin': 'application/yin+xml', '.emz': 'application/x-msmetafile', '.wad': 'application/x-doom', '.txf': 'application/vnd.mobius.txf', '.utz': 'application/vnd.uiq.theme', '.txd': 'application/vnd.genomatix.tuxedo', '.m2v': 'video/mpeg', '.m2a': 'audio/mpeg', '.rsd': 'application/rsd+xml', '.xbm': 'image/x-xbitmap', '.txt': 'text/plain', '.x3dvz': 'model/x3d+vrml', '.xbd': 'application/vnd.fujixerox.docuworks.binder', '.arc': 'application/x-freearc', '.opf': 'application/oebps-package+xml', '.smzip': 'application/vnd.stepmania.package', '.twd': 'application/vnd.simtech-mindmapper', '.dna': 'application/vnd.dna', '.ts': 'video/mp2t', '.tr': 'text/troff', '.distz': 'application/octet-stream', '.ahead': 'application/vnd.ahead.space', '.smil': 'application/smil+xml', '.fnc': 'application/vnd.frogans.fnc', '.sh': 'application/x-sh', '.et3': 'application/vnd.eszigno3+xml', '.xif': 'image/vnd.xiff', '.dae': 'model/vnd.collada+xml', '.s3m': 'audio/s3m', '.daf': 'application/vnd.mobius.daf', '.mif': 'application/vnd.mif', '.cer': 'application/pkix-cert', '.smf': 'application/vnd.stardivision.math', '.ufd': 'application/vnd.ufdl', '.uvvz': 'application/vnd.dece.zip', '.dotm': 'application/vnd.ms-word.template.macroenabled.12', '.kpxx': 'application/vnd.ds-keypoint', '.smi': 'application/smil+xml', '.smv': 'video/x-smv', '.t3': 'application/x-t3vm-image', '.gxt': 'application/vnd.geonext', '.jisp': 'application/vnd.jisp', '.sfs': 'application/vnd.spotfire.sfs', '.ecma': 'application/ecmascript', '.sfv': 'text/x-sfv', '.etx': 'text/x-setext', '.iges': 'model/iges', '.gxf': 'application/gxf', '.movie': 'video/x-sgi-movie', '.dxp': 'application/vnd.spotfire.dxp', '.png': 'image/png', '.mhtml': 'message/rfc822', '.tar': 'application/x-tar', '.pnm': 'image/x-portable-anymap', '.dvb': 'video/vnd.dvb.file', '.tra': 'application/vnd.trueapp', '.pnt': 'image/x-macpaint', '.mqy': 'application/vnd.mobius.mqy', '.dxf': 'image/vnd.dxf', '.rnc': 'application/relax-ng-compact-syntax', '.tao': 'application/vnd.tao.intent-module-archive', '.wvx': 'video/x-ms-wvx', '.rpst': 'application/vnd.nokia.radio-preset', '.nnw': 'application/vnd.noblenet-web', '.hpgl': 'application/vnd.hp-hpgl', '.dotx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', '.ecelp9600': 'audio/vnd.nuera.ecelp9600', '.cu': 'application/cu-seeme', '.chrt': 'application/vnd.kde.kchart', '.wsdl': 'application/wsdl+xml', '.dwg': 'image/x-dwg', '.conf': 'text/plain', '.fg5': 'application/vnd.fujitsu.oasysgp', '.3ds': 'image/x-3ds', '.cc': 'text/x-c', '.gex': 'application/vnd.geometry-explorer', '.ei6': 'application/vnd.pg.osasli', '.svc': 'application/vnd.dvb.service', '.mcd': 'application/vnd.mcd', '.odft': 'application/vnd.oasis.opendocument.formula-template', '.nnd': 'application/vnd.noblenet-directory', '.nlu': 'application/vnd.neurolanguage.nlu', '.str': 'application/vnd.pg.format', '.g2w': 'application/vnd.geoplan', '.stw': 'application/vnd.sun.xml.writer.template', '.sti': 'application/vnd.sun.xml.impress.template', '.xhvml': 'application/xv+xml', '.stk': 'application/hyperstudio', '.crl': 'application/pkix-crl', '.ipfix': 'application/ipfix', '.stl': 'application/vnd.ms-pki.stl', '.semf': 'application/vnd.semf', '.bed': 'application/vnd.realvnc.bed', '.stc': 'application/vnd.sun.xml.calc.template', '.crd': 'application/x-mscardfile', '.std': 'application/vnd.sun.xml.draw.template', '.m1v': 'video/mpeg', '.stf': 'application/vnd.wt.stf', '.oa3': 'application/vnd.fujitsu.oasys3', '.gmx': 'application/vnd.gmx', '.ifb': 'text/calendar', '.avi': 'video/x-msvideo', '.fgd': 'application/x-director', '.wdp': 'image/vnd.ms-photo', '.gml': 'application/gml+xml', '.qfx': 'application/vnd.intu.qfx', '.musicxml': 'application/vnd.recordare.musicxml+xml', '.mrcx': 'application/marcxml+xml', '.cla': 'application/vnd.claymore', '.pwn': 'application/vnd.3m.post-it-notes', '.z1': 'application/x-zmachine', '.z7': 'application/x-zmachine', '.z6': 'application/x-zmachine', '.z5': 'application/x-zmachine', '.mht': 'message/rfc822', '.pskcxml': 'application/pskc+xml', '.z8': 'application/x-zmachine', '.wmf': 'application/x-msmetafile', '.wmd': 'application/x-ms-wmd', '.mcurl': 'text/vnd.curl.mcurl', '.wmz': 'application/x-msmetafile', '.clp': 'application/x-msclip', '.wmx': 'video/x-ms-wmx', '.xfdl': 'application/vnd.xfdl', '.xltm': 'application/vnd.ms-excel.template.macroenabled.12', '.rp9': 'application/vnd.cloanto.rp9', '.mc1': 'application/vnd.medcalcdata', '.adp': 'audio/adpcm', '.m13': 'application/x-msmediaview', '.m14': 'application/x-msmediaview', '.dist': 'application/octet-stream', '.nml': 'application/vnd.enliven', '.hvd': 'application/vnd.yamaha.hv-dic', '.kpt': 'application/vnd.kde.kpresenter', '.xbap': 'application/x-ms-xbap', '.kpr': 'application/vnd.kde.kpresenter', '.dbk': 'application/docbook+xml', '.gdl': 'model/vnd.gdl', '.g3w': 'application/vnd.geospace', '.oa2': 'application/vnd.fujitsu.oasys2', '.jpeg': 'image/jpeg', '.gtar': 'application/x-gtar', '.p7m': 'application/pkcs7-mime', '.p7s': 'application/pkcs7-signature', '.nws': 'message/rfc822', '.deb': 'application/x-debian-package', '.p7c': 'application/pkcs7-mime', '.p7b': 'application/x-pkcs7-certificates', '.def': 'text/plain', '.mts': 'model/vnd.mts', '.bpk': 'application/octet-stream', '.ez': 'application/andrew-inset', '.appcache': 'text/cache-manifest', '.der': 'application/x-x509-ca-cert', '.saf': 'application/vnd.yamaha.smaf-audio', '.p7r': 'application/x-pkcs7-certreqresp', '.pntg': 'image/x-macpaint', '.ico': 'image/x-icon', '.eps': 'application/postscript', '.xul': 'application/vnd.mozilla.xul+xml', '.bdf': 'application/x-font-bdf', '.c11amz': 'application/vnd.cluetrust.cartomobile-config-pkg', '.ace': 'application/x-ace-compressed', '.icm': 'application/vnd.iccprofile', '.lrf': 'application/octet-stream', '.listafp': 'application/vnd.ibm.modcap', '.dfac': 'application/vnd.dreamfactory', '.acu': 'application/vnd.acucobol', '.wmlsc': 'application/vnd.wap.wmlscriptc', '.oas': 'application/vnd.fujitsu.oasys', '.c11amc': 'application/vnd.cluetrust.cartomobile-config', '.tex': 'application/x-tex', '.wri': 'application/x-mswrite', '.irp': 'application/vnd.irepository.package+xml', '.wrl': 'model/vrml', '.sse': 'application/vnd.kodak-descriptor', '.ssf': 'application/vnd.epson.ssf', '.sitx': 'application/x-stuffitx', '.oth': 'application/vnd.oasis.opendocument.text-web', '.tei': 'application/tei+xml', '.gif': 'image/gif', '.lostxml': 'application/lost+xml', '.meta4': 'application/metalink4+xml', '.irm': 'application/vnd.ibm.rights-management', '.lnk': 'application/x-ms-shortcut', '.joda': 'application/vnd.joost.joda-archive', '.wgt': 'application/widget', '.fdf': 'application/vnd.fdf', '.elc': 'application/octet-stream', '.eot': 'application/vnd.ms-fontobject', '.rpss': 'application/vnd.nokia.radio-presets', '.mft': 'application/rpki-manifest', '.flac': 'audio/x-flac', '.hps': 'application/vnd.hp-hps', '.mfm': 'application/vnd.mfmp', '.deploy': 'application/octet-stream', '.pas': 'text/x-pascal', '.ppd': 'application/vnd.cups-ppd', '.paw': 'application/vnd.pawaafile', '.fbs': 'image/vnd.fastbidsheet', '.dcurl': 'text/vnd.curl.dcurl', '.gim': 'application/vnd.groove-identity-message', '.kfo': 'application/vnd.kde.kformula', '.rtx': 'text/richtext', '.lrm': 'application/vnd.ms-lrm', '.cdkey': 'application/vnd.mediastation.cdkey', '.atomcat': 'application/atomcat+xml', '.djvu': 'image/vnd.djvu', '.i2g': 'application/vnd.intergeo', '.rtf': 'application/rtf', '.mag': 'application/vnd.ecowin.chart', '.mov': 'video/quicktime', '.twds': 'application/vnd.simtech-mindmapper', '.dxr': 'application/x-director', '.azw': 'application/vnd.amazon.ebook', '.qxt': 'application/vnd.quark.quarkxpress', '.azs': 'application/vnd.airzip.filesecure.azs', '.uvt': 'application/vnd.dece.ttml+xml', '.pyc': 'application/x-python-code', '.sv4cpio': 'application/x-sv4cpio', '.ulx': 'application/x-glulx', '.rms': 'application/vnd.jcp.javame.midlet-rms', '.azf': 'application/vnd.airzip.filesecure.azf', '.com': 'application/x-msdownload', '.wbxml': 'application/vnd.wap.wbxml', '.hh': 'text/x-c', '.mathml': 'application/mathml+xml', '.html': 'text/html', '.wiz': 'application/msword', '.vcd': 'application/x-cdlink', '.vcg': 'application/vnd.groove-vcard', '.vcf': 'text/x-vcard', '.json': 'application/json', '.shf': 'application/shf+xml', '.cdbcmsg': 'application/vnd.contact.cmsg', '.tpt': 'application/vnd.trid.tpt', '.install': 'application/x-install-instructions', '.psb': 'application/vnd.3gpp.pic-bw-small', '.vxml': 'application/voicexml+xml', '.psf': 'application/x-font-linux-psf', '.tpl': 'application/vnd.groove-tool-template', '.htke': 'application/vnd.kenameaapp', '.vcx': 'application/vnd.vcx', '.teicorpus': 'application/tei+xml', '.xhtml': 'application/xhtml+xml', '.midi': 'audio/midi', '.tiff': 'image/tiff', '.cdmio': 'application/cdmi-object', '.texi': 'application/x-texinfo', '.oda': 'application/oda', '.ustar': 'application/x-ustar', '.ssml': 'application/ssml+xml', '.odb': 'application/vnd.oasis.opendocument.database', '.m3u8': 'application/x-mpegurl', '.cdmid': 'application/cdmi-domain', '.see': 'application/vnd.seemail', '.cdmia': 'application/cdmi-capability', '.fcs': 'application/vnd.isac.fcs', '.mpkg': 'application/vnd.apple.installer+xml', '.manifest': 'text/cache-manifest', '.odt': 'application/vnd.oasis.opendocument.text', '.3g2': 'video/3gpp2', '.odp': 'application/vnd.oasis.opendocument.presentation', '.ods': 'application/vnd.oasis.opendocument.spreadsheet', '.msi': 'application/x-msdownload', '.cdmiq': 'application/cdmi-queue', '.text': 'text/plain', '.mpn': 'application/vnd.mophun.application', '.mpm': 'application/vnd.blueice.multipass', '.mpc': 'application/vnd.mophun.certificate', '.mpa': 'video/mpeg', '.mpg': 'video/mpeg', '.ssdl': 'application/ssdl+xml', '.mpe': 'video/mpeg', '.roa': 'application/rpki-roa', '.xdssc': 'application/dssc+xml', '.mpy': 'application/vnd.ibm.minipay', '.pot': 'application/vnd.ms-powerpoint', '.x3dbz': 'model/x3d+binary', '.g3': 'image/g3fax', '.tfi': 'application/thraud+xml', '.nsc': 'application/x-conference', '.mpp': 'application/vnd.ms-project', '.lbe': 'application/vnd.llamagraphics.life-balance.exchange+xml', '.tfm': 'application/x-tex-tfm', '.xspf': 'application/xspf+xml', '.nsf': 'application/vnd.lotus-notes', '.wmlc': 'application/vnd.wap.wmlc', '.spot': 'text/vnd.in3d.spot', '.ggb': 'application/vnd.geogebra.file', '.webp': 'image/webp', '.setreg': 'application/set-registration-initiation', '.dpg': 'application/vnd.dpgraph', '.fzs': 'application/vnd.fuzzysheet', '.3gp': 'video/3gpp', '.atc': 'application/vnd.acucorp', '.onetoc': 'application/onenote', '.webm': 'video/webm', '.kon': 'application/vnd.kde.kontour', '.karbon': 'application/vnd.kde.karbon', '.plc': 'application/vnd.mobius.plc', '.weba': 'audio/webm', '.wma': 'audio/x-ms-wma', '.pfx': 'application/x-pkcs12', '.icc': 'application/vnd.iccprofile', '.m4a': 'audio/mp4a-latm', '.mseq': 'application/vnd.mseq', '.ivp': 'application/vnd.immervision-ivp', '.ser': 'application/java-serialized-object', '.ivu': 'application/vnd.immervision-ivu', '.pfr': 'application/font-tdpfr', '.yang': 'application/yang', '.m4v': 'video/x-m4v', '.gv': 'text/vnd.graphviz', '.swf': 'application/x-shockwave-flash', '.m4p': 'audio/mp4a-latm', '.mp3': 'audio/mpeg', '.swi': 'application/vnd.aristanetworks.swi', '.dtshd': 'audio/vnd.dts.hd', '.pfa': 'application/x-font-type1', '.pfb': 'application/x-font-type1', '.mp4': 'video/mp4', '.hvp': 'application/vnd.yamaha.hv-voice', '.rm': 'application/vnd.rn-realmedia', '.hvs': 'application/vnd.yamaha.hv-script', '.src': 'application/x-wais-source', '.ra': 'audio/x-pn-realaudio', '.sbml': 'application/sbml+xml', '.seed': 'application/vnd.fdsn.seed', '.cb7': 'application/x-cbr', '.book': 'application/vnd.framemaker', '.cmdf': 'chemical/x-cmdf', '.qt': 'video/quicktime', '.wcm': 'application/vnd.ms-works', '.bin': 'application/octet-stream', '.rs': 'application/rls-services+xml', '.ppam': 'application/vnd.ms-powerpoint.addin.macroenabled.12', '.rq': 'application/sparql-query', '.rdz': 'application/vnd.data-vision.rdz', '.xop': 'application/xop+xml', '.skd': 'application/vnd.koan', '.mkv': 'video/x-matroska', '.skm': 'application/vnd.koan', '.h261': 'video/h261', '.osfpvg': 'application/vnd.yamaha.openscoreformat.osfpvg+xml', '.mks': 'video/x-matroska', '.h264': 'video/h264', '.skt': 'application/vnd.koan', '.plf': 'application/vnd.pocketlearn', '.skp': 'application/vnd.koan', '.nfo': 'text/x-nfo', '.ufdl': 'application/vnd.ufdl', '.for': 'text/x-fortran', '.lvp': 'audio/vnd.lucent.voice', '.hqx': 'application/mac-binhex40', '.gca': 'application/x-gca-compressed', '.mka': 'audio/x-matroska', '.ttl': 'text/turtle', '.ksp': 'application/vnd.kde.kspread', '.sit': 'application/x-stuffit', '.otp': 'application/vnd.oasis.opendocument.presentation-template', '.ac': 'application/pkix-attr-cert', '.ttf': 'application/x-font-ttf', '.igm': 'application/vnd.insors.igm', '.uu': 'text/x-uuencode', '.pptm': 'application/vnd.ms-powerpoint.presentation.macroenabled.12', '.shar': 'application/x-shar', '.ptid': 'application/vnd.pvi.ptid1', '.jam': 'application/vnd.jam', '.h263': 'video/h263', '.ksh': 'text/plain', '.ccxml': 'application/ccxml+xml', '.dot': 'application/msword', '.cdy': 'application/vnd.cinderella', '.cdx': 'chemical/x-cdx', '.boz': 'application/x-bzip2', '.slt': 'application/vnd.epson.salt', '.fvt': 'video/vnd.fvt', '.vor': 'application/vnd.stardivision.writer', '.ics': 'text/calendar', '.ntf': 'application/vnd.nitf', '.o': 'application/octet-stream', '.wbs': 'application/vnd.criticaltools.wbs+xml', '.vox': 'application/x-authorware-bin', '.ktr': 'application/vnd.kahootz', '.zirz': 'application/vnd.zul', '.gsf': 'application/x-font-ghostscript', '.vob': 'video/x-ms-vob', '.uoml': 'application/vnd.uoml+xml', '.ktx': 'image/ktx', '.ktz': 'application/vnd.kahootz', '.dwf': 'model/vnd.dwf', '.wbmp': 'image/vnd.wap.wbmp', '.in': 'text/plain', '.dmp': 'application/vnd.tcpdump.pcap', '.jsonml': 'application/jsonml+json', '.edm': 'application/vnd.novadigm.edm', '.mp4v': 'video/mp4', '.grv': 'application/vnd.groove-injector', '.list': 'text/plain', '.esf': 'application/vnd.epson.esf', '.abw': 'application/x-abiword', '.wspolicy': 'application/wspolicy+xml', '.mpga': 'audio/mpeg', '.esa': 'application/vnd.osgi.subsystem', '.epub': 'application/epub+zip', '.pki': 'application/pkixcmp', '.hdf': 'application/x-hdf', '.davmount': 'application/davmount+xml', '.xpdl': 'application/xml', '.pkg': 'application/octet-stream', '.zaz': 'application/vnd.zzazz.deck+xml', '.bdm': 'application/vnd.syncml.dm+wbxml', '.xht': 'application/xhtml+xml', '.wqd': 'application/vnd.wqd', '.log': 'text/plain', '.cxx': 'text/x-c', '.srx': 'application/sparql-results+xml', '.cxt': 'application/x-director', '.sru': 'application/sru+xml', '.srt': 'application/x-subrip', '.vcs': 'text/x-vcalendar', '.oxt': 'application/vnd.openofficeorg.extension', '.pbd': 'application/vnd.powerbuilder6', '.bh2': 'application/vnd.fujitsu.oasysprs', '.rif': 'application/reginfo+xml', '.mxf': 'application/mxf', '.mpg4': 'video/mp4', '.psd': 'image/vnd.adobe.photoshop', '.pbm': 'image/x-portable-bitmap', '.es3': 'application/vnd.eszigno3+xml', '.qbo': 'application/vnd.intu.qbo', '.vrml': 'model/vrml', '.msty': 'application/vnd.muvee.style', '.doc': 'application/msword', '.dtd': 'application/xml-dtd', '.dtb': 'application/x-dtbook+xml', '.pclxl': 'application/vnd.hp-pclxl', '.xdp': 'application/vnd.adobe.xdp+xml', '.xdw': 'application/vnd.fujixerox.docuworks', '.onepkg': 'application/onenote', '.mobi': 'application/x-mobipocket-ebook', '.mbk': 'application/vnd.mobius.mbk', '.cdxml': 'application/vnd.chemdraw+xml', '.kar': 'audio/midi', '.xdf': 'application/xcap-diff+xml', '.gre': 'application/vnd.geometry-explorer', '.xslt': 'application/xslt+xml', '.aiff': 'audio/x-aiff', '.aifc': 'audio/x-aiff', '.mp4a': 'audio/mp4', '.gqf': 'application/vnd.grafeq', '.mp21': 'application/mp21', '.flx': 'text/vnd.fmi.flexstor', '.fly': 'text/vnd.fly', '.kne': 'application/vnd.kinar', '.edx': 'application/vnd.novadigm.edx', '.flv': 'video/x-flv', '.flw': 'application/vnd.kde.kivio', '.odg': 'application/vnd.oasis.opendocument.graphics', '.susp': 'application/vnd.sus-calendar', '.lasxml': 'application/vnd.las.las+xml', '.ez3': 'application/vnd.ezpix-package', '.ez2': 'application/vnd.ezpix-album', '.gqs': 'application/vnd.grafeq', '.nbp': 'application/vnd.wolfram.player', '.snf': 'application/x-font-snf', '.hbci': 'application/vnd.hbci', '.pcap': 'application/vnd.tcpdump.pcap', '.uvvd': 'application/vnd.dece.data', '.odc': 'application/vnd.oasis.opendocument.chart', '.uvvf': 'application/vnd.dece.data', '.nns': 'application/vnd.noblenet-sealer', '.uvvh': 'video/vnd.dece.hd', '.uvvi': 'image/vnd.dece.graphic', '.ppt': 'application/vnd.ms-powerpoint', '.pps': 'application/vnd.ms-powerpoint', '.uvvp': 'video/vnd.dece.pd', '.odm': 'application/vnd.oasis.opendocument.text-master', '.ppm': 'image/x-portable-pixmap', '.uvvt': 'application/vnd.dece.ttml+xml', '.uvvu': 'video/vnd.uvvu.mp4', '.uvvv': 'video/vnd.dece.video', '.xvm': 'application/xv+xml', '.latex': 'application/x-latex', '.semd': 'application/vnd.semd', '.uris': 'text/uri-list', '.cgm': 'image/cgm', '.ppa': 'application/vnd.ms-powerpoint', '.fpx': 'image/vnd.fpx', '.igl': 'application/vnd.igloader', '.mbox': 'application/mbox', '.osf': 'application/vnd.yamaha.openscoreformat', '.nb': 'application/mathematica', '.odi': 'application/vnd.oasis.opendocument.image', '.kwt': 'application/vnd.kde.kword', '.dcr': 'application/x-director', '.oti': 'application/vnd.oasis.opendocument.image-template', '.mp2a': 'audio/mpeg', '.cdmic': 'application/cdmi-container', '.igx': 'application/vnd.micrografx.igx', '.kwd': 'application/vnd.kde.kword', '.igs': 'model/iges', '.apr': 'application/vnd.lotus-approach', '.crt': 'application/x-x509-ca-cert', '.qti': 'image/x-quicktime', '.jad': 'text/vnd.sun.j2me.app-descriptor', '.mwf': 'application/vnd.mfer', '.npx': 'image/vnd.net-fpx', '.ogv': 'video/ogg', '.rlc': 'image/vnd.fujixerox.edmics-rlc', '.rld': 'application/resource-lists-diff+xml', '.svgz': 'image/svg+xml', '.bz2': 'application/x-bzip2', '.jar': 'application/java-archive', '.ogg': 'audio/ogg', '.dts': 'audio/vnd.dts', '.oga': 'audio/ogg', '.afp': 'application/vnd.ibm.modcap', '.f90': 'text/x-fortran', '.application': 'application/x-ms-application', '.ms': 'text/troff', '.lwp': 'application/vnd.lotus-wordpro', '.rmvb': 'application/vnd.rn-realmedia-vbr', '.mxl': 'application/vnd.recordare.musicxml', '.mxs': 'application/vnd.triscape.mxs', '.gram': 'application/srgs', '.me': 'text/troff', '.jlt': 'application/vnd.hp-jlyt', '.mxu': 'video/vnd.mpegurl', '.ma': 'application/mathematica', '.qam': 'application/vnd.epson.quickanime', '.blb': 'application/x-blorb', '.afm': 'application/x-font-type1', '.thmx': 'application/vnd.ms-officetheme', '.mseed': 'application/vnd.fdsn.mseed', '.pcurl': 'application/vnd.curl.pcurl', '.mesh': 'model/mesh', '.xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', '.inkml': 'application/inkml+xml', '.xlsb': 'application/vnd.ms-excel.sheet.binary.macroenabled.12', '.pgn': 'application/x-chess-pgn', '.pgm': 'image/x-portable-graymap', '.xyz': 'chemical/x-xyz', '.svg': 'image/svg+xml', '.svd': 'application/vnd.svd', '.atom': 'application/atom+xml', '.dp': 'application/vnd.osgi.dp', '.roff': 'text/troff', '.unityweb': 'application/vnd.unity', '.123': 'application/vnd.lotus-1-2-3', '.xlsm': 'application/vnd.ms-excel.sheet.macroenabled.12', '.uvd': 'application/vnd.dece.data', '.uvg': 'image/vnd.dece.graphic', '.uvf': 'application/vnd.dece.data', '.uva': 'audio/vnd.dece.audio', '.uvm': 'video/vnd.dece.mobile', '.ogx': 'application/ogg', '.mar': 'application/octet-stream', '.uvi': 'image/vnd.dece.graphic', '.uvh': 'video/vnd.dece.hd', '.eol': 'audio/vnd.digital-winds', '.frame': 'application/vnd.framemaker', '.uvu': 'video/vnd.uvvu.mp4', '.qtif': 'image/x-quicktime', '.uvv': 'video/vnd.dece.video', '.uvp': 'video/vnd.dece.pd', '.uvs': 'video/vnd.dece.sd', '.mac': 'image/x-macpaint', '.pwz': 'application/vnd.ms-powerpoint', '.uvx': 'application/vnd.dece.unspecified', '.uvz': 'application/vnd.dece.zip', '.pya': 'audio/vnd.ms-playready.media.pya', '.iif': 'application/vnd.shana.informed.interchange', '.atx': 'application/vnd.antix.game-component', '.mmf': 'application/vnd.smaf', '.dataless': 'application/vnd.fdsn.seed', '.oxps': 'application/oxps', '.mny': 'application/x-msmoney', '.pyo': 'application/x-python-code', '.ghf': 'application/vnd.groove-help', '.z4': 'application/x-zmachine', '.mng': 'video/x-mng', '.rdf': 'application/rdf+xml', '.pyv': 'video/vnd.ms-playready.media.pyv', '.vcard': 'text/vcard', '.xdm': 'application/vnd.syncml.dm+xml', '.ecelp4800': 'audio/vnd.nuera.ecelp4800', '.tcap': 'application/vnd.3gpp2.tcap', '.uvva': 'audio/vnd.dece.audio', '.sema': 'application/vnd.sema', '.dll': 'application/x-msdownload', '.les': 'application/vnd.hhe.lesson-player', '.dgc': 'application/x-dgc-compressed', '.pgp': 'application/pgp-encrypted', '.apk': 'application/vnd.android.package-archive', '.uvvm': 'video/vnd.dece.mobile', '.scq': 'application/scvp-cv-request', '.scs': 'application/scvp-cv-response', '.scm': 'application/vnd.lotus-screencam', '.cbz': 'application/x-cbr', '.ris': 'application/x-research-info-systems', '.scurl': 'text/vnd.curl.scurl', '.rip': 'audio/vnd.rip', '.scd': 'application/x-msschedule', '.wdb': 'application/vnd.ms-works', '.u32': 'application/x-authorware-bin', '.xfdf': 'application/vnd.adobe.xfdf', '.z3': 'application/x-zmachine', '.xwd': 'image/x-xwindowdump', '.xlam': 'application/vnd.ms-excel.addin.macroenabled.12', '.aab': 'application/x-authorware-bin', '.aac': 'audio/x-aac', '.sda': 'application/vnd.stardivision.draw', '.aam': 'application/x-authorware-map', '.sdc': 'application/vnd.stardivision.calc', '.evy': 'application/x-envoy', '.sdd': 'application/vnd.stardivision.impress', '.js': 'application/javascript', '.eva': 'application/x-eva', '.aas': 'application/x-authorware-seg', '.sdp': 'application/sdp', '.sdw': 'application/vnd.stardivision.writer', '.plb': 'application/vnd.3gpp.pic-bw-large', '.res': 'application/x-dtbresource+xml', '.ipk': 'application/vnd.shana.informed.package', '.wml': 'text/vnd.wap.wml', '.3dml': 'text/vnd.in3d.3dml', '.gramps': 'application/x-gramps-xml', '.n-gage': 'application/vnd.nokia.n-gage.symbian.install', '.wtb': 'application/vnd.webturbo', '.msf': 'application/vnd.epson.msf', '.pls': 'application/pls+xml', '.tga': 'image/x-tga', '.flo': 'application/vnd.micrografx.flo', '.vst': 'application/vnd.visio', '.msl': 'application/vnd.mobius.msl', '.qxd': 'application/vnd.quark.quarkxpress', '.qxb': 'application/vnd.quark.quarkxpress', '.msh': 'model/mesh', '.fli': 'video/x-fli', '.lha': 'application/x-lzh-compressed', '.pcf': 'application/x-font-pcf', '.potm': 'application/vnd.ms-powerpoint.template.macroenabled.12', '.umj': 'application/vnd.umajin', '.pcl': 'application/vnd.hp-pcl', '.cpt': 'application/mac-compactpro', '.jpg': 'image/jpeg', '.mdb': 'application/x-msaccess', '.pct': 'image/x-pict', '.potx': 'application/vnd.openxmlformats-officedocument.presentationml.template', '.jpm': 'video/jpm', '.pcx': 'image/x-pcx', '.mk3d': 'video/x-matroska', '.mdi': 'image/vnd.ms-modi', '.zip': 'application/zip', '.vss': 'application/vnd.visio', '.m3u': 'audio/x-mpegurl', '.clkk': 'application/vnd.crick.clicker.keyboard', '.ppsx': 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', '.jnlp': 'application/x-java-jnlp-file', '.class': 'application/java-vm', '.torrent': 'application/x-bittorrent', '.hlp': 'application/winhlp', '.mj2': 'video/mj2', '.m3a': 'audio/mpeg', '.xz': 'application/x-xz', '.asc': 'application/pgp-signature', '.qxl': 'application/vnd.quark.quarkxpress', '.asf': 'video/x-ms-asf', '.fh5': 'image/x-freehand', '.vsf': 'application/vnd.vsf', '.xm': 'audio/xm', '.xo': 'application/vnd.olpc-sugar', '.xpi': 'application/x-xpinstall', '.aso': 'application/vnd.accpac.simply.aso', '.mmr': 'image/vnd.fujixerox.edmics-mmr', '.asm': 'text/x-asm', '.uri': 'text/uri-list', '.ggt': 'application/vnd.geogebra.tool', '.sm': 'application/vnd.stepmania.stepchart', '.jp2': 'image/jp2', '.xlm': 'application/vnd.ms-excel', '.xlb': 'application/vnd.ms-excel', '.xlc': 'application/vnd.ms-excel', '.sc': 'application/vnd.ibm.secure-container', '.xlf': 'application/x-xliff+xml', '.pkipath': 'application/pkix-pkipath', '.cif': 'chemical/x-cif', '.xls': 'application/vnd.ms-excel', '.cii': 'application/vnd.anser-web-certificate-issue-initiation', '.st': 'application/vnd.sailingtracker.track', '.xlw': 'application/vnd.ms-excel', '.xlt': 'application/vnd.ms-excel', '.spp': 'application/scvp-vp-response', '.wmls': 'text/vnd.wap.wmlscript', '.fhc': 'image/x-freehand', '.cbt': 'application/x-cbr', '.wmv': 'video/x-ms-wmv', '.gtw': 'model/vnd.gtw', '.uvvg': 'image/vnd.dece.graphic', '.fh7': 'image/x-freehand', '.cba': 'application/x-cbr', '.gtm': 'application/vnd.groove-tool-message', '.trm': 'application/x-msterminal', '.ppsm': 'application/vnd.ms-powerpoint.slideshow.macroenabled.12', '.urls': 'text/uri-list', '.pub': 'application/x-mspublisher', '.imp': 'application/vnd.accpac.simply.imp', '.ims': 'application/vnd.ms-ims', '.odf': 'application/vnd.oasis.opendocument.formula', '.cbr': 'application/x-cbr', '.fsc': 'application/vnd.fsc.weblaunch', '.ifm': 'application/vnd.shana.informed.formdata', '.mpt': 'application/vnd.ms-project', '.x3db': 'model/x3d+binary', '.sgi': 'image/sgi', '.mime': 'message/rfc822', '.sgl': 'application/vnd.stardivision.writer-global', '.sgm': 'text/sgml', '.spx': 'audio/ogg', '.lbd': 'application/vnd.llamagraphics.life-balance.desktop', '.portpkg': 'application/vnd.macports.portpkg', '.x3dv': 'model/x3d+vrml', '.maker': 'application/vnd.framemaker', '.fst': 'image/vnd.fst', '.man': 'text/troff', '.x32': 'application/x-authorware-bin', '.tif': 'image/tiff', '.n3': 'text/n3', '.woff': 'application/x-font-woff', '.x3dz': 'model/x3d+xml', '.dv': 'video/x-dv', '.rmi': 'audio/midi', '.pfm': 'application/x-font-type1', '.knp': 'application/vnd.kinar', '.f77': 'text/x-fortran', '.pic': 'image/x-pict', '.mvb': 'application/x-msmediaview', '.qwd': 'application/vnd.quark.quarkxpress', '.uvvs': 'video/vnd.dece.sd', '.ngdat': 'application/vnd.nokia.n-gage.data', '.lzh': 'application/x-lzh-compressed', '.mets': 'application/mets+xml', '.rmp': 'audio/x-pn-realaudio-plugin', '.z2': 'application/x-zmachine', '.acutc': 'application/vnd.acucorp', '.xsm': 'application/vnd.syncml+xml', '.xsl': 'application/xml', '.sxw': 'application/vnd.sun.xml.writer', '.fh4': 'image/x-freehand', '.nc': 'application/x-netcdf', '.dra': 'audio/vnd.dra', '.sxm': 'application/vnd.sun.xml.math', '.sub': 'text/vnd.dvb.subtitle', '.setpay': 'application/set-payment-initiation', '.sxi': 'application/vnd.sun.xml.impress', '.7z': 'application/x-7z-compressed', '.aep': 'application/vnd.audiograph', '.sxd': 'application/vnd.sun.xml.draw', '.sxg': 'application/vnd.sun.xml.writer.global', '.ink': 'application/inkml+xml', '.sxc': 'application/vnd.sun.xml.calc', '.h': 'text/plain', '.fxp': 'application/vnd.adobe.fxp', '.wps': 'application/vnd.ms-works', '.itp': 'application/vnd.shana.informed.formtemplate', '.sql': 'application/x-sql', '.jpe': 'image/jpeg', '.ice': 'x-conference/x-cooltalk', '.ai': 'application/postscript', '.rcprofile': 'application/vnd.ipunplugged.rcprofile', '.udeb': 'application/x-debian-package', '.f': 'text/x-fortran', '.fe_launch': 'application/vnd.denovo.fcselayout-link', '.vtu': 'model/vnd.vtu', '.gpx': 'application/gpx+xml', '.xltx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', '.wpd': 'application/vnd.wordperfect', '.mxml': 'application/xv+xml', '.p': 'text/x-pascal', '.s': 'text/x-asm', '.t': 'text/troff', '.wpl': 'application/vnd.ms-wpl', '.cpp': 'text/x-c', '.xenc': 'application/xenc+xml', '.btif': 'image/prs.btif', '.org': 'application/vnd.lotus-organizer', '.gnumeric': 'application/x-gnumeric', '.mods': 'application/mods+xml', '.kia': 'application/vnd.kidspiration', '.docm': 'application/vnd.ms-word.document.macroenabled.12', '.emf': 'application/x-msmetafile', '.xvml': 'application/xv+xml', '.x3d': 'model/x3d+xml', '.xap': 'application/x-silverlight-app', '.xar': 'application/vnd.xara', '.sldx': 'application/vnd.openxmlformats-officedocument.presentationml.slide', '.gbr': 'application/rpki-ghostbusters', '.docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', '.zmm': 'application/vnd.handheld-entertainment+xml', '.sv4crc': 'application/x-sv4crc', '.c': 'text/plain', '.cmc': 'application/vnd.cosmocaller', '.swa': 'application/x-director', '.dart': 'application/vnd.dart', '.cml': 'chemical/x-cml', '.m4u': 'video/vnd.mpegurl', '.pvb': 'application/vnd.3gpp.pic-bw-var', '.zir': 'application/vnd.zul', '.mgz': 'application/vnd.proteus.magazine', '.au': 'audio/basic', '.mid': 'audio/midi', '.mie': 'application/x-mie', '.cmp': 'application/vnd.yellowriver-custom-menu', '.chat': 'application/x-chat', '.cmx': 'image/x-cmx', '.qps': 'application/vnd.publishare-delta-tree', '.kml': 'application/vnd.google-earth.kml+xml', '.dump': 'application/octet-stream', '.gph': 'application/vnd.flographit', '.mb': 'application/mathematica', '.dif': 'video/x-dv', '.sfd-hdstx': 'application/vnd.hydrostatix.sof-data', '.dic': 'text/x-c', '.ncx': 'application/x-dtbncx+xml', '.wg': 'application/vnd.pmi.widget', '.kmz': 'application/vnd.google-earth.kmz', '.wax': 'audio/x-ms-wax', '.iota': 'application/vnd.astraea-software.iota', '.mp2': 'audio/mpeg', '.wm': 'video/x-ms-wm', '.qwt': 'application/vnd.quark.quarkxpress', '.teacher': 'application/vnd.smart.teacher', '.dis': 'application/vnd.mobius.dis', '.dir': 'application/x-director', '.cfs': 'application/x-cfs-compressed', '.curl': 'text/vnd.curl', '.sldm': 'application/vnd.ms-powerpoint.slide.macroenabled.12', '.nzb': 'application/x-nzb', '.vsw': 'application/vnd.visio', '.ttc': 'application/x-font-ttf', '.cod': 'application/vnd.rim.cod', '.w3d': 'application/x-director', '.jpgm': 'video/jpm', '.snd': 'audio/basic', '.mmd': 'application/vnd.chipnuts.karaoke-mmd', '.pict': 'image/pict', '.mjp2': 'video/mj2', '.gz': 'application/x-gzip', '.jpgv': 'video/jpeg', '.ftc': 'application/vnd.fluxtime.clip', '.pqa': 'application/vnd.palm', '.java': 'text/x-java-source', '.asx': 'video/x-ms-asf', '.mads': 'application/mads+xml'}
get_status()
guess_type(path)

Guess the type of a file.

Argument is a PATH (a filename).

Return value is a string of the form type/subtype, usable for a MIME Content-type header.

The default implementation looks the file’s extension up in the table self.extensions_map, using application/octet-stream as a default; however it would be permissible (if slow) to look inside the data to make a better guess.

list_directory(path)

Helper to produce a directory listing (absent index.html).

Return value is either a file object, or None (indicating an error). In either case, the headers are sent, making the interface the same as for send_head().

logrequests = False
translate_path(path)

Translate a /-separated PATH to the local filename syntax.

Components that mean special things to the local file system (e.g. drive or directory names) are ignored. (XXX They should probably be diagnosed.)

PYME.ParallelTasks.dataserver_wsgi.getTextFileLock(filename)
PYME.ParallelTasks.dataserver_wsgi.main(protocol='HTTP/1.0')

Test the HTTP request handler class.

This runs an HTTP server on port 8000 (or the first command line argument).

PYME.ParallelTasks.dataserver_wsgi.wsgiref_server(options)