当前位置: 首页>>代码示例>>Python>>正文


Python OUT.warn方法代码示例

本文整理汇总了Python中WebappConfig.debug.OUT.warn方法的典型用法代码示例。如果您正苦于以下问题:Python OUT.warn方法的具体用法?Python OUT.warn怎么用?Python OUT.warn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WebappConfig.debug.OUT的用法示例。


在下文中一共展示了OUT.warn方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: write

# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import warn [as 别名]
    def write(self):
        '''
        Write the contents file.
        '''

        dbpath = self.appdb()

        if not dbpath:
            OUT.die('No package specified!')

        self.check_installdir()

        values = [' '.join(i) for i in list(self.__content.values())]

        if not self.__p:
            try:
                fd = os.open(self.appdb(), os.O_WRONLY | os.O_CREAT,
                             self.__perm(0o600))

                os.write(fd, ('\n'.join(values)).encode('utf-8'))

                os.close(fd)
            except Exception as e:
                OUT.warn('Failed to write content file ' + dbpath + '!\n' 
                         + 'Error was: ' + str(e))
        else:
            OUT.info('Would have written content file ' + dbpath + '!')
开发者ID:PPed72,项目名称:webapp-config,代码行数:29,代码来源:content.py

示例2: how_to_update

# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import warn [as 别名]
    def how_to_update(self, dirs):
        '''
        Instruct the user how to update the application.
        '''
        my_command = self.update_command

        directories = []

        for i in dirs:
            present = False
            if directories:
                for j in directories:
                    if (i == j[:len(i)] or 
                        j == i[:len(j)]):
                        present = True
                        break
            if not present:
                directories.append(i)

        my_command_list = ''

        for i in directories:
            if not self.dirisconfigprotected(i):
                my_command_list += 'CONFIG_PROTECT="' + i + '" ' + my_command + '\n'

        if not my_command_list:
            my_command_list = my_command

        OUT.warn('One or more files have been config protected\nTo comple'
                 'te your install, you need to run the following command(s):\n\n'
                 + my_command_list)
开发者ID:PPed72,项目名称:webapp-config,代码行数:33,代码来源:protect.py

示例3: mkdir

# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import warn [as 别名]
    def mkdir(self, directory, current_type):
        '''
        Create a directory with the correct ownership and permissions.

        directory   - name of the directory
        '''
        src_dir = self.__sourced + '/' + directory
        dst_dir = self.__destd + '/' + directory

        OUT.debug('Creating directory', 6)

        # some special cases
        #
        # these should be triggered only if we are trying to install
        # a webapp into a directory that already has files and dirs
        # inside it

        if os.path.exists(dst_dir) and not os.path.isdir(dst_dir):
            # something already exists with the same name
            #
            # in theory, this should automatically remove symlinked
            # directories

            OUT.warn('    ' + dst_dir + ' already exists, but is not a di'
                     'rectory - removing')
            if not self.__p:
                os.unlink(dst_dir)

        dirtype = self.__ws.dirtype(src_dir, current_type)

        OUT.debug('Checked directory type', 8)

        (user, group, perm) = self.__perm['dir'][dirtype]

        dsttype = 'dir'

        if not os.path.isdir(dst_dir):

            OUT.debug('Creating directory', 8)

            if not self.__p:
                os.makedirs(dst_dir, perm(0o755))

                os.chown(dst_dir,
                         user,
                         group)

        self.__content.add(dsttype,
                           dirtype,
                           self.__destd,
                           directory,
                           directory,
                           self.__relative)

        return dirtype
开发者ID:Feandil,项目名称:webapp-config,代码行数:57,代码来源:worker.py

示例4: clean

# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import warn [as 别名]
    def clean(self):

        self.file_behind_flag = False

        OUT.debug('Basic server clean', 7)

        self.file_behind_flag |= self.__del.remove_files()

        self.file_behind_flag |= self.__del.remove_dirs()

        OUT.info('Any files or directories listed above must be removed b'
                 'y hand')

        # okay, let's finish off
        #
        # we don't need the contents file anymore

        self.file_behind_flag |= not self.__content.kill()

        # right - we need to run the hook scripts now
        # if they fail, we don't actually care

        # run the hooks

        self.__ebuild.run_hooks('clean', self)

        # do we need the dotconfig file?
        #
        # if the .webapp file is the only one in the dir, we believe
        # that we can remove it

        self.__dotconfig.kill()

        # is the installation directory empty?

        if not os.listdir(self.__destd) and os.path.isdir(self.__destd):
            if not self.__p:
                os.rmdir(self.__destd)
        else:
            OUT.notice('--- ' + self.__destd)

        # update the list of installs

        self.__db.remove(self.__destd)

        # Remove the selinux module

        if self.__selinux is not None:
            self.__selinux.remove_module()

        # did we leave anything behind?

        if self.file_behind_flag:
            OUT.warn('Remove whatever is listed above by hand')
