当前位置: 首页>>代码示例>>Python>>正文


Python Exit.printException方法代码示例

本文整理汇总了Python中lib.Functions.Exit.printException方法的典型用法代码示例。如果您正苦于以下问题:Python Exit.printException方法的具体用法?Python Exit.printException怎么用?Python Exit.printException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lib.Functions.Exit的用法示例。


在下文中一共展示了Exit.printException方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from lib.Functions import Exit [as 别名]
# 或者: from lib.Functions.Exit import printException [as 别名]
def main():
	dryRun =  "-D" in sys_argv
	debug =   "-d" in sys_argv
	verbose = "-v" in sys_argv
	quiet =   "-q" in sys_argv

	# configure Exit class
	Exit.quiet = quiet

	try:
		Init.init()
		# handover to a class instance
		poc = PoC(debug, verbose, quiet, dryRun)
		poc.Run()
		Exit.exit()

	except (CommonException, ConfigurationException, SimulatorException, CompilerException) as ex:
		print("{RED}ERROR:{NOCOLOR} {message}".format(message=ex.message, **Init.Foreground))
		cause = ex.__cause__
		if isinstance(cause, FileNotFoundError):
			print("{YELLOW}  FileNotFound:{NOCOLOR} '{cause}'".format(cause=str(cause), **Init.Foreground))
		elif isinstance(cause, NotADirectoryError):
			print("{YELLOW}  NotADirectory:{NOCOLOR} '{cause}'".format(cause=str(cause), **Init.Foreground))
		elif isinstance(cause, DuplicateOptionError):
			print("{YELLOW}  DuplicateOptionError:{NOCOLOR} '{cause}'".format(cause=str(cause), **Init.Foreground))
		elif isinstance(cause, ConfigParser_Error):
			print("{YELLOW}  configparser.Error:{NOCOLOR} '{cause}'".format(cause=str(cause), **Init.Foreground))
		elif isinstance(cause, ParserException):
			print("{YELLOW}  ParserException:{NOCOLOR} {cause}".format(cause=str(cause), **Init.Foreground))
			cause = cause.__cause__
			if (cause is not None):
				print("{YELLOW}    {name}:{NOCOLOR} {cause}".format(name=cause.__class__.__name__, cause= str(cause), **Init.Foreground))
		elif isinstance(cause, ToolChainException):
			print("{YELLOW}  {name}:{NOCOLOR} {cause}".format(name=cause.__class__.__name__, cause=str(cause), **Init.Foreground))
			cause = cause.__cause__
			if (cause is not None):
				if isinstance(cause, OSError):
					print("{YELLOW}    {name}:{NOCOLOR} {cause}".format(name=cause.__class__.__name__, cause=str(cause), **Init.Foreground))
			else:
				print("  Possible causes:")
				print("   - The compile order is broken.")
				print("   - A source file was not compiled and an old file got used.")

		if (not (verbose or debug)):
			print()
			print("{CYAN}  Use '-v' for verbose or '-d' for debug to print out extended messages.{NOCOLOR}".format(**Init.Foreground))
		Exit.exit(1)

	except EnvironmentException as ex:          Exit.printEnvironmentException(ex)
	except NotConfiguredException as ex:        Exit.printNotConfiguredException(ex)
	except PlatformNotSupportedException as ex: Exit.printPlatformNotSupportedException(ex)
	except ExceptionBase as ex:                 Exit.printExceptionbase(ex)
	except NotImplementedError as ex:           Exit.printNotImplementedError(ex)
	except Exception as ex:                     Exit.printException(ex)
开发者ID:krabo0om,项目名称:PoC,代码行数:56,代码来源:PoC.py

示例2: main

