Example #1
0
def receive_fax():
    parameters = [arg.rstrip() for arg in argv]
    try:
        scriptname = parameters[0]
        filename = parameters[1]
        device = parameters[2]
        commid = parameters[3]
        reason = parameters[4]
        cid = parameters[5]
        mystery2 = parameters[6]
        msn = parameters[7]
    except IndexError:
        pass
    logging.info("Processing received fax %s" % commid)
    logging.debug(
        "Fax %s in file %s, received on device %s MSN %s, "
        'reason "%s", id %s' % (commid, filename, device, msn, reason, cid)
    )
    fullfname = settings.FAX_SPOOL_DIR + "/%s" % filename
    fax = Fax()
    fax.received_on = datetime.fromtimestamp(os.path.getmtime(fullfname))
    fax.filename = filename
    fax.device = device
    fax.comm_id = commid
    fax.msn = msn
    fax.caller_id = cid
    fax.msn = mystery2
    fax.status = 1  # Success
    fax.reason = reason
    try:
        fax.update_from_tiff()
    except ValueError, e:
        if not fax.reason == "":
            # There was an error
            fax.error = True
            fax.status = 2  # Error
            logging.info("Fax %s has an error; reason: %s" % fax.reason)
        else:
            raise e
Example #2
0
def create_fax_entry(metadata):
	from faxcelerate.fax.models import Fax
	def m(key):
		try:
			return metadata[key]
		except KeyError:
			return None
	f = Fax()
	f.comm_id = m('commid')
	f.station_id = m('tsi')
	f.msn = m('msn')
	f.received_on = m('date')
	f.time_to_receive = m('jobduration')
	f.conn_duration = m('connduration')
	f.pages = m('pages')
	f.params = m('params')
	f.reason = m('reason')
	f.filename = m('filename')
	f.caller_id = m('callerid')
	f.save()
	return f