开发者ID:Feandil,项目名称:webapp-config,代码行数:56,代码来源:server.py

示例5: kill

# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import warn [as 别名]
 def kill(self):
     ''' Remove the contents file.'''
     if not self.__p:
         try:
             dbpath = self.appdb()
             self.check_installdir()
             os.unlink(dbpath)
             self.__content = {}
             return True
         except:
             OUT.warn('Failed to remove ' + self.appdb() + '!')
             return False
     else:
         OUT.info('Would have removed ' + self.appdb())
         return True
开发者ID:Feandil,项目名称:webapp-config,代码行数:17,代码来源:content.py

示例6: dirtype

# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import warn [as 别名]
    def dirtype(self, directory, parent_type = ''):
        '''
        Inputs:

          directory     - the directory that we need a decision about

          parent_type  - the type of the parent directory

        returns one of these:

          server-owned         - dir needs to be owned by the webserver user
          config-owned         - dir needs to be owned by the config user
          config-server-owned  - Both the previous cases at the same time
          server-owned-dir     - Directory that contains file/dirs to be owned
                                 by the webserver user
          default-owned        - we need a local copy, owned by root

        NOTE:
          Use get_filetype(filename) for files

        NOTE:
          the user can use --default-dirs on the command-line to change
          what type default directories are really reported as
        '''

        # remove any whitespace and trailing /
        directory = self.__fix(directory)

        # check the cache
        if directory in self.__cache.keys():
            # Check if parent type is recursive
            if parent_type == 'server-owned-dir':
                new_type = self.__cache[directory]
                if new_type == 'config-owned':
                    OUT.die('This version does not support config dirs')
                if new_type == server-owned:
                    OUT.warn('Configuration error: {} is marked server-owned two times'.format(filename))
                return 'server-owned-dir'
            return self.__cache[directory]

        # Check if parent type is recursive
        if parent_type == 'server-owned-dir':
            return 'server-owned-dir'
        # unspecified directories are default-owned
        return self.__default_dirs
开发者ID:Feandil,项目名称:webapp-config,代码行数:47,代码来源:filetype.py

示例7: filetype

# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import warn [as 别名]
    def filetype(self, filename, parent_type = ''):
        '''
        Inputs:

          filename      - the file that we need a decision about

          parent_type  - the type of the parent directory

        returns one of these:

          server-owned         - file needs to be owned by the webserver user
                                 (and needs to be a local copy)
          config-owned         - file needs to be owned by the config user
                                 (and needs to be a local copy)
          config-server-owned  - Both the previous cases at the same time
          virtual              - we do not need a local copy of the file

        NOTE:
          Use get_dirtype(directory) for directories

        NOTE:
          the user can use --virtual-files on the command-line to change
          what type virtual files are really reported as
        '''

        # remove any whitespace and trailing /
        filename = self.__fix(filename)

        # check the cache
        if filename in self.__cache.keys():
            # Check if parent type is recursive
            if parent_type == 'server-owned-dir':
                new_type = self.__cache[filename]
                if new_type == 'config-owned':
                    return 'config-server-owned'
                if new_type == 'server-owned':
                    OUT.warn('Configuration error: {} is marked server-owned twice'.format(filename))
                return 'server-owned' 
            return self.__cache[filename]

        # Check if parent type is recursive
        if parent_type == 'server-owned-dir':
            return 'server-owned'
        # unspecified file (and thus virtual)
        return self.__virtual_files
开发者ID:Feandil,项目名称:webapp-config,代码行数:47,代码来源:filetype.py

示例8: package_installed

# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import warn [as 别名]
def package_installed(full_name, pm):
    '''
    This function identifies installed packages.
    The Portage part is stolen from gentoolkit.
    We are not using gentoolkit directly as it doesn't seem to support ${ROOT}
    '''

    if pm == "portage":
        try:
            import portage
        except ImportError as e:
            OUT.die("Portage libraries not found, quitting:\n%s" % e)

        try:
             t = portage.db[portage.root]["vartree"].dbapi.match(full_name)
        # catch the "ambiguous package" Exception
        except ValueError as e:
            if isinstance(e[0], list):
                t = []
                for cp in e[0]:
                    t += portage.db[portage.root]["vartree"].dbapi.match(cp)
            else:
                raise ValueError(e)
        return t

    elif pm == "paludis":

        cmd="cave print-best-version '%s'" % (full_name)

        fi, fo, fe = os.popen3(cmd)
        fi.close()
        result_lines = fo.readlines()
        error_lines  = fe.readlines()
        fo.close()
        fe.close()

        if error_lines:
            for i in error_lines:
                OUT.warn(i)

        return ' '.join(result_lines)

    else:
        OUT.die("Unknown package manager: " + pm)
