def __init__(self, ver, install_path, build_args): self.ver = ver self.install_path = install_path self.build_args = build_args self.url = "http://nodejs.org/dist/v%s/node-v%s.tar.gz" % (self.ver, self.ver) try: urlopen(self.url) except HTTPError: raise shared.NoSuchVersionError("cannot download node-v%s.tar.gz" % self.ver) except URLError: raise IOError("make sure you are connected to the Internet") self.tmpdir = shared.get_tmp_dir() try: logfile_path = os.path.join(os.path.join(shared.get_nodevers_prefix(), "log")) self.logfile = open(logfile_path, "w") except IOError: self.logfile = open(os.devnull, 'w')
def __init__(self, ver, install_path, build_args): self.ver = ver self.install_path = install_path self.build_args = build_args self.url = "http://nodejs.org/dist/v%s/node-v%s.tar.gz" % (self.ver, self.ver) try: urlopen(self.url) except HTTPError: raise shared.NoSuchVersionError("cannot download node-v%s.tar.gz" % self.ver) except URLError: raise IOError("make sure you are connected to the Internet") self.tmpdir = shared.get_tmp_dir() try: logfile_path = os.path.join( os.path.join(shared.get_nodevers_prefix(), "log")) self.logfile = open(logfile_path, "w") except IOError: self.logfile = open(os.devnull, 'w')
""" This checks if nodevers prefix exists and then calls cli.parse(). """ import sys import nodevers.shared as shared import nodevers.cli as cli if not shared.valid_nodevers_prefix(shared.get_nodevers_prefix()): try: shared.mknodevers_prefix(shared.get_nodevers_prefix()) except IOError: sys.stderr.write("Error: failed to create the nodevers directory") sys.exit(3) def main(argv): try: cli.parse(argv[1:]) except KeyboardInterrupt: sys.exit(1) if __name__ == "__main__": main(sys.argv)