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


Python PluginHelper.show_legacy方法代码示例

本文整理汇总了Python中pynag.Plugins.PluginHelper.show_legacy方法的典型用法代码示例。如果您正苦于以下问题:Python PluginHelper.show_legacy方法的具体用法?Python PluginHelper.show_legacy怎么用?Python PluginHelper.show_legacy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pynag.Plugins.PluginHelper的用法示例。


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

示例1: PluginHelper

# 需要导入模块: from pynag.Plugins import PluginHelper [as 别名]
# 或者: from pynag.Plugins.PluginHelper import show_legacy [as 别名]
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# This script collects key figure metrics from hagstofan.is

from pynag.Plugins import PluginHelper, ok, unknown
import requests
from BeautifulSoup import BeautifulSoup

url = 'http://hagstofan.is'

p = PluginHelper()
p.parse_arguments()
p.show_legacy = True

tmp = requests.get(url)
html = tmp.content
soup = BeautifulSoup(html, convertEntities=BeautifulSoup.HTML_ENTITIES)

keyfigures_table = soup.find('table', {'class': 'keyfigures_small'})
if not keyfigures_table:
    p.exit(unknown, "Could not find any table with class=keyfigures_small'")
rows = keyfigures_table.findAll('tr')

for row in rows:
    textdata = row.find('td', {'class': 'textdata'})
    numberdata = row.find('td', {'class': 'numberdata'})

    if not textdata or not numberdata:
        continue
    # Get the text content out of the <td> cells
开发者ID:asbela,项目名称:monitor-iceland,代码行数:33,代码来源:check_hagstofan.py

示例2: reload

# 需要导入模块: from pynag.Plugins import PluginHelper [as 别名]
# 或者: from pynag.Plugins.PluginHelper import show_legacy [as 别名]
from dateutil.parser import parse
import requests
import sys
import time

from BeautifulSoup import BeautifulSoup
from pynag.Plugins import PluginHelper,ok,warning,critical,unknown

reload(sys)
sys.setdefaultencoding('utf-8')



helper = PluginHelper()
helper.parse_arguments()
helper.show_legacy = True

now = time.time()
url =  'http://hraun.vedur.is/ja/skjalftar/skjlisti.html'
html = requests.get(url).content
soup = BeautifulSoup(html)
tables = soup.findAll('table')
earthquakes = tables[2]
rows = earthquakes.findAll('tr')

header_row = rows.pop(0)
lines = []
recent_earthquakes = 0
major_earthquakes = 0
for row in rows:
  columns = row.findAll('td')
开发者ID:arthurtiteica,项目名称:monitor-iceland,代码行数:33,代码来源:check_earthquake.py


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