def setConstants(request, im): im.BMUoptions = getBMUoptions() im.validateonly = 'validateonly' in request.POST constants = {} for override in im.BMUoptions['overrides']: if override[2] in request.POST: constants[override[2]] = [request.POST[override[2]],request.POST['override%s' % override[2]]] else: constants[override[2]] = ['', 'never'] return constants
def showqueue(request): elapsedtime = time.time() jobs, errors, jobcount, errorcount = getJoblist() if 'checkjobs' in request.POST: errors = None elif 'showerrors' in request.POST: jobs = None else: errors = None BMUoptions = getBMUoptions() elapsedtime = time.time() - elapsedtime status = 'up' timestamp = time.strftime("%b %d %Y %H:%M:%S", time.localtime()) return render(request, 'uploadmedia.html', {'dropdowns': BMUoptions, 'override_options': override_options, 'timestamp': timestamp, 'elapsedtime': '%8.2f' % elapsedtime, 'status': status, 'apptitle': TITLE, 'serverinfo': SERVERINFO, 'jobs': jobs, 'jobcount': jobcount, 'errors': errors, 'errorcount': errorcount})
def checkfilename(request): elapsedtime = time.time() if 'filenames2check' in request.POST and request.POST['filenames2check'] != '': listoffilenames = request.POST['filenames2check'] filenames = listoffilenames.split(' ') objectnumbers = [getNumber(o, INSTITUTION) for o in filenames] else: objectnumbers = [] listoffilenames = '' BMUoptions = getBMUoptions() elapsedtime = time.time() - elapsedtime status = 'up' timestamp = time.strftime("%b %d %Y %H:%M:%S", time.localtime()) return render(request, 'uploadmedia.html', {'filenames2check': listoffilenames, 'objectnumbers': objectnumbers, 'dropdowns': BMUoptions, 'override_options': override_options, 'timestamp': timestamp, 'elapsedtime': '%8.2f' % elapsedtime, 'status': status, 'apptitle': TITLE, 'serverinfo': SERVERINFO})
logger = logging.getLogger(__name__) logger.info('%s :: %s :: %s' % ('uploadmedia startup', '-', '-')) TITLE = 'Bulk Media Uploader' override_options = [['ifblank', 'Overide only if blank'], ['always', 'Always Overide']] overrride_default = 'ifblank' class im: # empty class for image metadata pass im.BMUoptions = getBMUoptions() def prepareFiles(request, validateonly, BMUoptions, constants): jobnumber = constants['jobnumber'] jobinfo = {} images = [] for lineno, afile in enumerate(request.FILES.getlist('imagefiles')): # print afile try: print "%s %s: %s %s (%s %s)" % ('id', lineno + 1, 'name', afile.name, 'size', afile.size) image = get_exif(afile) filename, objectnumber, imagenumber = getNumber(afile.name, INSTITUTION) datetimedigitized, dummy = assignValue('', 'ifblank', image, 'DateTimeDigitized', {}) imageinfo = {'id': lineno, 'name': afile.name, 'size': afile.size, 'objectnumber': objectnumber, 'imagenumber': imagenumber,