def AssertNPMInstalled(): Logger.Info("Checking npm install path..", end = ' ') if not asserter.IsCommandExists("npm"): installhelper.InstallPrompt([ "npm" ]) else: Logger.Success("OK") Logger.Info("Verifying latest version of NPM", end = ' ') installhelper.Install("npm", "npm") Logger.Success("OK")
def AddToPath(syspath): if not IsAdmin(): return Logger.Failed("You have no permission to modify the path.") Logger.Info("Trying to add {} to path..".format(syspath), end=' ') if not syspath in os.environ['PATH']: if sys.platform == "win32": path = os.pathsep + syspath oldpath = os.environ['PATH'] Call('setx OLDPATH {}'.format(oldpath)) Call('setx /M PATH "%PATH%;{}"'.format(path)) return Logger.Success("OK") else: return Logger.Success("Path already defined, skipping")
def DownloadAndInstallWindowsService(service, serviceName): conf = config.GetConfig() exeName = serviceName + '.exe' exePath = conf['temp-download-folder'] + '/' + serviceName + '/' + exeName if DownloadTo(service['url'], serviceName, exeName): Logger.Success("Download finished") Logger.Info("Installing {}.. Follow the instructions.".format(exeName), end=' ') if InstallExe(exePath): return Logger.Success("Install finished") return Logger.Failed("Unexpected error during installation..") return Logger.Failed("Unexpected error during download..")
def InstallMongoDB(): conf = config.GetConfig() installdir = conf["install-root"] + 'mongodb' if not ash.AssertMongoInstalled(): if not sh.AddToPathPrompt(installdir + '/bin'): Logger.Alert("Make sure to add this path to env") return Logger.Success("Mongo is installed in {0}.".format(installdir))
def RegisterGitRemote(remote): if assertsh.AssertGitInstalled(): if assertsh.AssertCall("git remote add origin {}".format(remote)): sh.Call("git remote -v") return Logger.Success("git setup complete on: {}".format(remote)) else: return Logger.Failed("Could not add git remote: {}".format(remote)) else: return Logger.Failed("Unexpected error during git installation.")
def AssertGitInstalled(): Logger.Info("Checking git install path..", end = ' '), if not ( asserter.IsCommandExists("git") ): return installhelper.InstallPrompt([ "git" ]) else: return Logger.Success("OK");
def AssertDockerInstalled(): Logger.Info("Checking docker install path..", end = ' '), if not ( asserter.IsCommandExists("docker") ): return installhelper.InstallPrompt([ "docker" ]) else: return Logger.Success("OK");
def AssertMongoInstalled(): Logger.Info("Checking mongodb install path..", end = ' '), if not ( asserter.IsCommandExists("mongo") or asserter.IsCommandExists("mongod") or asserter.IsCommandExists("mongos") ): return installhelper.InstallPrompt([ "mongodb" ]) else: return Logger.Success("OK");
def AssertNodeInstalled(): Logger.Info("Checking node install path..", end = ' '), if not asserter.IsCommandExists("node"): return installhelper.InstallPrompt([ "nodejs", "npm" ]) else: return Logger.Success("OK"),
def AssertExpressInstalled(): Logger.Info("Checking express install path..", end = ' ') if not asserter.IsCommandExists("express"): return installhelper.InstallPrompt([ "express-generator" ], 'npm') else: return Logger.Success(" OK")