This file contains hidden or 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
class EntryListHandler(tornado.web.RequestHandler): | |
def post(self, ressource_name): | |
# Get file content and mime type | |
fileContent = None | |
try: | |
fileContent = self.request.files['fname'][0]['body'] | |
except Exception, e: | |
if self.request.headers.has_key('Content-Type') and self.request.headers['Content-Type'].startswith("application/octet-stream"): | |
fileContent = self.request.body |
This file contains hidden or 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
# multipart post. Original from http://code.activestate.com/recipes/146306/ | |
# use StringIO or fd instead of buffer | |
import mimetools | |
import magic | |
def getMime(content): | |
ms = magic.open(magic.MAGIC_MIME) | |
ms.load() | |
magic_s = ms.buffer(content[:1024]) |
This file contains hidden or 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 | |
from lxml import etree | |
CARD_MULT=1 | |
CARD_SINGLE=0 | |
class xmlStor: | |
properties = {} |
This file contains hidden or 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
#!/bin/bash | |
ffmpeg -threads 2 -i $1 -vcodec libx264 -g 30 -deinterlace -b 900k -s 640x360 -padtop 60 -padbottom 60 -padcolor 000000 -aspect 4:3 -acodec mp3 -ab 64k $2 |
This file contains hidden or 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 search( searchRequest, idxPath): | |
initVM(CLASSPATH) | |
fsDir = FSDirectory.getDirectory(idxPath, False) | |
searcher = IndexSearcher(fsDir) | |
language = StandardAnalyzer() | |
queryp = QueryParser('all', language) | |
query = queryp.parse(searchRequest) # "title", language) | |
hits = searcher.search(query) | |
print "# Found %d hits for %s"%(len(hits), searchRequest) |
This file contains hidden or 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 indexFilesFromPath(dir, idxPath): | |
initVM(CLASSPATH) | |
writer = IndexWriter(idxPath, StandardAnalyzer(), True) | |
count = 1 | |
for root, dirs, files in os.walk(dir): | |
for file in files: | |
#print "- "+str(root)+" "+file | |
sfx = file[-3:] | |
if sfx.lower() not in [ "mp3","mp4", "ogg", "flac" ]: | |
continue |
This file contains hidden or 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 python2.5 | |
# vim:set fileencoding=utf-8 | |
import os | |
import sys | |
import tagpy | |
from lucene import \ | |
Document, IndexSearcher, FSDirectory, MultiFieldQueryParser, QueryParser, StandardAnalyzer, IndexWriter, \ | |
StringReader, IndexReader, MoreLikeThis, Term, TermQuery, BooleanQuery,BooleanClause , Field, initVM, CLASSPATH | |
def indexFilesFromPath(dir, idxPath): |
NewerOlder