示例#1
0
文件: test.py 项目: tijmengit/pycopia
 def test_vgetty(self):
     #signal.signal(signal.SIGPIPE, signal.SIG_IGN)
     os.environ["VOICE_INPUT"] = "0"
     os.environ["VOICE_OUTPUT"] = "1"
     os.environ["VOICE_PID"] = str(os.getpid())
     os.environ["VOICE_PROGRAM"] = "Vgetty.py"
     cp = Vgetty.CallProgram()  # XXX
示例#2
0
def mailmessage(cp):
    parts = []
    # main message text and subject line
    body = CF.mail.body(line=CF.lines.get(cp._device), caller_id=cp.caller_id, caller_name=cp.caller_name)
    parts.append(body)
    subj = CF.mail.Subject(line=CF.lines.get(cp._device), caller_id=cp.caller_id, caller_name=cp.caller_name)
    # ogg file attachment
    oggfile = tempfile.NamedTemporaryFile(suffix=".ogg", prefix="voicemail", dir="/var/tmp")
    Vgetty.rmd2ogg(cp.inname, oggfile.name)
    oggfile.seek(0)
    ogg = ezmail.MIMEApplication.MIMEApplication(oggfile.read(), "ogg")
    ogg["Content-Disposition"] = "attachment; filename=%s" % (os.path.basename(cp.inname.replace("rmd", "ogg")), )
    oggfile.close()
    parts.append(ogg)
    # mail it!
    ezmail.mail(parts, subject=subj, To=CF.mail.To)
示例#3
0
def mailmessage(cp):
    parts = []
    # main message text and subject line
    body = CF.mail.body(line=CF.lines.get(cp._device),
                        caller_id=cp.caller_id,
                        caller_name=cp.caller_name)
    parts.append(body)
    subj = CF.mail.Subject(line=CF.lines.get(cp._device),
                           caller_id=cp.caller_id,
                           caller_name=cp.caller_name)
    # ogg file attachment
    oggfile = tempfile.NamedTemporaryFile(suffix=".ogg",
                                          prefix="voicemail",
                                          dir="/var/tmp")
    Vgetty.rmd2ogg(cp.inname, oggfile.name)
    oggfile.seek(0)
    ogg = ezmail.MIMEApplication.MIMEApplication(oggfile.read(), "ogg")
    ogg["Content-Disposition"] = "attachment; filename=%s" % (os.path.basename(
        cp.inname.replace("rmd", "ogg")), )
    oggfile.close()
    parts.append(ogg)
    # mail it!
    ezmail.mail(parts, subject=subj, To=CF.mail.To)
示例#4
0
def main(argv):
    cf = ConfigHolder()
    cf.VOICEDIR = "/var/spool/voice"
    cf.MESSAGEDIR = "messages"
    cf.SPOOLDIR = "incoming"
    cf.GREETING = "greeting.rmd"
    cf.LOGFILE = "/var/log/voicemail/voicemail.log"

    lf = logfile.open(cf.LOGFILE)

    try:
        rv = Vgetty.answering_machine(cf, lf)
    finally:
        lf.close()
    return rv
示例#5
0
def main(argv):
    cf = ConfigHolder()
    cf.VOICEDIR = "/var/spool/voice"
    cf.MESSAGEDIR = "messages"
    cf.SPOOLDIR = "incoming"
    cf.GREETING = "greeting.rmd"
    cf.LOGFILE = "/var/log/voicemail/voicemail.log"

    lf = logfile.open(cf.LOGFILE)

    try:
        rv = Vgetty.answering_machine(cf, lf)
    finally:
        lf.close()
    return rv
示例#6
0
def answering_machine(logfile=None, dtmf_handler=None):
    global CF
    greeting = os.path.join(CF.VOICEDIR, CF.MESSAGEDIR, CF.GREETING)

    cp = Vgetty.BasicCallProgram(logfile=logfile)
    cp.inname = os.path.join(CF.VOICEDIR, CF.SPOOLDIR,
                             "v-%s.rmd" % (int(time.time()), ))
    cp.set_dtmf_handler(dtmf_handler)
    cp.play(greeting)
    cp.beep()
    try:
        cp.record(cp.inname)
    except VgettyError, err:
        print >> sys.stderr, "%s: %s" % (time.ctime(), err)
        cp.beep(6000, 3)
        cp.close()