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


Python stdout.red函数代码示例

本文整理汇总了Python中stdout.red函数的典型用法代码示例。如果您正苦于以下问题:Python red函数的具体用法?Python red怎么用?Python red使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: get_kernel_version

def get_kernel_version(kerneldir):
    """
    Get the kernel version number and nickname

    @arg: string
    @return: string
    """
    # check for linux symlink
    if not os.path.isdir(kerneldir):
        print(red('error')+': no /usr/src/linux found')
        sys.exit(2)

    # best way *here* is to get KV from the sources, not the running KV
    if not os.path.isfile(kerneldir+'/Makefile'):
        # if no /Makefile, that sux big time
        print(red('error')+': no kernel Makefile found')
        sys.exit(2)
    head = []
    nlines = 0
    for line in open(kerneldir+'/Makefile'):
        line = line.replace(' ','')
        head.append(line.rstrip())
        nlines += 1
        if nlines >= 5:
            break
    head = dict(item.split("=") for item in head )

    return head['VERSION']+"."+head['PATCHLEVEL']+"."+head['SUBLEVEL']+head['EXTRAVERSION'], head['NAME']
开发者ID:kungfoo-linux,项目名称:kigen,代码行数:28,代码来源:misc.py

示例2: fail

    def fail(self, step):
        """
        @arg step   string

        @return     exit
        """
        print red('error')+': initramfs.lvm2.'+step+'() failed'
        sys.exit(2)
开发者ID:ac1965,项目名称:kigen,代码行数:8,代码来源:lvm2.py

示例3: fail

    def fail(self, step):
        """
        @arg step   string

        @return     exit
        """
        print red("error") + ": initramfs.busybox." + step + "() failed"
        sys.exit(2)
开发者ID:ac1965,项目名称:kigen,代码行数:8,代码来源:busybox.py

示例4: build_sequence

def build_sequence(master_config, temp, verbose):
	"""
	unionfs_fuse build sequence

	@arg master_config	dict
	@arg temp		dict
	@arg verbose		string

	@return: bool
	"""
	zero = int('0')
	ret = True

	if os.path.isfile('%s/unionfs-fuse-%s.tar.bz2' % (utils.get_distdir(temp), str(master_config['unionfs_fuse_ver']))) is not True:
		ret = download(master_config['unionfs_fuse_ver'], temp, verbose)
		if ret is not zero:
			print red('error: ')+'initramfs.unionfs_fuse.download() failed'
			sys.exit(2)

	ret = extract(master_config['unionfs_fuse_ver'], temp, verbose)
	ret = zero # grr, tar thing to not return 0

#	ret = configure(temp['work'] + '/unionfs_fuse/' + master_config['unionfs_fuse_ver'], master_config, temp, verbose)
#	if ret is not zero:
#		print red('error: ')+'initramfs.unionfs_fuse.configure() failed'
#		sys.exit(2)

	# add fuse lib path
	os.system('echo "CPPFLAGS += -static -I%s/include -L%s/lib/.libs" >> %s' % (temp['work'] + '/fuse-' + master_config['fuse_ver'], temp['work'] + '/fuse-' + master_config['fuse_ver'], temp['work'] + '/unionfs-fuse-' + master_config['unionfs_fuse_ver']+'/Makefile'))
	os.system('echo "CPPFLAGS += -static -I%s/include -L%s/lib/.libs" >> %s' % (temp['work'] + '/fuse-' + master_config['fuse_ver'], temp['work'] + '/fuse-' + master_config['fuse_ver'], temp['work'] + '/unionfs-fuse-' + master_config['unionfs_fuse_ver']+'/src/Makefile'))
	os.system('echo "LIB += -static -L%s/lib/.libs -ldl -lrt" >> %s' % (temp['work'] + '/fuse-' + master_config['fuse_ver'], temp['work'] + '/unionfs-fuse-' + master_config['unionfs_fuse_ver']+'/Makefile'))
	os.system('echo "LIB += -static -L%s/lib/.libs -ldl -lrt" >> %s' % (temp['work'] + '/fuse-' + master_config['fuse_ver'], temp['work'] + '/unionfs-fuse-' + master_config['unionfs_fuse_ver']+'/src/Makefile'))

	ret = compile(temp['work'] + '/unionfs-fuse-' + master_config['unionfs_fuse_ver'], master_config, verbose)
	if ret is not zero:
		print red('error: ')+'initramfs.unionfs_fuse.compile() failed'
		sys.exit(2)

