コード例 #1
0
ファイル: ec2rl.py プロジェクト: robets/aws-ec2rescue-linux
import sys


def main():
    """
    Create the ec2rl instance and run it. Provide the user with messages relevant to their subcommand, if applicable.

    Returns:
        (int): 0 if no errors detected,
        201 if Python < 2.7,
    """

    if sys.hexversion < 0x2070000:
        print("ec2rl requires Python 2.7+, but running version is {0}.".format(
            platform.python_version()))
        return 201

    import ec2rlcore.main
    ec2rl = ec2rlcore.main.Main()
    ec2rl()

    return 0


if __name__ == "__main__":
    if "--pdb" in sys.argv:
        sys.argv.remove("--pdb")
        sys.exit(pdb.run("main()"))
    else:
        sys.exit(main())
コード例 #2
0
    if sys.hexversion < 0x2070000:
        print("ec2rl requires Python 2.7+, but running version is {0}.".format(
            platform.python_version()))
        return 201

    import ec2rlcore.main
    ec2rl = ec2rlcore.main.Main()
    return ec2rl()


def pdb_signal_handler(signal_num, stack_frame):
    """
    Handles the SIGUSR1 signal to initiate pdb
    """
    print("Received signal: {}".format(signal_num))
    pdb.Pdb().set_trace(stack_frame)


if __name__ == "__main__":
    if "--pdb" in sys.argv:
        sys.argv.remove("--pdb")
        sys.exit(pdb.run("main()"))
    else:
        # SIGUSR1 is POSIX signal 10
        signal.signal(signal.SIGUSR1, pdb_signal_handler)
        if main():
            sys.exit(0)
        else:
            sys.exit(1)