# 需要导入模块: from lib.Functions import Exit [as 别名]
# 或者: from lib.Functions.Exit import printException [as 别名]
def main():
	from colorama import Fore, Back, Style, init
	init()
	
	print(Fore.MAGENTA + "=" * 80)
	print("{: ^80s}".format("The PoC Library - NetList Service Tool"))
	print("=" * 80)
	print(Fore.RESET + Back.RESET + Style.RESET_ALL)
	
	try:
		import argparse
		import textwrap
		
		# create a command line argument parser
		argParser = argparse.ArgumentParser(
			formatter_class = argparse.RawDescriptionHelpFormatter,
			description = textwrap.dedent('''\
				This is the PoC Library NetList Service Tool.
				'''),
			add_help=False)

		# add arguments
		group1 = argParser.add_argument_group('Verbosity')
		group1.add_argument('-D', 																											help='enable script wrapper debug mode',	action='store_const', const=True, default=False)
		group1.add_argument('-d',																		dest="debug",				help='enable debug mode',									action='store_const', const=True, default=False)
		group1.add_argument('-v',																		dest="verbose",			help='print out detailed messages',				action='store_const', const=True, default=False)
		group1.add_argument('-q',																		dest="quiet",				help='run in quiet mode',									action='store_const', const=True, default=False)
		group1.add_argument('-r',																		dest="showReport",	help='show report',												action='store_const', const=True, default=False)
		group1.add_argument('-l',																		dest="showLog",			help='show logs',													action='store_const', const=True, default=False)
		group2 = argParser.add_argument_group('Commands')
		group21 = group2.add_mutually_exclusive_group(required=True)
		group21.add_argument('-h', '--help',												dest="help",				help='show this help message and exit',		action='store_const', const=True, default=False)
		group211 = group21.add_mutually_exclusive_group()
		group211.add_argument(		 '--coregen',	metavar="<Entity>",	dest="coreGen",			help='use Xilinx IP-Core Generator (CoreGen)')
		group211.add_argument(		 '--xst',			metavar="<Entity>",	dest="xst",					help='use Xilinx Compiler Tool (XST)')
		group3 = group211.add_argument_group('Specify target platform')
		group31 = group3.add_mutually_exclusive_group()
		group31.add_argument('--device',				metavar="<Device>",	dest="device",			help='target device (e.g. XC5VLX50T-1FF1136)')
		group31.add_argument('--board',					metavar="<Board>",	dest="board",				help='target board to infere the device (e.g. ML505)')

		# parse command line options
		args = argParser.parse_args()
		
	except Exception as ex:
		Exit.printException(ex)
		
	try:
		netList = NetList(args.debug, args.verbose, args.quiet)
		#netList.dryRun = True
	
		if (args.help == True):
			argParser.print_help()
			return
		elif (args.coreGen is not None):
			netList.coreGenCompilation(args.coreGen, args.showLog, args.showReport, deviceString=args.device, boardString=args.board)
		elif (args.xst is not None):
			netList.xstCompilation(args.xst, args.showLog, args.showReport, deviceString=args.device, boardString=args.board)
		else:
			argParser.print_help()
		
	except CompilerException as ex:
		from colorama import Fore, Back, Style
		from configparser import Error
		
		print(Fore.RED + "ERROR:" + Fore.RESET + " %s" % ex.message)
		if isinstance(ex.__cause__, FileNotFoundError):
			print(Fore.YELLOW + "  FileNotFound:" + Fore.RESET + " '%s'" % str(ex.__cause__))
		elif isinstance(ex.__cause__, Error):
			print(Fore.YELLOW + "  configparser.Error:" + Fore.RESET + " %s" % str(ex.__cause__))
		print(Fore.RESET + Back.RESET + Style.RESET_ALL)
		exit(1)
		
	except EnvironmentException as ex:					Exit.printEnvironmentException(ex)
	except NotConfiguredException as ex:				Exit.printNotConfiguredException(ex)
	except PlatformNotSupportedException as ex:	Exit.printPlatformNotSupportedException(ex)
	except BaseException as ex:									Exit.printBaseException(ex)
	except NotImplementedException as ex:				Exit.printNotImplementedException(ex)
	except Exception as ex:											Exit.printException(ex)
开发者ID:hoangt,项目名称:PoC,代码行数:80,代码来源:Netlist.py

示例3: main

