def parse(args): """ Parse the arguments and call the correct functions based on them. """ if len(args) == 0: shared.help_func(__helpstr__) else: try: optlist, arglist = getopt.getopt(args, "h", ["help"]) except getopt.error: err = sys.exc_info()[1] sys.stderr.write("Error: %s.\n" % str(err)) sys.exit(-1) for option, value in optlist: if option in ("-h", "--help"): shared.help_func(__helpstr__) if shared.version_exists(args[0]): remove(args[0]) else: sys.stdout.write("Error: there is no such version installed\n")
def install(ver, build_args): """ This calls the correct functions in the correct order to install Node. It also handles exceptions. """ if shared.version_exists(ver): sys.stderr.write("Error: %s is already installed\n" % ver) sys.exit(1) elif not shared.valid_version_string(ver): sys.stderr.write("Error: %s doesn't look like a valid version\n" % ver) sys.exit(2) try: nodesrc = install_helper.NodeSourceInstaller(ver, shared.get_version_dir(ver), build_args) sys.stdout.write("Downloading...\n") nodesrc.download() sys.stdout.write("Extracting...\n") nodesrc.extract() sys.stdout.write("Patching...\n") if len(shared.get_patches_list(ver)) == 0: sys.stdout.write("No patches found.\n") else: nodesrc.patch() sys.stdout.write("Configuring...\n") nodesrc.configure() sys.stdout.write("Building...\n") nodesrc.make() sys.stdout.write("Installing...\n") nodesrc.make_install() except StandardError: err = sys.exc_info()[1] sys.stderr.write("Error: %s\n" % str(err)) sys.exit(2) finally: sys.stdout.write("Cleaning up...\n") try: nodesrc.cleanup() except StandardError: pass
def install(ver, build_args): """ This calls the correct functions in the correct order to install Node. It also handles exceptions. """ if shared.version_exists(ver): sys.stderr.write("Error: %s is already installed\n" % ver) sys.exit(1) elif not shared.valid_version_string(ver): sys.stderr.write("Error: %s doesn't look like a valid version\n" % ver) sys.exit(2) try: nodesrc = install_helper.NodeSourceInstaller( ver, shared.get_version_dir(ver), build_args) sys.stdout.write("Downloading...\n") nodesrc.download() sys.stdout.write("Extracting...\n") nodesrc.extract() sys.stdout.write("Patching...\n") if len(shared.get_patches_list(ver)) == 0: sys.stdout.write("No patches found.\n") else: nodesrc.patch() sys.stdout.write("Configuring...\n") nodesrc.configure() sys.stdout.write("Building...\n") nodesrc.make() sys.stdout.write("Installing...\n") nodesrc.make_install() except StandardError: err = sys.exc_info()[1] sys.stderr.write("Error: %s\n" % str(err)) sys.exit(2) finally: sys.stdout.write("Cleaning up...\n") try: nodesrc.cleanup() except StandardError: pass