Odyssey
customer.py
1 """
2 Manage customers (credit-unions).
3 """
4 
5 import shellish
6 import subprocess
7 import re
8 
9 
10 class Customer(shellish.Command):
11  """ Manage customers (credit-unions). """
12 
13  name = 'customer'
14 
15  def setup_args(self, parser):
16  self.add_subcommand(Create)
17 
18 
19 class Create(shellish.Command):
20  """ Create a new customer.
21 
22  This will create DB tables, records and filesystem assets for a new
23  credit-union.
24 
25  NOTE: This is a wrapper for the wellknown `cuset.pl` tool.
26  """
27 
28  name = 'create'
29  vendors = (
30  'AMI',
31  'COMPUSOURCE',
32  'CORRELATION',
33  'CRUISE',
34  'CU-CENTRIC',
35  'CUC',
36  'CUPRODIGY',
37  'CUSA',
38  'ESP',
39  'FEDCOMP',
40  'GALAXY',
41  'HARLAND',
42  'INFOWARE',
43  'SHARETEC',
44  'SOS',
45  'SYMITAR',
46  'ULTRADATA',
47  'WEBONLY',
48  'XP-SYSTEMS',
49  )
50 
51  def setup_args(self, parser):
52  self.add_argument('ident', help='Credit Union Identifier',
53  type=self.ident)
54  self.add_argument('--vendor', choices=self.vendors, help='Core vendor')
55  self.add_argument('--batch', action='store_true', help='Use `Batch` '
56  'insteade of `Live` mode.')
57  self.add_argument('--nodb', action='store_true', help='No Database')
58  self.add_argument('--nofs', action='store_true', help='No Filesystem')
59 
60  def ident(self, value):
61  if re.match('[a-zA-Z0-9]*', value).group() != value:
62  raise ValueError('Invalid characters')
63  return value
64 
65  def run(self, args):
66  cmd = [
67  '/usr/bin/env', 'perl', '/cli/cuset.pl',
68  '-f',
69  '-u', args.ident,
70  '-v', args.vendor if args.vendor else '',
71  '-t', 'B' if args.batch else 'L',
72  '-x', 'Y' if args.nofs else 'N',
73  '-w', 'Y' if args.nodb else 'N',
74  ]
75  raise SystemExit(subprocess.call(cmd))
def ident(self, value)
Definition: customer.py:60