Beispiel #1
0
 def install(self):
     """ Basic Installation of Drupdates. """
     base_dir = self.settings.get('baseDir')
     backup_dir = self.settings.get('backupDir')
     dirs = [backup_dir, base_dir]
     for directory in dirs:
         Utils.check_dir(directory)
     current_dir = os.path.dirname(os.path.realpath(__file__))
     src = os.path.join(current_dir, "templates/settings.template")
     settings_file = os.path.join(Utils.check_dir(base_dir), 'settings.yaml')
     instructions_url = "http://drupdates.readthedocs.org/en/latest/setup/"
     if not os.path.isfile(settings_file):
         shutil.copy(src, settings_file)
         msg = "The Settings file {0} was created and needs updated.\n".format(settings_file)
         msg += "See {0} for instructions".format(instructions_url)
         print(msg)
         sys.exit(1)
     current_settings = open(settings_file, 'r')
     settings = yaml.load(current_settings)
     if 'repoDict' in settings and 'example' in settings['repoDict']['value']:
         msg = "The default Settings file, {0}, needs updated. \n ".format(settings_file)
         msg += "See {0} for instructions".format(instructions_url)
         print(msg)
         sys.exit(1)
Beispiel #2
0
 def download_plugin(name):
     """ Download the plugin, name, Drupdates oragnization on Github. """
     uri = 'https://github.com/drupdates/' + name + '.git'
     plugins_dir = Utils.check_dir(os.path.join('~', '.drupdates', 'plugins'))
     if not bool(urlparse(uri).netloc):
         msg = ("Error: {0} url, {1}, is not a valid url").format(name, uri)
         raise DrupdatesError(20, msg)
     response = requests.get(uri)
     if response.status_code not in [200, 201]:
         msg = "Plugin url {0} returned an invalid HTTP response code {1}".format(uri, response.status_code)
         raise DrupdatesError(20, msg)
     try:
         Repo.clone_from(uri, os.path.join(plugins_dir, name.title()))
     except git.exc.GitCommandError as git_error:
         msg = "Failed to clone the plugin repo\n Error: {0}".format(git_error)
         raise DrupdatesError(20, msg)
     else:
         plugins = Plugin.get_plugins()
         return plugins[name]
Beispiel #3
0
    def standup_site(self):
        """ Using the drush core-quick-drupal (qd) command stand-up a Drupal site.

        This will:
        - Perform site install with sqlite.
        - If needed, build webroot from a make file.
        - Install any sub sites (ie multi-sites)
        - Ensure that all the files in the web root are writable.

        """
        qd_settings = self.settings.get('qdCmds')
        qd_cmds = copy.copy(qd_settings)
        backup_dir = Utils.check_dir(self.settings.get('backupDir'))
        qd_cmds += ['--backup-dir=' + backup_dir]
        try:
            qd_cmds.remove('--no-backup')
        except ValueError:
            pass
        if self.settings.get('useMakeFile'):
            make_file = self.utilities.find_make_file(self._site_name, self.site_dir)
            if make_file:
                qd_cmds += ['--makefile=' + make_file]
            else:
                msg = "Can't find make file in {0} for {1}".format(self.site_dir, self._site_name)
                raise DrupdatesBuildError(20, msg)
            if self.settings.get('buildSource') == 'make':
                qd_cmds.remove('--use-existing')
        try:
            Drush.call(qd_cmds, self._site_name)
            sub_sites = Drush.get_sub_site_aliases(self._site_name)
            for alias, data in sub_sites.items():
                Drush.call(qd_cmds, alias)
                # Add sub site settings.php to list of file_cleanup() files.
                sub_site_st = Drush.call(['st'], alias, True)
                self.si_files.append(sub_site_st['site'] + '/settings.php')
                self.si_files.append(sub_site_st['files'] + '/.htaccess')
                self.si_files.append(sub_site_st['site'])
        except DrupdatesError as standup_error:
            raise standup_error
Beispiel #4
0
 def run_updates(self):
     """ Drupdates main function. """
     if self.settings.get('debug'):
         self.utilities.write_debug_file()
     report = {}
     for current_working_dir in self.working_dirs:
         try:
             current_working_dir = Utils.check_dir(current_working_dir)
             self.utilities.load_dir_settings(current_working_dir)
             update = self.update_sites(current_working_dir)
             report[current_working_dir] = update
         except DrupdatesError as update_error:
             report[current_working_dir] = update_error.msg
             if update_error.level >= 30:
                 break
             else:
                 continue
     try:
         reporting = Reports()
     except DrupdatesError as reports_error:
         print("Reporting error: \n {0}".format(reports_error.msg))
         sys.exit(1)
     reporting.send(report)
Beispiel #5
0
 def setup(self):
     """ Setup the plugins directory. """
     Utils.check_dir(os.path.join(expanduser('~'), '.drupdates', 'plugins'))