summaryrefslogtreecommitdiffstats
path: root/clients/ivam-voicebox
blob: 02e5b3349c873183217aa8d72329e918961189fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/python

# $Id$
#
# This file is part of ivam2.
#
# ivam2 is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# ivam2 is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ivam2; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.

import sys, os, getopt

from ivamCore import log
from ivamUtil import getContents, setContents
import ivamCore, ivamVoiceBox

def usage():
    log("%s [--record-time=SECS] [--welcome-message=MESSAGE] [--pin=PIN] [--pin-file=PINFILE] [--message-program=BINARY] [--debug] [--record-only] [--no-record] DIRECTORY" % sys.argv[0])

def parseArgs(vb, argv):

    try:
        opts, args = getopt.getopt(argv[1:], "hd", ["help", "record-time=", "welcome-message=", "pin=", "pin-file=", "debug", "message-program=", "record-only", "no-record"])
    except getopt.GetoptError:
        usage()
        sys.exit(1)

    try:
        dname = args[0]
    except IndexError:
        usage()
        sys.exit(1)
        
    vb.setDirectory(dname)

    for o, a in opts:
        if o in ("-d", "--debug",):
            ivamCore.DEBUG = True
            
        elif o in ("-h", "--help",):
            usage()
            sys.exit()
            
        elif o in ("--record-time",):
            vb.recordTime = int(a)
            
        elif o in ("--welcome-message",):
            vb.setWelcomeMessage(a)
 
        elif o in ("--pin",):
            vb.setPin(a)
            
        elif o in ("--pin-file",):
            vb.setPin(getContents(a))
            
        elif o in ("--message-program",):
            vb.messageProgram = a

        elif o in ("--record-only",):
            vb.recordOnly = True

        elif o in ("--no-record",):
            vb.noRecord = True


def main():
    vb = ivamVoiceBox.VoiceBox()
    parseArgs(vb, sys.argv)
    ivamCore.newConnector(vb).run()
    sys.exit()

if __name__ == "__main__":
    main()