Пример #1
0
def pdf(query_string=dict()):
	job = getJob(query_string)
	default_key = job['groupfiles'].iterkeys().next()[0]
	key = query_string.get('key', [default_key])[0]
	email_dest = email_addresses.get(key, {})
	email_outcome, email_error = None, None
	
	# test if callback from email form
	try:
		addresses = query_string.get('em', [])
		email_body = ''.join(query_string.get('emailbody', ['']))
		email_subject = ''.join(query_string.get('subject', ['no subject']))
		action = query_string.get('action', None)
		
		docf = getJobFile( job, key)
		
		if len(addresses) > 0 and docf and len(email_subject) > 1:
			email_outcome = "Queueing email to " + ','.join(addresses) + ' - check the result later!';
			print(email_outcome)
			try:
				mailqueue.append(dict(
					to=addresses, body=email_body, subject=email_subject,
					attachment=pdfdir + docf))
			except:
				traceback.print_exc(file=sys.stdout)
				email_error = "<strong>Problem!</strong> unable to queue email!"
		elif action:
			email_error = "<strong>Oh snap!</strong> Some fields missing or incomplete!"
	except:
		raise

	return ( template_lookup.get_template("/pdf.html").render(printers=getPrinters(), job=job, key=key, email_templ=email_template, email_dest=email_dest, email_outcome=email_outcome, email_error=email_error), 'text/html')
Пример #2
0
def pdf(query_string=dict()):
    job = getJob(query_string)
    default_key = job['groupfiles'].iterkeys().next()[0]
    key = query_string.get('key', [default_key])[0]
    email_dest = email_addresses.get(key, {})
    email_outcome, email_error = None, None

    # test if callback from email form
    try:
        addresses = query_string.get('em', [])
        email_body = ''.join(query_string.get('emailbody', ['']))
        email_subject = ''.join(query_string.get('subject', ['no subject']))
        action = query_string.get('action', None)

        docf = getJobFile(job, key)

        if len(addresses) > 0 and docf and len(email_subject) > 1:
            email_outcome = "Queueing email to " + ','.join(
                addresses) + ' - check the result later!'
            print(email_outcome)
            try:
                mailqueue.append(
                    dict(to=addresses,
                         body=email_body,
                         subject=email_subject,
                         attachment=pdfdir + docf))
            except:
                traceback.print_exc(file=sys.stdout)
                email_error = "<strong>Problem!</strong> unable to queue email!"
        elif action:
            email_error = "<strong>Oh snap!</strong> Some fields missing or incomplete!"
    except:
        raise

    return (template_lookup.get_template("/pdf.html").render(
        printers=getPrinters(),
        job=job,
        key=key,
        email_templ=email_template,
        email_dest=email_dest,
        email_outcome=email_outcome,
        email_error=email_error), 'text/html')
Пример #3
0
def plain(query_string=dict()):
	job = getJob(query_string, returnLast=True)

	return ( template_lookup.get_template("/plain.html").render(printers=getPrinters(), job=job, pb='always'), 'text/html')
Пример #4
0
def printers(query_string=''):
	return ( template_lookup.get_template("/printers.html").render(printers=getPrinters()), 'text/html')
Пример #5
0
def plain(query_string=dict()):
    job = getJob(query_string, returnLast=True)

    return (template_lookup.get_template("/plain.html").render(
        printers=getPrinters(), job=job, pb='always'), 'text/html')
Пример #6
0
def printers(query_string=''):
    return (template_lookup.get_template("/printers.html").render(
        printers=getPrinters()), 'text/html')