]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - processor-sdk/performance-audio-sr.git/blob - processor_audio_sdk_1_00_00_00/tools/pyalpha/pyalpha/__main__.py
Update python headers
[processor-sdk/performance-audio-sr.git] / processor_audio_sdk_1_00_00_00 / tools / pyalpha / pyalpha / __main__.py
1 """
2 /*
3 Copyright (c) 2004 - 2016, Texas Instruments Incorporated - http://www.ti.com/
4 All rights reserved.
6 * Redistribution and use in source and binary forms, with or without 
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the
16 * distribution.
17 *
18 * Neither the name of Texas Instruments Incorporated nor the names of
19 * its contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 */
35 """
37 import sys
38 import argparse
39 from pyalpha import PyAlpha, ConversionError
41 # TODO USE ARGPARSE
42 parser = argparse.ArgumentParser(description='Alpha Command Communicator',
43                                  prog='PyAlpha',
44                                  add_help=False)
46 general_args = [
47     (['-?', '--help'], {
48         'help' : "show this help message and exit",
49         'action' : 'help',
50     }),
52     (['-h', '--header'], {
53         'help' : "Add FILE_a.h to symbol definition list and FILE_a.hdM to symbol decomposition list",
54         'metavar' : 'FILE',
55         'required' : True,
56     }),
58     (['-I', '--include'], {
59         'help' : "Add DIR to the include path. [default: ./alpha]",
60         'metavar' : 'DIR',
61         'default' : './alpha',
62     }),
64     (['-p', '--port'], {
65         'help' : "Communication port [default: COM1]",
66         'default' : 'COM1',
67     }),
69     (['-b', '--baud'], {
70         'help' : "Baud rate [default: 19200]",
71         'type' : int,
72         'default' : 19200,
73     }),
75     (['-t', '--temp'], {
76         'help' : "Temporary file save location [default: .]",
77         'metavar' : 'DIR',
78         'default' : '.',
79     }),
81     (['-r', '--retain'], {
82         'help' : "Retain temporary files",
83         'action' : 'store_true',
84     }),
86     (['--fast'], {
87         'help' : "Skip post-processing",
88         'action' : 'store_true',
89     }),
91     
92     (['alpha_list'], {
93         'help' : "Alpha commands, separated by spaces",
94         'nargs' : '+',
95         'metavar' : 'ALPHAS'
96     }),
97 ]
99 for arg in general_args:
100     parser.add_argument(*arg[0], **arg[1])
102 args = parser.parse_args()
104 p = PyAlpha(args.port, args.header, baud=args.baud, retain=args.retain,
105             inc=args.include, alfas=args.temp)
107 try:
108     ret = p.send(alpha_list=args.alpha_list, fast=args.fast)
109     print ret
110 except ConversionError, e:
111     pass