# TODO remove manpage rm -rf %s/unionfs_fuse/man % temp['work']

	ret = strip(master_config, temp)
	if ret is not zero:
		print red('error: ')+'initramfs.unionfs_fuse.strip() failed'
		sys.exit(2)

	ret = compress(master_config, temp, verbose)
	if ret is not zero:
		print red('error: ')+'initramfs.unionfs_fuse.compress() failed'
		sys.exit(2)

	ret = cache(temp['work'] + '/unionfs-fuse-' + master_config['unionfs_fuse_ver'], master_config, temp, verbose)
	if ret is not zero:
		print red('error: ')+'initramfs.unionfs_fuse.compress() failed'

	return ret
开发者ID:ac1965,项目名称:kigen,代码行数:55,代码来源:unionfs_fuse.py

示例5: chgdir

 def chgdir(self, dir):
     """
     Change to directory
 
     @arg: string
     @return: none
     """
     if not os.path.isdir(dir):
         print red('error') + ': ' + 'cannot change dir to ' + dir
         sys.exit(2)
     if not os.getcwd() == dir:
         os.chdir(dir)
开发者ID:ac1965,项目名称:kigen,代码行数:12,代码来源:kernel.py

示例6: build_sequence

def build_sequence(master_config, temp, verbose):
	"""
	fuse build sequence

	@arg: dict
	@arg: dict
	@arg: string
	@return: bool
	"""
	zero = int('0')
	ret = True

	if os.path.isfile('%s/fuse-%s.tar.gz' % (utils.get_distdir(temp), str(master_config['fuse_ver']))) is not True:
		ret = download(master_config['fuse_ver'], temp, verbose)
		if ret is not zero:
			print(red('error: ')+'initramfs.fuse.download() failed')
			sys.exit(2)

	ret = extract(master_config['fuse_ver'], temp, verbose)
	ret = zero # grr, tar thing to not return 0 when success

	ret = configure(temp['work'] + '/fuse-' + master_config['fuse_ver'], master_config, temp, verbose)
	if ret is not zero:
		print(red('error: ')+'initramfs.fuse.configure() failed')
		sys.exit(2)

	ret = compile(temp['work'] + '/fuse-' + master_config['fuse_ver'], master_config, verbose)
	if ret is not zero:
		print(red('error: ')+'initramfs.fuse.compile() failed')
		sys.exit(2)

#	ret = install(temp['work'] + '/fuse-' + master_config['fuse_ver'], master_config, verbose)
#	if ret is not zero:
#		print red('error: ')+'initramfs.fuse.install() failed'
#		sys.exit(2)
#
#	ret = strip(master_config, temp)
#	if ret is not zero:
#		print red('error: ')+'initramfs.fuse.strip() failed'
#		sys.exit(2)
#
#	ret = compress(master_config, temp, verbose)
#	if ret is not zero:
#		print red('error: ')+'initramfs.fuse.compress() failed'
#		sys.exit(2)

	ret = cache(temp['work'] + '/fuse-' + master_config['fuse_ver'], master_config, temp, verbose)
	if ret is not zero:
		print(red('error: ')+'initramfs.fuse.compress() failed')
		sys.exit(2)

	return ret
开发者ID:kungfoo-linux,项目名称:kigen,代码行数:52,代码来源:fuse.py

