예제 #1
0
def main():
    # parse option
    parser = argparse.ArgumentParser(conflict_handler="resolve")
    parser.add_argument("-v",
                        action="store_true",
                        dest="verbose",
                        default=False,
                        help="Verbose")
    parser.add_argument('-c',
                        action='store',
                        dest='comString',
                        default='',
                        type=str,
                        help='Execute a command in the batch mode')
    parser.add_argument("-3",
                        action="store_true",
                        dest="python3",
                        default=False,
                        help="Use python3")
    parser.add_argument('--version',
                        action='store_const',
                        const=True,
                        dest='version',
                        default=False,
                        help='Displays version')
    parser.add_argument('--devSrv',
                        action='store_const',
                        const=True,
                        dest='devSrv',
                        default=False,
                        help=argparse.SUPPRESS)
    parser.add_argument('--intrSrv',
                        action='store_const',
                        const=True,
                        dest='intrSrv',
                        default=False,
                        help=argparse.SUPPRESS)

    options, args = parser.parse_known_args()

    # display version
    if options.version:
        print("Version: %s" % PandaToolsPkgInfo.release_version)
        sys.exit(0)

    # use dev server
    if options.devSrv:
        Client.useDevServer()

    # use INTR server
    if options.intrSrv:
        Client.useIntrServer()

    # fork for Ctl-c
    global fork_child_pid
    fork_child_pid = os.fork()
    if fork_child_pid == -1:
        print("ERROR : Failed to fork")
        sys.exit(1)
    if fork_child_pid == 0:
        # main
        # instantiate core
        if options.verbose:
            print(options)
        pbookCore = PBookCore.PBookCore(verbose=options.verbose)

        # CUI
        intmain(pbookCore, options.comString)
    else:
        # set handler
        signal.signal(signal.SIGINT, catch_sig)
        signal.signal(signal.SIGHUP, catch_sig)
        signal.signal(signal.SIGTERM, catch_sig)
        pid, status = os.wait()
        if os.WIFSIGNALED(status):
            sys.exit(-os.WTERMSIG(status))
        elif os.WIFEXITED(status):
            sys.exit(os.WEXITSTATUS(status))
        else:
            sys.exit(0)
예제 #2
0
        dest='devSrv',
        default=False,
        help=
        "Please don't use this option. Only for developers to use the dev panda server"
    )

    options, args = parser.parse_args()

    # display version
    if options.version:
        print "Version: %s" % PandaToolsPkgInfo.release_version
        sys.exit(0)

    # use dev server
    if options.devSrv:
        Client.useDevServer()

    # fork for Ctl-c
    fork_child_pid = os.fork()
    if fork_child_pid == -1:
        print "ERROR : Failed to fork"
        sys.exit(1)
    if fork_child_pid == 0:
        # main
        if options.gui:
            # instantiate core with pass phrase
            if options.noPass:
                pbookCore = PBookCore(False, options.verbose)
            else:
                pbookCore = PBookCore(True, options.verbose)
            # GUI