#!/bin/env python # This module handles the real file names during filesender upload import os, sys, logging, threading, time, string from sqlalchemy import * import subprocess import re from pprint import * import Dumper ## needed to sort complex data structures from operator import itemgetter, attrgetter ## ## ====== DB connection to the Lifeportal tables DEFINED in file "startup_settings.sh" ====== application_db_engine = create_engine( os.environ['FILESENDERDB'], encoding='utf-8') metadata = MetaData(application_db_engine) def get_real_name ( vid ) : """ Retrieves the real file name (as opposed to the VID hash from table 'files' """ connection = application_db_engine.connect() filenames = [] result = connection.execute("select fileoriginalname from files where filevoucheruid = '%s' " % vid) for row in result: filenames.append(row.fileoriginalname) connection.close() print "FILENAMES ", filenames return filenames