本文整理汇总了Python中nikola.utils.LOGGER.notice方法的典型用法代码示例。如果您正苦于以下问题:Python LOGGER.notice方法的具体用法?Python LOGGER.notice怎么用?Python LOGGER.notice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nikola.utils.LOGGER
的用法示例。
在下文中一共展示了LOGGER.notice方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _execute
# 需要导入模块: from nikola.utils import LOGGER [as 别名]
# 或者: from nikola.utils.LOGGER import notice [as 别名]
def _execute(self, options, args):
"""Start test server."""
out_dir = self.site.config['OUTPUT_FOLDER']
if not os.path.isdir(out_dir):
LOGGER.error("Missing '{0}' folder?".format(out_dir))
else:
os.chdir(out_dir)
httpd = HTTPServer((options['address'], options['port']),
OurHTTPRequestHandler)
sa = httpd.socket.getsockname()
LOGGER.notice("Serving HTTP on {0} port {1} ...".format(*sa))
httpd.serve_forever()
示例2: spell_check
# 需要导入模块: from nikola.utils import LOGGER [as 别名]
# 或者: from nikola.utils.LOGGER import notice [as 别名]
def spell_check(self, post, lang):
""" Check spellings for the given post and given language. """
try:
dictionary = enchant.request_dict(lang)
checker = SpellChecker(lang, filters=[EmailFilter, URLFilter])
checker.set_text(post.text(lang=lang, strip_html=True))
words = [error.word for error in checker]
words = [
word for word in words if not dictionary.check(word)
]
LOGGER.notice(
'Mis-spelt words in %s: %s' % (
post.fragment_deps(lang), ', '.join(words)
)
)
except enchant.DictNotFoundError:
LOGGER.notice('No dictionary found for %s' % lang)
示例3: spell_check
# 需要导入模块: from nikola.utils import LOGGER [as 别名]
# 或者: from nikola.utils.LOGGER import notice [as 别名]
def spell_check(self, post, lang):
""" Check spellings for the given post and given language. """
if enchant.dict_exists(lang):
checker = SpellChecker(lang, filters=[EmailFilter, URLFilter])
checker.set_text(post.text(lang=lang, strip_html=True))
words = [error.word for error in checker]
words = [
word for word in words if
self._not_in_other_dictionaries(word, lang)
]
LOGGER.notice(
'Mis-spelt words in %s: %s' % (
post.fragment_deps(lang), ', '.join(words)
)
)
else:
LOGGER.notice('No dictionary found for %s' % lang)
示例4: _execute
# 需要导入模块: from nikola.utils import LOGGER [as 别名]
# 或者: from nikola.utils.LOGGER import notice [as 别名]
def _execute(self, command, args):
# Get last succesful deploy date
timestamp_path = os.path.join(self.site.config['CACHE_FOLDER'], 'lastdeploy')
if self.site.config['COMMENT_SYSTEM_ID'] == 'nikolademo':
LOGGER.warn("\nWARNING WARNING WARNING WARNING\n"
"You are deploying using the nikolademo Disqus account.\n"
"That means you will not be able to moderate the comments in your own site.\n"
"And is probably not what you want to do.\n"
"Think about it for 5 seconds, I'll wait :-)\n\n")
time.sleep(5)
deploy_drafts = self.site.config.get('DEPLOY_DRAFTS', True)
deploy_future = self.site.config.get('DEPLOY_FUTURE', False)
if not (deploy_drafts and deploy_future):
# Remove drafts and future posts
out_dir = self.site.config['OUTPUT_FOLDER']
self.site.scan_posts()
for post in self.site.timeline:
if (not deploy_drafts and post.is_draft) or \
(not deploy_future and post.publish_later):
remove_file(os.path.join(out_dir, post.destination_path()))
remove_file(os.path.join(out_dir, post.source_path))
for command in self.site.config['DEPLOY_COMMANDS']:
try:
with open(timestamp_path, 'rb') as inf:
last_deploy = literal_eval(inf.read().strip())
except Exception:
last_deploy = datetime(1970, 1, 1) # NOQA
LOGGER.notice("==>", command)
ret = subprocess.check_call(command, shell=True)
if ret != 0: # failed deployment
raise Exception("Failed deployment")
LOGGER.notice("Successful deployment")
new_deploy = datetime.now()
# Store timestamp of successful deployment
with codecs.open(timestamp_path, 'wb+', 'utf8') as outf:
outf.write(repr(new_deploy))
示例5: scan_links
# 需要导入模块: from nikola.utils import LOGGER [as 别名]
# 或者: from nikola.utils.LOGGER import notice [as 别名]
def scan_links(self, find_sources=False):
LOGGER.notice("Checking Links:")
LOGGER.notice("===============")
failure = False
for task in os.popen('nikola list --all', 'r').readlines():
task = task.strip()
if task.split(':')[0] in (
'render_tags', 'render_archive',
'render_galleries', 'render_indexes',
'render_pages'
'render_site') and '.html' in task:
if self.analyze(task, find_sources):
failure = True
if not failure:
LOGGER.notice("All links checked.")
return failure
示例6: _execute
# 需要导入模块: from nikola.utils import LOGGER [as 别名]
# 或者: from nikola.utils.LOGGER import notice [as 别名]
def _execute(self, options={}, args=None):
"""Create a new site."""
if not args:
print("Usage: nikola init folder [options]")
return False
target = args[0]
if target is None:
print(self.usage)
else:
if not options or not options.get('demo'):
self.create_empty_site(target)
LOGGER.notice('Created empty site at {0}.'.format(target))
else:
self.copy_sample_site(target)
LOGGER.notice("A new site with example data has been created at "
"{0}.".format(target))
LOGGER.notice("See README.txt in that folder for more information.")
self.create_configuration(target)
示例7: scan_files
# 需要导入模块: from nikola.utils import LOGGER [as 别名]
# 或者: from nikola.utils.LOGGER import notice [as 别名]
def scan_files(self):
failure = False
LOGGER.notice("Checking Files:")
LOGGER.notice("===============\n")
only_on_output, only_on_input = self.real_scan_files()
if only_on_output:
only_on_output.sort()
LOGGER.warn("Files from unknown origins:")
for f in only_on_output:
LOGGER.warn(f)
failure = True
if only_on_input:
only_on_input.sort()
LOGGER.warn("Files not generated:")
for f in only_on_input:
LOGGER.warn(f)
if not failure:
LOGGER.notice("All files checked.")
return failure
示例8: setUpClass
# 需要导入模块: from nikola.utils import LOGGER [as 别名]
# 或者: from nikola.utils.LOGGER import notice [as 别名]
def setUpClass():
LOGGER.notice('--- TESTS FOR ItemScope')
LOGGER.level = logbook.WARNING
示例9: tearDownClass
# 需要导入模块: from nikola.utils import LOGGER [as 别名]
# 或者: from nikola.utils.LOGGER import notice [as 别名]
def tearDownClass():
sys.stdout.write('\n')
LOGGER.level = logbook.NOTICE
LOGGER.notice('--- END OF TESTS FOR ItemPropUrl')
示例10: tearDownClass
# 需要导入模块: from nikola.utils import LOGGER [as 别名]
# 或者: from nikola.utils.LOGGER import notice [as 别名]
def tearDownClass():
sys.stdout.write('\n')
#LOGGER.level = logbook.NOTICE
LOGGER.notice('--- END OF TESTS FOR helloworld')
示例11: setUpClass
# 需要导入模块: from nikola.utils import LOGGER [as 别名]
# 或者: from nikola.utils.LOGGER import notice [as 别名]
def setUpClass():
from nikola.__main__ import main
main(['install_plugin', 'microdata'])
LOGGER.notice('--- TESTS FOR ItemScope')
LOGGER.level = logbook.WARNING
示例12: generate_css
# 需要导入模块: from nikola.utils import LOGGER [as 别名]
# 或者: from nikola.utils.LOGGER import notice [as 别名]
def generate_css():
# Compass compile
for theme_name in self.site.THEMES:
theme_root = os.path.abspath(utils.get_theme_path(theme_name))
compass_root = os.path.abspath(os.path.join(theme_root, 'style'))
tmp_dir = os.path.abspath(os.path.join(theme_root, '_tmp'))
if os.path.exists(compass_root):
LOGGER.notice("PYGMENTS CSS CODE")
create_code_css(self.site.config['CODE_COLOR_SCHEME'],
os.path.join(compass_root, 'css', 'code.css'))
LOGGER.notice("COMPASS COMPILE")
run('compass clean', cwd=compass_root)
run('compass compile', cwd=compass_root)
LOGGER.notice("AUTOPREFIXER")
LOGGER.notice("CWD: {}".format(theme_root))
run('autoprefixer -o _tmp/all.pre.css _tmp/all.css', cwd=theme_root)
LOGGER.notice("CSSO (CSS optimizer)")
LOGGER.notice("CWD: {}".format(theme_root))
run('csso _tmp/all.pre.css _tmp/all.min.css', cwd=theme_root)
LOGGER.notice("Move CSS to output")
css_output_dir = os.path.join(os.path.abspath(self.site.config['OUTPUT_FOLDER']), 'assets', 'css')
utils.makedirs(css_output_dir)
shutil.copy2(os.path.join(tmp_dir, 'all.min.css'), css_output_dir)
示例13: update_feed
# 需要导入模块: from nikola.utils import LOGGER [as 别名]
# 或者: from nikola.utils.LOGGER import notice [as 别名]
def update_feed(feed):
modified = feed.last_modified.timetuple()
etag = feed.etag
try:
parsed = feedparser.parse(
feed.url,
etag=etag,
modified=modified
)
feed.last_status = str(parsed.status)
except: # Probably a timeout
# TODO: log failure
return
if parsed.feed.get('title'):
LOGGER.notice(parsed.feed.title)
else:
LOGGER.notice(feed.url)
feed.etag = parsed.get('etag', 'foo')
modified = tuple(parsed.get('date_parsed', (1970, 1, 1)))[:6]
LOGGER.notice("==========>", modified)
modified = datetime.datetime(*modified)
feed.last_modified = modified
feed.save()
# No point in adding items from missinfg feeds
if parsed.status > 400:
# TODO log failure
return
for entry_data in parsed.entries:
LOGGER.notice("=========================================")
date = entry_data.get('published_parsed', None)
if date is None:
date = entry_data.get('updated_parsed', None)
if date is None:
LOGGER.error("Can't parse date from:\n", entry_data)
return False
LOGGER.notice("DATE:===>", date)
date = datetime.datetime(*(date[:6]))
title = "%s: %s" % (feed.name, entry_data.get('title', 'Sin título'))
content = entry_data.get('content', None)
if content:
content = content[0].value
if not content:
content = entry_data.get('description', None)
if not content:
content = entry_data.get('summary', 'Sin contenido')
guid = str(entry_data.get('guid', entry_data.link))
link = entry_data.link
LOGGER.notice(repr([date, title]))
e = list(Entry.select().where(Entry.guid == guid))
LOGGER.notice(
repr(dict(
date=date,
title=title,
content=content,
guid=guid,
feed=feed,
link=link,
))
)
if not e:
entry = Entry.create(
date=date,
title=title,
content=content,
guid=guid,
feed=feed,
link=link,
)
else:
entry = e[0]
entry.date = date
entry.title = title
entry.content = content
entry.link = link
entry.save()
示例14: tearDownModule
# 需要导入模块: from nikola.utils import LOGGER [as 别名]
# 或者: from nikola.utils.LOGGER import notice [as 别名]
def tearDownModule():
sys.stdout.write('\n')
LOGGER.level = logbook.NOTICE
LOGGER.notice('--- END OF TESTS FOR tags')
示例15: setUpClass
# 需要导入模块: from nikola.utils import LOGGER [as 别名]
# 或者: from nikola.utils.LOGGER import notice [as 别名]
def setUpClass():
LOGGER.notice('--- TESTS FOR helloworld')