コード例 #1
0
def main():
    issudo = "sudo "

    # check if user is sudoer
    if os.geteuid() == 0:
        print "Sorry, you are root. Please type: ./installer without sudo. Your password will be required later. Exit program\n"
        sys.exit(2)

    # Check input parameters
    try:
        opts, args = getopt.getopt(sys.argv[1:], 'ha')
    except getopt.GetoptError:
        usage()
    for opt, arg in opts:
        if opt == '-h':
            usage()
        elif opt in ('-a'):
            issudo = ""

    try:
        this_computer = Os()
    except UnsupportedOs, e:
        MsgUser.debug(str(e))
        raise InstallFailed(str(e))
コード例 #2
0
def main():
    issudo = "sudo "

    # check if user is sudoer
    if os.geteuid() == 0:
        print "Sorry, you are root. Please type: ./installer without sudo. Your password will be required later. Exit program\n"
        sys.exit(2)

    # Check input parameters
    try:
        opts, args = getopt.getopt(sys.argv[1:], 'ha')
    except getopt.GetoptError:
        usage()
    for opt, arg in opts:
        if opt == '-h':
            usage()
        elif opt in ('-a'):
            issudo = ""

    try:
        this_computer = Os()
    except UnsupportedOs, e:
        MsgUser.debug(str(e))
        raise InstallFailed(str(e))
コード例 #3
0
    # fetch version of the toolbox
    print 'Fetch version of the toolbox... '
    with open (path_sct+"/version.txt", "r") as myfile:
        version_sct = Version(myfile.read().replace('\n', ''))
    print "  toolbox version: "+str(version_sct)

    # fetch version of the patch
    print 'Fetch version of the patch... '
    with open ("version.txt", "r") as myfile:
        version_patch = Version(myfile.read().replace('\n', ''))
    print "  patch version: "+str(version_patch)

    # if patch is not compatible with this release, send message and quit.
    print 'Check compatibility... '
    if version_sct == version_patch:
        MsgUser.failed("You already have installed this patch.")
        sys.exit(2)
    elif version_sct > version_patch:
        MsgUser.failed("You can't install a patch that is an oldest version than the one you have.")
        sys.exit(2)
    elif not version_sct.isEqualTo_MajorMinor(version_patch):
        print "  ERROR: Patch is not compatible with this release. Patch version X.Y.Z should correspond to release" \
                "  version X.Y. Exit program.\n"
        sys.exit(2)
    else:
        print "  OK"

    # list all files in patch
    files = [os.path.join(dp, f) for dp, dn, filenames in os.walk('.') for f in filenames]

    # copy files one by one (to inform user)
コード例 #4
0
    # fetch version of the toolbox
    print "Fetch version of the toolbox... "
    with open(path_sct + "/version.txt", "r") as myfile:
        version_sct = Version(myfile.read().replace("\n", ""))
    print "  toolbox version: " + str(version_sct)

    # fetch version of the patch
    print "Fetch version of the patch... "
    with open("version.txt", "r") as myfile:
        version_patch = Version(myfile.read().replace("\n", ""))
    print "  patch version: " + str(version_patch)

    # if patch is not compatible with this release, send message and quit.
    print "Check compatibility... "
    if version_sct == version_patch:
        MsgUser.failed("You already have installed this patch.")
        sys.exit(2)
    elif version_sct > version_patch:
        MsgUser.warning(
            "You can't install a patch that is an oldest version than the one you have. Installing this patch can broke the SCToolbox stability. Are you sure you want to install it?"
        )
        install_new = ""
        signal.alarm(120)
        while install_new not in ["yes", "no"]:
            install_new = input_timeout("[yes|no]: ")
        signal.alarm(0)
        if install_new == "no":
            sys.exit(2)
    elif not version_sct.isEqualTo_MajorMinor(version_patch):
        print "  ERROR: Patch is not compatible with this release. Patch version X.Y.Z should correspond to release" "  version X.Y. Exit program.\n"
        sys.exit(2)
コード例 #5
0
    # fetch version of the toolbox
    print 'Fetch version of the toolbox... '
    with open(os.path.join(path_sct, "spinalcordtoolbox", "version.txt"), "r") as myfile:
        version_sct = Version(myfile.read().rstrip())
    print "  toolbox version: "+str(version_sct)

    # fetch version of the patch
    print 'Fetch version of the patch... '
    with open("spinalcordtoolbox/version.txt", "r") as myfile:
        version_patch = Version(myfile.read().rstrip())
    print "  patch version: "+str(version_patch)

    # if patch is not compatible with this release, send message and quit.
    print 'Check compatibility... '
    if version_sct >= version_patch:
        MsgUser.warning("This patch is not newer than the current version. Are you sure you want to install it?")
        install_new = ""
        signal.alarm(120)
        while install_new not in ["yes", "no"]:
            install_new = input_timeout("[yes|no]: ")
        signal.alarm(0)
        if install_new == "no":
            sys.exit(2)
    elif not version_sct.isEqualTo_MajorMinor(version_patch):
        print "  ERROR: Patch is not compatible with this release. Patch version X.Y.Z should correspond to release" \
                "  version X.Y. Exit program.\n"
        sys.exit(2)
    else:
        print "  OK"

    # list all files in patch
コード例 #6
0
    # fetch version of the toolbox
    print 'Fetch version of the toolbox... '
    with open(os.path.join(path_sct, "version.txt"), "r") as myfile:
        version_sct = Version(myfile.read().rstrip())
    print "  toolbox version: "+str(version_sct)

    # fetch version of the patch
    print 'Fetch version of the patch... '
    with open("version.txt", "r") as myfile:
        version_patch = Version(myfile.read().rstrip())
    print "  patch version: "+str(version_patch)

    # if patch is not compatible with this release, send message and quit.
    print 'Check compatibility... '
    if version_sct >= version_patch:
        MsgUser.warning("This patch is not newer than the current version. Are you sure you want to install it?")
        install_new = ""
        signal.alarm(120)
        while install_new not in ["yes", "no"]:
            install_new = input_timeout("[yes|no]: ")
        signal.alarm(0)
        if install_new == "no":
            sys.exit(2)
    elif not version_sct.isEqualTo_MajorMinor(version_patch):
        print "  ERROR: Patch is not compatible with this release. Patch version X.Y.Z should correspond to release" \
                "  version X.Y. Exit program.\n"
        sys.exit(2)
    else:
        print "  OK"

    # list all files in patch