Пример #1
0
    def get_appl_physical_path(self, appcmd_exe=None):
        """
        Finding the `APPL_PHYSICAL_PATH`.

        Until such a time as Web Platform Installer or Web Deploy
        provide some way to identify the physical path of the `iisApp`
        being installed when the `runCommand` provider is used, we
        have to guess the physical path.  Start by querying appcmd.exe
        for all sites/site/application/virtualDirectory/@physicalPath
        definitions whose sites/site/@name matches the app name if
        given.  The first such physicalPath with a stamp file and the
        correct app name, if either of those options is given, is
        taken to be the APPL_PHYSICAL_PATH.
        """
        appl_physical_path = os.environ.get('APPL_PHYSICAL_PATH')
        if appl_physical_path is not None:
            if not os.path.exists(appl_physical_path):
                raise ValueError(
                    ('The APPL_PHYSICAL_PATH environment variable value is a '
                     'non-existent path: {0}').format(appl_physical_path))
            else:
                self.logger.info(
                    ('Found IIS app in APPL_PHYSICAL_PATH environment '
                     'variable at {0}').format(appl_physical_path))
                return appl_physical_path
        else:
            self.logger.info(
                'APPL_PHYSICAL_PATH environment variable not set')

        appl_physical_paths = list(
            path for path in fcgi.list_appl_paths(self.app_name, appcmd_exe)
            if os.path.exists(os.path.join(path, self.stamp_filename)))
        if len(appl_physical_paths) > 1:
            appl_physical_path = appl_physical_paths[0]
            logger.error(
                ('Found multiple {0} stamp files in the virtual directories, '
                 '{1}.  Choosing the most recent one: {2}').format(
                    self.stamp_filename, appl_physical_paths[1:],
                    appl_physical_path))
            return appl_physical_path
        elif len(appl_physical_paths) == 1:
            appl_physical_path = appl_physical_paths[0]
            self.logger.info(
                ('Found just one IIS app with a stamp file: {0}'
                 ).format(appl_physical_path))
            return appl_physical_path

        raise ValueError(
            ('Found no {0} stamp file in any of the virtual '
             'directories returned by appcmd.exe').format(
                self.stamp_filename))
Пример #2
0
 def delete_stamp_files(self, distribution):
     """
     Clean up likely stale iis_install.stamp files for bdist_webpi packages.
     """
     for appl_physical_path in fcgi.list_appl_paths(
             distribution.msdeploy_app_name):
         if not os.path.exists(
                 os.path.join(appl_physical_path, self.stamp_filename)):
             continue
         stamp_file = os.path.join(appl_physical_path, self.stamp_filename)
         if os.path.exists(stamp_file):
             logger.info('Removing stale install stamp file: {0}'.format(
                 stamp_file))
             os.remove(stamp_file)
Пример #3
0
 def delete_stamp_files(self, distribution):
     """
     Clean up likely stale iis_install.stamp files for bdist_webpi packages.
     """
     for appl_physical_path in fcgi.list_appl_paths(
         distribution.msdeploy_app_name):
         if not os.path.exists(os.path.join(
             appl_physical_path, self.stamp_filename)):
             continue
         stamp_file = os.path.join(
             appl_physical_path, self.stamp_filename)
         if os.path.exists(stamp_file):
             logger.info('Removing stale install stamp file: {0}'.format(
                 stamp_file))
             os.remove(stamp_file)
Пример #4
0
    def get_appl_physical_path(self, appcmd_exe=None):
        """
        Finding the `APPL_PHYSICAL_PATH`.

        Until such a time as Web Platform Installer or Web Deploy
        provide some way to identify the physical path of the `iisApp`
        being installed when the `runCommand` provider is used, we
        have to guess the physical path.  Start by querying appcmd.exe
        for all sites/site/application/virtualDirectory/@physicalPath
        definitions whose sites/site/@name matches the app name if
        given.  The first such physicalPath with a stamp file and the
        correct app name, if either of those options is given, is
        taken to be the APPL_PHYSICAL_PATH.
        """
        appl_physical_path = os.environ.get('APPL_PHYSICAL_PATH')
        if appl_physical_path is not None:
            if not os.path.exists(appl_physical_path):
                raise ValueError(
                    ('The APPL_PHYSICAL_PATH environment variable value is a '
                     'non-existent path: {0}').format(appl_physical_path))
            else:
                self.logger.info(
                    ('Found IIS app in APPL_PHYSICAL_PATH environment '
                     'variable at {0}').format(appl_physical_path))
                return appl_physical_path
        else:
            self.logger.info('APPL_PHYSICAL_PATH environment variable not set')

        appl_physical_paths = list(
            path for path in fcgi.list_appl_paths(self.app_name, appcmd_exe)
            if os.path.exists(os.path.join(path, self.stamp_filename)))
        if len(appl_physical_paths) > 1:
            appl_physical_path = appl_physical_paths[0]
            logger.error(
                ('Found multiple {0} stamp files in the virtual directories, '
                 '{1}.  Choosing the most recent one: {2}').format(
                     self.stamp_filename, appl_physical_paths[1:],
                     appl_physical_path))
            return appl_physical_path
        elif len(appl_physical_paths) == 1:
            appl_physical_path = appl_physical_paths[0]
            self.logger.info(('Found just one IIS app with a stamp file: {0}'
                              ).format(appl_physical_path))
            return appl_physical_path

        raise ValueError(
            ('Found no {0} stamp file in any of the virtual '
             'directories returned by appcmd.exe').format(self.stamp_filename))