开发者ID:Feandil,项目名称:webapp-config,代码行数:46,代码来源:wrapper.py

示例9: mkdirs

# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import warn [as 别名]
    def mkdirs(self, directory = '', current_type = ''):
        '''
        Create a set of directories

        Inputs

        directory   - the directory within the source hierarchy
        '''

        sd = self.__sourced + '/' + directory
        real_dir = re.compile('/+').sub('/',
                self.__ws.appdir()
                + '/' + self.__sourced
                + '/' + directory)

        OUT.debug('Creating directories', 6)

        if not self.__ws.source_exists(sd):

            OUT.warn(self.__ws.package_name()
                     + ' does not install any files from '
                     + real_dir + '; skipping')
            return

        OUT.info('    Installing from ' + real_dir)

        for i in self.__ws.get_source_directories(sd):

            OUT.debug('Handling directory', 7)

            # create directory first
            next_type = self.mkdir(directory + '/' + i, current_type)

            # then recurse into the directory
            self.mkdirs(directory + '/' + i, next_type)

        for i in self.__ws.get_source_files(sd):

            OUT.debug('Handling file', 7)

            # handle the file
            self.mkfile(directory + '/' + i, current_type)
开发者ID:Feandil,项目名称:webapp-config,代码行数:44,代码来源:worker.py

示例10: kill

# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import warn [as 别名]
    def kill(self):
        ''' Remove the dot config file.'''

        empty = self.is_empty()

        OUT.debug('Trying to removing .webapp file', 7)

        if not empty:
            if not self.__p:
                try:
                    os.unlink(self.__dot_config())
                except:
                    OUT.warn('Failed to remove '
                             + self.__dot_config() + '!')
                    return False
            else:
                OUT.info('Would have removed ' + self.__dot_config())
            return True
        else:
            OUT.notice('--- ' + empty)
            return False
开发者ID:PPed72,项目名称:webapp-config,代码行数:23,代码来源:dotconfig.py

示例11: write

# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import warn [as 别名]
    def write(self):
        '''
        Write the contents file.

        A short test:

        >>> import os.path
        >>> here = os.path.dirname(os.path.realpath(__file__))
        >>> a = Contents(here + '/tests/testfiles/contents/',
        ...              package = 'test', version = '1.0',
        ...              pretend = True)
        >>> a.read()
        >>> OUT.color_off()
        >>> a.write() #doctest: +ELLIPSIS
        * Would have written content file .../tests/testfiles/contents//.webapp-test-1.0!
        '''

        dbpath = self.appdb()

        if not dbpath:
            OUT.die('No package specified!')

        self.check_installdir()

        values = [' '.join(i) for i in self.__content.values()]

        if not self.__p:
            try:
                fd = os.open(self.appdb(), os.O_WRONLY | os.O_CREAT,
                             self.__perm(0o600))

                os.write(fd, ('\n'.join(values)).encode('utf-8'))

                os.close(fd)
            except Exception as e:
                OUT.warn('Failed to write content file ' + dbpath + '!\n' 
                         + 'Error was: ' + str(e))
        else:
            OUT.info('Would have written content file ' + dbpath + '!')
开发者ID:Feandil,项目名称:webapp-config,代码行数:41,代码来源:content.py

示例12: remove_module

# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import warn [as 别名]
 def remove_module(self):
     OUT.info('Removing SELinux modules')
     for policy in self.policy_types:
         if subprocess.call(['semodule', '-s', policy, '-r', self.policy_name]):
             OUT.warn('Unable to remove {} SELinux module for {} @ {}'.format(policy, self.package_name, self.vhost_hostname))
开发者ID:Feandil,项目名称:webapp-config,代码行数:7,代码来源:selinux.py

示例13: prune_database

# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import warn [as 别名]
    def prune_database(self, action):
        '''
        Prunes the installs files to ensure no webapp
        is incorrectly listed as installed.
        '''

        loc = self.read_db()
        
        if not loc and self.__v:
            OUT.die('No virtual installs found!')

        files = self.list_locations()
        keys = sorted(loc)

        if action != 'clean':
            OUT.warn('This is a list of all outdated entries that would be removed: ')
        for j in keys:
            for i in loc[j]:
                appdir = i[3].strip()
                # We check to see if the webapp is installed.
                if not os.path.exists(appdir+'/.webapp-'+j):
                    if self.__v:
                       OUT.warn('No .webapp file found in dir: ')
                       OUT.warn(appdir)
                       OUT.warn('Assuming webapp is no longer installed.')
                       OUT.warn('Pruning entry from database.')
                    if action == 'clean':
                        for installs in files.keys():
                            contents = open(installs).readlines()
                            new_entries = ''
                            for entry in contents:
                                # Grab all the other entries but the one that
                                # isn't installed.
                                if not re.search('.* ' + appdir +'\\n', entry):
                                    new_entries += entry
                            f = open(installs, 'w')
                            f.write(new_entries)
                            f.close()
                    else:
                        OUT.warn(appdir)
开发者ID:Feandil,项目名称:webapp-config,代码行数:42,代码来源:db.py

示例14: remove

# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import warn [as 别名]
    def remove(self, installdir):
        '''
        Remove a record from the list of virtual installs.

        installdir - the installation directory
        '''
        if not installdir:
            OUT.die('The installation directory must be specified!')

        dbpath = self.appdb()

        if not dbpath:
            OUT.die('No package specified!')

        if not os.access(dbpath, os.R_OK):
            OUT.warn('Unable to read the install database ' + dbpath)
            return

        # Read db file
        fdb = open(dbpath)
        entries = fdb.readlines()
        fdb.close()

        newentries = []
        found = False

        for i in entries:

            j = i.strip().split(' ')

            if j:

                if len(j) != 4:

                    # Remove invalid entry
                    OUT.warn('Invalid line "' + i.strip() + '" remo'
                             'ved from the database file!')
                elif j[3] != installdir:

                    OUT.debug('Keeping entry', 7)

                    # Keep valid entry
                    newentries.append(i.strip())

                elif j[3] == installdir:

                    # Remove entry, indicate found
                    found = True

        if not found:
            OUT.warn('Installation at "' +  installdir + '" could not be '
                     'found in the database file. Check the entries in "'
                     + dbpath + '"!')

        if not self.__p:
            installs = open(dbpath, 'w')
            installs.write('\n'.join(newentries) + '\n')
            installs.close()
            if not self.has_installs():
                os.unlink(dbpath)
        else:
            OUT.info('Pretended to remove installation ' + installdir)
            OUT.info('Final DB content:\n' + '\n'.join(newentries) + '\n')
开发者ID:Feandil,项目名称:webapp-config,代码行数:65,代码来源:db.py

示例15: how_to_update

# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import warn [as 别名]
    def how_to_update(self, dirs):
        '''
        Instruct the user how to update the application.

        >>> OUT.color_off()
        >>> a = Protection('','horde','3.0.5','portage')

        >>> a.how_to_update(['/my/strange/htdocs/where/i/installed/x'])
        * One or more files have been config protected
        * To complete your install, you need to run the following command(s):
        * 
        * CONFIG_PROTECT="/my/strange/htdocs/where/i/installed/x" etc-update
        * 
        >>> a.how_to_update(['/a/','/c/'])
        * One or more files have been config protected
        * To complete your install, you need to run the following command(s):
        * 
        * CONFIG_PROTECT="/a/" etc-update
        * CONFIG_PROTECT="/c/" etc-update
        * 
        >>> a.how_to_update(['/a//test3','/a//test3/abc', '/c/'])
        * One or more files have been config protected
        * To complete your install, you need to run the following command(s):
        * 
        * CONFIG_PROTECT="/a//test3" etc-update
        * CONFIG_PROTECT="/c/" etc-update
        * 

        Add a virtual config protected directory:

        >>> a.config_protect += ' /my/strange/htdocs/'
        >>> a.how_to_update(['/my/strange/htdocs/where/i/installed/x'])
        * One or more files have been config protected
        * To complete your install, you need to run the following command(s):
        * 
        * etc-update
        '''
        my_command = self.update_command

        directories = []

        for i in dirs:
            present = False
            if directories:
                for j in directories:
                    if (i == j[:len(i)] or 
                        j == i[:len(j)]):
                        present = True
                        break
            if not present:
                directories.append(i)

        my_command_list = ''

        for i in directories:
            if not self.dirisconfigprotected(i):
                my_command_list += 'CONFIG_PROTECT="' + i + '" ' + my_command + '\n'

        if not my_command_list:
            my_command_list = my_command

        OUT.warn('One or more files have been config protected\nTo comple'
                 'te your install, you need to run the following command(s):\n\n'
                 + my_command_list)
开发者ID:Feandil,项目名称:webapp-config,代码行数:66,代码来源:protect.py


注:本文中的WebappConfig.debug.OUT.warn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。