本文整理汇总了Python中WebappConfig.debug.OUT类的典型用法代码示例。如果您正苦于以下问题:Python OUT类的具体用法?Python OUT怎么用?Python OUT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OUT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: packageavail
def packageavail(self):
'''
Check to see whether the given package has been installed or not.
These checks are carried out by using wrapper.py to facilitate
distribution independant handling of the task.
Outputs:
0 - on success
1 - package not found
2 - no package to find
3 - package isn't webapp-config compatible '
'''
OUT.debug('Verifying package ' + self.package_name(), 6)
# package_installed() does not handle "/PN" correctly
package = self.pn
if self.category:
package = self.category + '/' + self.pn
# not using self.package_name() here as we don't need pvr
return 1
# unfortunately, just because a package has been installed, it
# doesn't mean that the package itself is webapp-compatible
#
# we need to check that the package has an entry in the
# application repository
if not self.appdb():
return 3
else:
return 0
示例2: remove
def remove(self, entry):
'''
Decide whether to delete something - and then go ahead and do so
Just like portage, we only remove files that have not changed
from when we installed them. If the timestamp or checksum is
different, we leave the file in place.
Inputs
entry - file/dir/sym to remove
'''
OUT.debug('Trying to remove file', 6)
# okay, deal with the file | directory | symlink
removeable = self.__content.get_canremove(entry)
if not removeable:
# Remove directory or file.
# Report if we are only pretending
if self.__p:
OUT.info(' pretending to remove: ' + entry)
# try to remove the entry
try:
entry_type = self.__content.etype(entry)
if self.__content.etype(entry) == 'dir':
# its a directory -> rmdir
if not self.__p:
os.rmdir(entry)
else:
# its a file -> unlink
if not self.__p:
os.unlink(entry)
except:
# Report if there is a problem
OUT.notice('!!! '
+ self.__content.epath(entry))
return
if self.__v and not self.__p:
# Report successful deletion
OUT.notice('<<< ' + entry_type + ' '
* (5 - len(entry_type))
+ self.__content.epath(entry))
self.__content.delete(entry)
return True
else:
OUT.notice(removeable)
return False
示例3: listservers
def listservers():
OUT.notice('\n'.join(['apache',
'lighttpd',
'cherokee',
'nginx',
'gatling']))
示例4: read
def read(self,
config_owned = 'config-files',
server_owned = 'server-owned-files',
virtual_files = 'virtual',
default_dirs = 'default-owned'):
'''
Initialize the type cache.
'''
import WebappConfig.filetype
server_files = []
config_files = []
if os.access(self.appdir() + '/' + config_owned, os.R_OK):
flist = open(self.appdir() + '/' + config_owned)
config_files = flist.readlines()
OUT.debug('Identified config-protected files.', 7)
flist.close()
if os.access(self.appdir() + '/' + server_owned, os.R_OK):
flist = open(self.appdir() + '/' + server_owned)
server_files = flist.readlines()
OUT.debug('Identified server-owned files.', 7)
flist.close()
self.__types = WebappConfig.filetype.FileType(config_files,
server_files,
virtual_files,
default_dirs)
示例5: filetype
def filetype(self, filename, parent_type = ''):
''' Determine filetype for the given file.'''
if self.__types:
OUT.debug('Returning file type', 7)
return self.__types.filetype(filename, parent_type)
示例6: get_root
def get_root(config):
'''Returns the $ROOT variable'''
if config.config.get('USER', 'package_manager') == "portage":
try:
import portage
except ImportError as e:
OUT.die("Portage libraries not found, quitting:\n%s" % e)
return portage.settings['ROOT']
elif config.config.get('USER', 'package_manager') == "paludis":
cat = config.maybe_get('cat')
pn = config.maybe_get('pn')
if cat and pn:
cmd="cave print-id-environment-variable -b --format '%%v\n' --variable-name ROOT %s/%s" % (cat,pn)
fi, fo, fe = os.popen3(cmd)
fi.close()
result_lines = fo.readlines()
fo.close()
fe.close()
if result_lines[0].strip():
return result_lines[0].strip()
else:
return '/'
else:
return '/'
else:
OUT.die("Unknown package manager: " + pm)
示例7: dirtype
def dirtype(self, directory, parent_type = ''):
''' Determine filetype for the given directory.'''
if self.__types:
OUT.debug('Returning directory type', 7)
return self.__types.dirtype(directory, parent_type)
示例8: read
def read(self):
''' Read the contents of the dot config file.'''
dotconfig = self.__dot_config()
OUT.debug('Checking for dotconfig ', 6)
if not self.has_dotconfig():
raise Exception('Cannot read file ' + dotconfig)
tokens = shlex.shlex(open(dotconfig))
while True:
a = tokens.get_token()
b = tokens.get_token()
c = tokens.get_token()
OUT.debug('Reading token', 8)
if (a in self.__tokens and
b == '=' and c):
if c[0] == '"':
c = c[1:]
if c[-1] == '"':
c = c[:-1]
self.__data[a] = c
else:
break
示例9: how_to_update
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)
示例10: dirisconfigprotected
def dirisconfigprotected(self, installdir):
'''
Traverses the path of parent directories for the
given install dir and checks if any matches the list
of config protected files.
>>> a = Protection('','horde','3.0.5','portage')
Add a virtual config protected directory:
>>> a.config_protect += ' /my/strange/htdocs/'
>>> a.dirisconfigprotected('/my/strange/htdocs/where/i/installed/x')
True
>>> a.dirisconfigprotected('/my/strange/htdocs/where/i/installed/x/')
True
>>> a.config_protect += ' /my/strange/htdocs'
>>> a.dirisconfigprotected('/my/strange/htdocs/where/i/installed/x')
True
>>> a.dirisconfigprotected('/my/strange/htdocs/where/i/installed/x/')
True
>>> a.config_protect += ' bad_user /my/strange/htdocs'
>>> a.dirisconfigprotected('/my/bad_user/htdocs/where/i/installed/x')
False
>>> a.dirisconfigprotected('/my/strange/htdocs/where/i/installed/x/')
True
>>> a.dirisconfigprotected('/')
False
'''
my_master = []
for i in self.config_protect.split(' '):
if i[0] == '/':
if i[-1] == '/':
my_master.append(i[:-1])
else:
my_master.append(i)
if installdir[0] != '/':
OUT.die('BUG! Don\'t call this with a relative path.')
if installdir[-1] == '/':
my_dir = installdir[:-1]
else:
my_dir = installdir
while my_dir:
if my_dir == '.' or my_dir == '/':
return False
for x in my_master:
if my_dir == x:
return True
my_dir = os.path.dirname(my_dir)
# nope, the directory isn't config-protected at this time
return False
示例11: show_postinst
def show_postinst(self, server = None):
'''
Display any post-installation instructions, if there are any.
'''
OUT.debug('Running show_postinst', 6)
self.show_post(filename = 'postinst-en.txt', ptype = 'install', server = server)
示例12: test_read_corrupt
def test_read_corrupt(self):
contents = Contents('/'.join((HERE, 'testfiles', 'contents')),
package = 'test', version = '1.1')
OUT.color_off()
contents.read()
output = sys.stdout.getvalue().split('\n')
self.assertEqual(output[12], '* Not enough entries.')
示例13: show_postupgrade
def show_postupgrade(self, server = None):
'''
Display any post-upgrade instructions, if there are any.
'''
OUT.debug('Running show_postupgrade', 6)
self.show_post(filename = 'postupgrade-en.txt', ptype = 'upgrade', server = server)
示例14: listservers
def listservers():
OUT.notice('\n'.join(['apache',
'lighttpd',
'cherokee',
'nginx',
'gatling',
'hiawatha',
'tracd',]))
示例15: db_print
def db_print(self):
''' Print all enties of the contents file.'''
entries = self.get_sorted_files()
values = []
for i in entries:
# Fix relative entry
s = self.__content[i]
s[1] = str(int(s[1]))
values.append(' '.join(s))
OUT.notice('\n'.join(values))