# 需要导入模块: from lib.Functions import Exit [as 别名]
# 或者: from lib.Functions.Exit import printException [as 别名]
def main():
    from colorama import Fore, Back, Style, init

    init()

    print(Fore.MAGENTA + "=" * 80)
    print("{: ^80s}".format(Testbench.headLine))
    print("=" * 80)
    print(Fore.RESET + Back.RESET + Style.RESET_ALL)

    try:
        import argparse
        import textwrap

        # create a commandline argument parser
        argParser = argparse.ArgumentParser(
            formatter_class=argparse.RawDescriptionHelpFormatter,
            description=textwrap.dedent(
                """\
				This is the PoC Library Testbench Service Tool.
				"""
            ),
            add_help=False,
        )

        # add arguments
        group1 = argParser.add_argument_group("Verbosity")
        group1.add_argument(
            "-D", help="enable script wrapper debug mode", action="store_const", const=True, default=False
        )
        group1.add_argument(
            "-d", dest="debug", help="enable debug mode", action="store_const", const=True, default=False
        )
        group1.add_argument(
            "-v", dest="verbose", help="print out detailed messages", action="store_const", const=True, default=False
        )
        group1.add_argument(
            "-q", dest="quiet", help="run in quiet mode", action="store_const", const=True, default=False
        )
        group1.add_argument(
            "-r", dest="showReport", help="show report", action="store_const", const=True, default=False
        )
        group1.add_argument("-l", dest="showLog", help="show logs", action="store_const", const=True, default=False)
        group2 = argParser.add_argument_group("Commands")
        group21 = group2.add_mutually_exclusive_group(required=True)
        group21.add_argument(
            "-h",
            "--help",
            dest="help",
            help="show this help message and exit",
            action="store_const",
            const=True,
            default=False,
        )
        group21.add_argument("--list", metavar="<Entity>", dest="list", help="list available testbenches")
        group21.add_argument("--isim", metavar="<Entity>", dest="isim", help="use Xilinx ISE Simulator (isim)")
        group21.add_argument("--xsim", metavar="<Entity>", dest="xsim", help="use Xilinx Vivado Simulator (xsim)")
        group21.add_argument("--vsim", metavar="<Entity>", dest="vsim", help="use Mentor Graphics Simulator (vsim)")
        group21.add_argument("--ghdl", metavar="<Entity>", dest="ghdl", help="use GHDL Simulator (ghdl)")
        group3 = argParser.add_argument_group("Options")
        group3.add_argument(
            "--std", metavar="<version>", dest="std", help="set VHDL standard [87,93,02,08]; default=93"
        )
        # 		group3.add_argument('-i', '--interactive',					dest="interactive",	help='start simulation in interactive mode',	action='store_const', const=True, default=False)
        group3.add_argument(
            "-g",
            "--gui",
            dest="gui",
            help="start simulation in gui mode",
            action="store_const",
            const=True,
            default=False,
        )

        # parse command line options
        args = argParser.parse_args()

    except Exception as ex:
        Exit.printException(ex)

        # create class instance and start processing
    try:
        test = Testbench(args.debug, args.verbose, args.quiet)

        if args.help == True:
            argParser.print_help()
            print()
            return
        elif args.list is not None:
            test.listSimulations(args.list)
        elif args.isim is not None:
            iSimGUIMode = args.gui

            test.iSimSimulation(args.isim, args.showLog, args.showReport, iSimGUIMode)
        elif args.xsim is not None:
            xSimGUIMode = args.gui

            test.xSimSimulation(args.xsim, args.showLog, args.showReport, xSimGUIMode)
        elif args.vsim is not None:
            if (args.std is not None) and (args.std in ["87", "93", "02", "08"]):
#.........这里部分代码省略.........
开发者ID:hoangt,项目名称:PoC,代码行数:103,代码来源:Testbench.py

示例4: main

