def check_drush_bin(self, drush_bin=None): """ Check if the given 'drush_bin' is installed. If 'drush_bin' isn't defined, use the "which" shell commande to detect the right location of 'drush' """ if drush_bin is not None: if os.path.isfile(drush_bin) and os.access(drush_bin, os.X_OK): self.drush_bin = drush_bin else: raise DrushBinError("given drush binary '%s' is not correct" % drush_bin) else: if Tools.which("drush") is not None: self.drush_bin = Tools.which("drush") else: raise DrushBinError("drush binary not detected")
def check_drush_install(config, logger): """ Check if drush binary is installed. First test the 'drush.path' value defined into configuration file. If this last isn't present set default to "which drush" command. """ try: drush_bin = config["drush"] if os.path.isfile(drush_bin) and os.access(drush_bin, os.X_OK): logger.info("%s binary is installed." % "drush") else: logger.error("%s binary not installed. exiting..." % "drush") sys.exit(1) except KeyError: logger.info("no value for drush.path in config: set to default value") if Tools.which("drush") is not None: drush_bin = Tools.which("drush") logger.info("=> %s" % drush_bin) else: logger.error("%s binary not installed. exiting..." % "drush") sys.exit(1) return drush_bin