示例7: fail

    def fail(self, step):
        """
        @arg step   string

        @return     exit
        """
        print(red("error") + ": initramfs.screen." + step + "() failed")
        sys.exit(2)
开发者ID:r1k0,项目名称:kigen,代码行数:8,代码来源:screen.py

示例8: fail

    def fail(self, step):
        """
        @arg step   string

        @return     exit
        """
        print(red('error')+': initramfs.splash.'+step+'() failed')
        sys.exit(2)
开发者ID:r1k0,项目名称:kigen,代码行数:8,代码来源:splash.py

示例9: copy_config

 def copy_config(self, source, dest): #, self.dotconfig, self.kerneldir + '/.config', self.quiet):
     """
     Copy kernel .config file to kerneldir 
     (/usr/src/linux by default)
 
     @arg: string
     @arg: string
     @return: none
     """
     cpv = ''
     if self.quiet is '': cpv = '-v'
     print green(' * ') + turquoise('kernel.copy_config') + ' ' + source + ' -> ' + dest
     if os.path.isfile(source):
         return os.system('cp %s %s %s' % (cpv, source, dest))
     else:
         print red('error: ') + source + " doesn't exist."
         sys.exit(2)
开发者ID:ac1965,项目名称:kigen,代码行数:17,代码来源:kernel.py

示例10: fail

    def fail(self, step):
        """
        Exit

        @arg step   string
        @return     exit
        """
        print(red('error')+': initramfs.dropbear.'+step+'() failed')
        sys.exit(2)
开发者ID:kungfoo-linux,项目名称:kigen,代码行数:9,代码来源:dropbear.py

示例11: build_sequence

def build_sequence(master_config, temp, quiet):
	"""
	iscsi build sequence

	@arg: dict
	@arg: dict
	@arg: string
	@return: bool
	"""
	zero = int('0')
	ret = True

	if os.path.isfile('%s/open-iscsi-%s.tar.gz' % (utils.get_distdir(temp), str(master_config['iscsi_ver']))) is not True:
		ret = download(master_config['iscsi_ver'], temp, quiet)
		if ret is not zero:
			print(red('error: ')+'initramfs.iscsi.download() failed')
			sys.exit(2)

	ret = extract(master_config['iscsi_ver'], temp, quiet)
	ret = zero # grr, tar thing to not return 0

	ret = compile(temp['work'] + '/open-iscsi-' + master_config['iscsi_ver'], master_config, quiet)
	if ret is not zero:
		print(red('error: ')+'initramfs.iscsi.compile() failed')
		sys.exit(2)

# TODO remove manpage rm -rf %s/iscsi/man % temp['work']

	ret = strip(master_config, temp)
	if ret is not zero:
		print(red('error: ')+'initramfs.iscsi.strip() failed')
		sys.exit(2)

	ret = compress(master_config, temp, quiet)
	if ret is not zero: 
		print(red('error: ')+'initramfs.iscsi.compress() failed')
		sys.exit(2)

	ret = cache(temp['work'] + '/open-iscsi-' + master_config['iscsi_ver'], master_config, temp, quiet)
	if ret is not zero: 
		print(red('error: ')+'initramfs.iscsi.compress() failed')
		sys.exit(2)

	return ret
开发者ID:kungfoo-linux,项目名称:kigen,代码行数:44,代码来源:iscsi.py

示例12: chgdir

    def chgdir(self, dir):
        """
        Change to directory

        @arg: string
        @return: none
        """
        if not os.path.isdir(dir):
            print(red("error") + ": " + "cannot change dir to " + dir)
            sys.exit(2)
        if not os.getcwd() == dir:
            os.chdir(dir)
开发者ID:r1k0,项目名称:kigen,代码行数:12,代码来源:screen.py

示例13: getdotconfig