# 需要导入模块: from lib.Functions import Exit [as 别名]
# 或者: from lib.Functions.Exit import printException [as 别名]
def main():
	from sys import exit
	import argparse
	import textwrap
	import colorama
	
	colorama.init()
	
	try:
		# create a commandline argument parser
		argParser = argparse.ArgumentParser(
			formatter_class = argparse.RawDescriptionHelpFormatter,
			description = textwrap.dedent('''\
				This is the PoC-Library Repository Service Tool.
				'''),
			add_help=False)

		# add arguments
		group1 = argParser.add_argument_group('Verbosity')
		group1.add_argument('-D', 																														help='enable script wrapper debug mode',		action='store_const', const=True, default=False)
		group1.add_argument('-d',																	dest="debug",								help='enable debug mode',										action='store_const', const=True, default=False)
		group1.add_argument('-v',																	dest="verbose",							help='print out detailed messages',					action='store_const', const=True, default=False)
		group1.add_argument('-q',																	dest="quiet",								help='run in quiet mode',										action='store_const', const=True, default=False)
		group2 = argParser.add_argument_group('Commands')
		group21 = group2.add_mutually_exclusive_group(required=True)
		group21.add_argument('-h', '--help',											dest="help",								help='show this help message and exit',			action='store_const', const=True, default=False)
		group21.add_argument('--configure',												dest="configurePoC",				help='configure PoC Library',								action='store_const', const=True, default=False)
		group21.add_argument('--new-solution',	metavar="<Name>",	dest="newSolution",					help='create a new solution')
		group21.add_argument('--add-solution',	metavar="<Name>",	dest="addSolution",					help='add an existing solution')
		group21.add_argument('--ise-settingsfile',								dest="iseSettingsFile",			help='return Xilinx ISE settings file',			action='store_const', const=True, default=False)
		group21.add_argument('--vivado-settingsfile',							dest="vivadoSettingsFile",	help='return Xilinx Vivado settings file',	action='store_const', const=True, default=False)

		# parse command line options
		args = argParser.parse_args()

	except Exception as ex:
		Exit.printException(ex)

	# create class instance and start processing
	try:
		from colorama import Fore, Back, Style
		
		config = Configuration(args.debug, args.verbose, args.quiet)
		
		if (args.help == True):
			print(Fore.MAGENTA + "=" * 80)
			print("{: ^80s}".format(Configuration.headLine))
			print("=" * 80)
			print(Fore.RESET + Back.RESET + Style.RESET_ALL)
		
			argParser.print_help()
			return
		elif args.configurePoC:
			print(Fore.MAGENTA + "=" * 80)
			print("{: ^80s}".format(Configuration.headLine))
			print("=" * 80)
			print(Fore.RESET + Back.RESET + Style.RESET_ALL)
		
			#config.autoConfiguration()
			config.manualConfiguration()
			exit(0)
			
		elif args.newSolution:
			print(Fore.MAGENTA + "=" * 80)
			print("{: ^80s}".format(Configuration.headLine))
			print("=" * 80)
			print(Fore.RESET + Back.RESET + Style.RESET_ALL)
			
			config.newSolution(args.newSolution)
			exit(0)
			
		elif args.addSolution:
			print(Fore.MAGENTA + "=" * 80)
			print("{: ^80s}".format(Configuration.headLine))
			print("=" * 80)
			print(Fore.RESET + Back.RESET + Style.RESET_ALL)
			
			config.addSolution(args.addSolution)
			exit(0)
			
		elif args.iseSettingsFile:
			print(config.getISESettingsFile())
			exit(0)
		elif args.vivadoSettingsFile:
			print(config.getVivadoSettingsFile())
			exit(0)
		else:
			print(Fore.MAGENTA + "=" * 80)
			print("{: ^80s}".format(Configuration.headLine))
			print("=" * 80)
			print(Fore.RESET + Back.RESET + Style.RESET_ALL)
		
			argParser.print_help()
			exit(0)
	
#	except ConfiguratorException as ex:
#		from colorama import Fore, Back, Style
#		print(Fore.RED + "ERROR:" + Fore.RESET + " %s" % ex.message)
#		if isinstance(ex.__cause__, FileNotFoundError):
#			print(Fore.YELLOW + "  FileNotFound:" + Fore.RESET + " '%s'" % str(ex.__cause__))
#.........这里部分代码省略.........
开发者ID:hoangt,项目名称:PoC,代码行数:103,代码来源:Configuration.py


注:本文中的lib.Functions.Exit.printException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。