本文整理汇总了Python中feedback.Feedback.block方法的典型用法代码示例。如果您正苦于以下问题:Python Feedback.block方法的具体用法?Python Feedback.block怎么用?Python Feedback.block使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类feedback.Feedback
的用法示例。
在下文中一共展示了Feedback.block方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DevToolsDpkg
# 需要导入模块: from feedback import Feedback [as 别名]
# 或者: from feedback.Feedback import block [as 别名]
class DevToolsDpkg(DebPackage):
"""
Class for managing packages via 'dpkg'
"""
def __init__(self):
# Get the apt cache
self.cache = Cache()
# Feedback module
self.feedback = Feedback()
def installdeb(self, pkg):
"""
Install the Debian package.
:param pkg: The path to the package to install
:type pkg: str
"""
# Get the DebPackage object and the filename
dpkg = DebPackage(filename=pkg, cache=self.cache)
pkg_name = basename(pkg)
# Look for package conflicts
if not dpkg.check_conflicts():
self.feedback.block(dpkg.conflicts, 'CONFLICT')
self.feedback.error('Cannot install package <{0}>, conflicts with:'.format(pkg_name))
return False
# Get any version in cache
cache_version = dpkg.compare_to_version_in_cache()
action = 'Installed'
# Not installed
if cache_version == dpkg.VERSION_NONE:
self.feedback.info('Package <{0}> not installed'.format(pkg_name))
# Upgrading
if cache_version == dpkg.VERSION_OUTDATED:
self.feedback.info('Package <{0}> outdated, upgrading'.format(pkg_name))
action = 'Updated'
# Same version
if cache_version == dpkg.VERSION_SAME:
return self.feedback.info('Package <{0}> already installed'.format(pkg_name))
# Installed is newer
if cache_version == dpkg.VERSION_NEWER:
return self.feedback.info('Package <{0}> has newer version installed'.format(pkg_name))
# Install the package
dpkg.install()
self.feedback.success('{0}: {1}'.format(action, pkg_name))
示例2: value
# 需要导入模块: from feedback import Feedback [as 别名]
# 或者: from feedback.Feedback import block [as 别名]
w_back = feedback.warn('Testing warning message')
e_back = feedback.error('Testing error message')
# Test user input
feedback.input('Ask the user for some data: ', key='key_one')
feedback.input('Ask the user a "y" or "n" question? (y/n): ', key='key_two', yes_no=True)
feedback.input('Ask the user for a password and confirm: ', key='key_three', secure=True, confirm=True)
feedback.input('This input has a default value (123): ', key='key_four', default=123)
# Test block display and response retrieval
feedback.block([
'This is a block of indented text, and here is some stuff to look at:',
'Response 1: {0}'.format(feedback.get_response('key_one')),
'Response 2: {0}'.format(feedback.get_response('key_two')),
'Response 3: {0}'.format(feedback.get_response('key_three')),
'Response 4: {0}'.format(feedback.get_response('key_four')),
'Info Returned: {0}'.format(i_back),
'Success Returned: {0}'.format(s_back),
'Warn Returned: {0}'.format(w_back),
'Error Returned: {0}'.format(e_back),
'And that\'s the end of this block'
], 'ABOUT')
# Create new instance with timestamp
del feedback
feedback = Feedback(use_timestamp=True)
# Test basic messages
feedback.info('Testing information message')
feedback.success('Testing success message')
feedback.warn('Testing warning message')
feedback.error('Testing error message')