def getdotconfig(binary, kerneldir, libdir, verbose):

    print(green(' * ')+turquoise('tool.extract.kernel.getdotconfig ')+'from '+binary+' to /var/tmp/kigen/dotconfig')

    if not os.path.isfile(binary):
        print(red('error')+': '+binary+' is not a file!')
        sys.exit(2)

    if os.path.isfile('/var/tmp/kigen/dotconfig'):
        from time import strftime
        os.system('mv %s %s-%s ' % ('/var/tmp/kigen/dotconfig', '/var/tmp/kigen/dotconfig', strftime("%Y-%m-%d-%H-%M-%S")))

    os.system('sh %s %s > /var/tmp/kigen/dotconfig 2>/dev/null' % (libdir+'/tools/extract-ikconfig', binary))
开发者ID:kungfoo-linux,项目名称:kigen,代码行数:13,代码来源:extract.py

示例14: initramfs

def initramfs(temproot, extract, to, verbose):
    """
    Extract user initramfs

    @return: bool
    """
    # copy initramfs to /usr/src/linux/usr/initramfs_data.cpio.gz, should we care?
    print(green(' * ') + turquoise('tool.extract.initramfs ') + 'to ' + to)

    # clean previous root
    if os.path.isdir(to):
        from time import strftime
        os.system('mv %s %s-%s ' % (to, to, strftime("%Y-%m-%d-%H-%M-%S")))
    else:
        process('mkdir -p %s' % to, verbose)

    # create dir if needed
    if not os.path.isdir(to):
        os.makedirs(to)

    # check if binary is gzip or xz format
    ret = gziporxz(extract, verbose)
    if ret is ':(':
        print(red('error') + ': don\'t know the format of %s' % extract)

    if ret is 'gzip':
        process('cp %s %s/initramfs_data.cpio.gz' % (extract, to), verbose)
        # extract gzip archive
        process('gzip -d -f %s/initramfs_data.cpio.gz' % to, verbose)

    elif ret is 'xz':
        process('cp %s %s/initramfs_data.cpio.xz' % (extract, to), verbose)
        process('unxz %s/initramfs_data.cpio.xz' % to, verbose)

    # extract cpio archive
    os.chdir(to)
    os.system('cpio -id < initramfs_data.cpio 2>/dev/null')
    os.system('rm initramfs_data.cpio')
开发者ID:kungfoo-linux,项目名称:kigen,代码行数:38,代码来源:extract.py

示例15: build

    def build(self):
        """
        luks build sequence

        @return: bool
        """
        zero = int('0')

        # make sure dev-libs/libgcrypt has static-libs use flag enabled
        if not pkg_has_useflag('dev-libs', 'libgcrypt', 'static-libs'):
            print(red('error')+': utils.pkg_has_useflag("dev-libs", "libgcrypt", "static-libs") failed, remerge libgcrypt with +static-libs')
            sys.exit(2)

        if os.path.isfile('%s/cryptsetup-%s.tar.bz2' % (get_distdir(self.temp), self.luks_ver)) is not True:
            print(green(' * ') + '... luks.download')
            if self.download() is not zero:
                process('rm -v %s/cryptsetup-%s.tar.bz2' % (get_distdir(self.temp), self.luks_ver), self.verbose)
                self.fail('download')

        print(green(' * ') + '... luks.extract')
        self.extract()
        # grr, tar thing to not return 0 when success

        print(green(' * ') + '... luks.configure')
        if self.configure()is not zero: self.fail('configure')

        print(green(' * ') + '... luks.make')
        if self.make() is not zero: self.fail('make')

        print(green(' * ') + '... luks.strip')
        if self.strip() is not zero: self.fail('strip')

        print(green(' * ') + '... luks.compress')
        if self.compress() is not zero: self.fail('compress')

        print(green(' * ') + '... luks.cache')
        if self.cache() is not zero: self.fail('cache')
开发者ID:r1k0,项目名称:kigen,代码行数:37,代码来源:luks.py


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