Skip to content

Commit

Permalink
[command] added main()
Browse files Browse the repository at this point in the history
  • Loading branch information
Stiivi committed Aug 28, 2014
1 parent f67f91a commit 04b958a
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions cubes/slicer/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,21 +461,26 @@ def edit_model(args):
help='backend name (currently limited only to SQL backends)')
subparser.set_defaults(func=generate_ddl)

args = parser.parse_args(sys.argv[1:])

if not args.func:
parser.print_help()
exit(0)
def main():
args = parser.parse_args(sys.argv[1:])

if args.cubes_debug:
args.func(args)
else:
try:
if not args.func:
parser.print_help()
exit(0)

if args.cubes_debug:
args.func(args)
except CubesError as e:
sys.stderr.write("ERROR: %s\n" % e)
exit(1)
except MissingPackageError as e:
sys.stderr.write("MISSING PACKAGE ERROR: %s\n" % e)
exit(2)
else:
try:
args.func(args)
except CubesError as e:
sys.stderr.write("ERROR: %s\n" % e)
exit(1)
except MissingPackageError as e:
sys.stderr.write("MISSING PACKAGE ERROR: %s\n" % e)
exit(2)

if __name__ == "__main__":
main()

0 comments on commit 04b958a

Please sign in to comment.