本文整理汇总了Python中WebappConfig.debug.OUT.notice方法的典型用法代码示例。如果您正苦于以下问题:Python OUT.notice方法的具体用法?Python OUT.notice怎么用?Python OUT.notice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebappConfig.debug.OUT
的用法示例。
在下文中一共展示了OUT.notice方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: listservers
# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import notice [as 别名]
def listservers():
OUT.notice('\n'.join(['apache',
'lighttpd',
'cherokee',
'nginx',
'gatling']))
示例2: listunused
# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import notice [as 别名]
def listunused(self, db):
'''
Outputs a list of what has not been installed so far
'''
packages = self.list_locations()
if not packages:
OUT.die('No packages found!')
keys = sorted(packages)
OUT.debug('Check for unused web applications', 7)
for i in keys:
db.set_category(packages[i][0])
db.set_package (packages[i][1])
db.set_version (packages[i][2])
if not db.has_installs():
if packages[i][0]:
OUT.notice(packages[i][0] + '/' + packages[i][1] + '-' + packages[i][2])
else:
OUT.notice(packages[i][1] + '-' + packages[i][2])
示例3: listservers
# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import notice [as 别名]
def listservers():
OUT.notice('\n'.join(['apache',
'lighttpd',
'cherokee',
'nginx',
'gatling',
'hiawatha',
'tracd',]))
示例4: db_print
# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import notice [as 别名]
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))
示例5: clean
# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import notice [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')
示例6: show_installed
# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import notice [as 别名]
def show_installed(self):
''' Show which application has been installed in the install
location.'''
if not self.has_dotconfig():
OUT.die('No ' + self.__file + ' file in ' + self.__instdir
+ '; unable to continue')
self.read()
if 'WEB_CATEGORY' in self.__data:
OUT.notice(self.__data['WEB_CATEGORY'] + ' ' +
self.__data['WEB_PN'] + ' ' +
self.__data['WEB_PVR'])
else:
OUT.notice(
self.__data['WEB_PN'] + ' ' +
self.__data['WEB_PVR'])
示例7: kill
# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import notice [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
示例8: remove
# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import notice [as 别名]
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
示例9: show_post
# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import notice [as 别名]
def show_post(self, filename, ptype, server = None):
'''
Display one of the post files.
'''
post_file = self.__sourced + '/' + filename
OUT.debug('Check for instruction file', 7)
if not os.path.isfile(post_file):
return
self.run_vars(server)
post_instructions = open(post_file).readlines()
OUT.debug('Read post instructions', 7)
post = [
'',
'=================================================================',
'POST-' + ptype.upper() + ' INSTRUCTIONS',
'=================================================================',
'']
for i in post_instructions:
i = i.replace('"', '\\"')
post.append(os.popen('echo -n "' + i + '"\n').read()[:-1])
post = post + [
'',
'=================================================================',
'']
for i in post:
OUT.notice(i)
示例10: add
# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import notice [as 别名]
#.........这里部分代码省略.........
... destination = here + '/tests/testfiles/contents/app/',
... path = '/test2', relative = True)
b.entry(here + '/tests/testfiles/contents/app/test2') #doctest: +ELLIPSIS
'file 1 config-owned "test2" ... d8e8fca2dc0f896fd7cb4cb0031ba249 '
b.add('dir', 'default-owned',
... destination = here + '/tests/testfiles/contents/app/',
... path = '/dir1', relative = True)
b.entry(here + '/tests/testfiles/contents/app/dir1') #doctest: +ELLIPSIS
'dir 1 default-owned "dir1" ... 0 '
b.add('dir', 'default-owned', destination = here + '/tests/testfiles/contents/app',
... path = '/dir1',
... relative = False)
b.entry(here + '/tests/testfiles/contents/app/dir1') #doctest: +ELLIPSIS
'dir 0 default-owned ".../tests/testfiles/contents/app/dir1" ... 0 '
Q: Is the full link to the target what we want?
A: Yes, since the link will still be ok even if we move the directory.
b.add('sym', 'virtual',
... destination = here + '/tests/testfiles/contents/app/',
... path = '/test3', relative = True)
b.entry(here + '/tests/testfiles/contents/app/test3') #doctest: +ELLIPSIS
'sym 1 virtual "test3" ... 0 .../tests/testfiles/contents/app/test1'
b.db_print() #doctest: +ELLIPSIS
file 1 config-owned "test1" ... d8e8fca2dc0f896fd7cb4cb0031ba249
file 1 config-owned "test2" ... d8e8fca2dc0f896fd7cb4cb0031ba249
sym 1 virtual "test3" ... 0 .../tests/testfiles/contents/app/test1
dir 0 default-owned ".../tests/testfiles/contents/app/dir1" ... 0
'''
OUT.debug('Adding entry to content dictionary', 6)
# Build the full path that we use as index in the contents list
while path[0] == '/':
path = path[1:]
while destination[-1] == '/':
destination = destination[:-1]
entry = destination + '/' + path
# special case - we don't add entries for '.'
if os.path.basename(entry) == '.':
return
if (not self.__p
and not os.path.islink(entry)
and (not os.path.exists(entry)
or not os.access(entry, os.R_OK))):
OUT.warn('Cannot access file ' + entry + ' to add it as'
' installation content. This should not happen!')
return
allowed_types = {
'file' : [ 'file', self.file_md5, self.file_null ],
'hardlink': [ 'file', self.file_md5, self.file_null ],
'dir' : [ 'dir', self.file_zero, self.file_null ],
'sym' : [ 'sym', self.file_zero, self.file_link ],
}
if not dsttype in allowed_types.keys():
OUT.die('Oops, webapp-config bug. "dsttype" is ' + dsttype)
# Generate handler for file attributes
a = allowed_types[dsttype]
# For absolute entries the path must match the entry
if not relative:
path = entry
OUT.debug('Adding entry', 7)
# report if pretending
if self.__p:
OUT.info(' pretending to add: ' +
' '.join([dsttype,
str(int(relative)),
ctype,
'"' + path + '"']))
else:
# Only the path is enclosed in quotes, NOT the link targets
self.__content[entry] = [ a[0],
str(int(relative)),
ctype,
'"' + path + '"',
self.file_time(entry),
a[1](real_path),
a[2](entry)]
if self.__v:
msg = path
if msg[0] == "/":
msg = self.__root + msg
msg = self.__re.sub('/', msg)
OUT.notice('>>> ' + a[0] + ' ' * (4 - len(a[0])) + ' (' \
+ ctype + ') ' + msg)
示例11: mkfile
# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import notice [as 别名]
def mkfile(self, filename, current_type):
'''
This is what we are all about. No more games - lets take a file
from the master image of the web-based app, and make it available
inside the install directory.
filename - name of the file
'''
OUT.debug('Creating file', 6)
dst_name = self.__destd + '/' + filename
file_type = self.__ws.filetype(self.__sourced + '/' + filename, current_type)
OUT.debug('File type determined', 7)
# are we overwriting an existing file?
OUT.debug('Check for existing file', 7)
if os.path.exists(dst_name):
OUT.debug('File in the way!', 7)
my_canremove = True
# o-oh - we're going to be overwriting something that already
# exists
# If we are upgrading, check if the file can be removed
if self.__u:
my_canremove = self.__remove.remove(self.__destd, filename)
# Config protected file definitely cannot be removed
elif file_type[0:6] == 'config':
my_canremove = False
if not my_canremove:
# not able to remove the file
# or
# file is config-protected
dst_name = self.__protect.get_protectedname(self.__destd,
filename)
OUT.notice('^o^ hiding ' + filename)
self.config_protected_dirs.append(self.__destd + '/'
+ os.path.dirname(filename))
OUT.debug('Hiding config protected file', 7)
else:
# it's a file we do not know about - so get rid
# of it anyway
#
# this behaviour here *is* by popular request
# personally, I'm not comfortable with it -- Stuart
if not self.__p:
if os.path.isdir(dst_name):
os.rmdir(dst_name)
else:
os.unlink(dst_name)
else:
OUT.info(' would have removed "' + dst_name + '" s'
'ince it is in the way for the current instal'
'l. It should not be present in that location'
'!')
# if we get here, we can get on with the business of making
# the file available
(user, group, perm) = self.__perm['file'][file_type]
my_contenttype = ''
src_name = self.__ws.appdir() + '/' + self.__sourced + '/' + filename
# Fix the paths
src_name = re.compile('/+').sub('/', src_name)
dst_name = re.compile('/+').sub('/', dst_name)
OUT.debug('Creating File', 7)
# this is our default file type
#
# we link in (soft and hard links are supported)
# if we're allowed to
#
# some applications (/me points at PHP scripts)
# won't run if symlinked in.
# so we now support copying files in too
#
# default behaviour is to hard link (if we can), and
# to copy if we cannot
#
# if the user wants symlinks, then the user has to
# use the new '--soft' option
if file_type == 'virtual' or os.path.islink(src_name):
#.........这里部分代码省略.........
示例12: add
# 需要导入模块: from WebappConfig.debug import OUT [as 别名]
# 或者: from WebappConfig.debug.OUT import notice [as 别名]
#.........这里部分代码省略.........
<optional> is additional data that depends upon <what>
NOTE:
Filenames used to be on the end of the line. This made
the old bash version more complicated, and
prone to failure. So I have moved the filename into the
middle of the line. -- Stuart
Portage uses absolute names for its files, dirs, and symlinks.
We do not.
In theory, you can move a directory containing a web-based app,
and
a) the app itself will not break, and
b) webapp-config will still work on that directory
for upgrades and cleans.
Position-independence *is* a design constraint that all future
changes to this script need to honour.
Inputs:
dsttype - type to add (one of dir|sym|file|hardlink)
ctype - internal webapp-config type
- (server-owned | config-owned | virtual)
destination - install dir (normally $G_INSTALLDIR)
path - filename inside 'destination'
real_path - for config-protected files realpath =! path
(and this is important for md5)
relative - 1 for storing a relative filename, 0 otherwise
'''
OUT.debug('Adding entry to content dictionary', 6)
# Build the full path that we use as index in the contents list
while path[0] == '/':
path = path[1:]
while destination[-1] == '/':
destination = destination[:-1]
entry = destination + '/' + path
# special case - we don't add entries for '.'
if os.path.basename(entry) == '.':
return
if (not self.__p
and not os.path.islink(entry)
and (not os.path.exists(entry)
or not os.access(entry, os.R_OK))):
OUT.warn('Cannot access file ' + entry + ' to add it as'
' installation content. This should not happen!')
return
allowed_types = {
'file' : [ 'file', self.file_md5, self.file_null ],
'hardlink': [ 'file', self.file_md5, self.file_null ],
'dir' : [ 'dir', self.file_zero, self.file_null ],
'sym' : [ 'sym', self.file_zero, self.file_link ],
}
if not dsttype in list(allowed_types.keys()):
OUT.die('Oops, webapp-config bug. "dsttype" is ' + dsttype)
# Generate handler for file attributes
a = allowed_types[dsttype]
# For absolute entries the path must match the entry
if not relative:
path = entry
OUT.debug('Adding entry', 7)
# report if pretending
if self.__p:
OUT.info(' pretending to add: ' +
' '.join([dsttype,
str(int(relative)),
ctype,
'"' + path + '"']))
else:
# Only the path is enclosed in quotes, NOT the link targets
self.__content[entry] = [ a[0],
str(int(relative)),
ctype,
'"' + path + '"',
self.file_time(entry),
a[1](real_path),
a[2](entry)]
if self.__v:
msg = path
if msg[0] == "/":
msg = self.__root + msg
msg = self.__re.sub('/', msg)
OUT.notice('>>> ' + a[0] + ' ' * (4 - len(a[0])) + ' (' \
+ ctype + ') ' + msg)