本文整理汇总了Python中core.Core.check_service_upd方法的典型用法代码示例。如果您正苦于以下问题:Python Core.check_service_upd方法的具体用法?Python Core.check_service_upd怎么用?Python Core.check_service_upd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.Core
的用法示例。
在下文中一共展示了Core.check_service_upd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BlrknCLI
# 需要导入模块: from core import Core [as 别名]
# 或者: from core.Core import check_service_upd [as 别名]
class BlrknCLI(object):
def __init__(self):
self.cfg = Config()
choice_rb_diff = [i for i in range(self.cfg.DiffCount())]
self.parser = argparse.ArgumentParser(add_help=True,
description='Tool for list of restricted websites '
'http://vigruzki.rkn.gov.ru/')
self.group = self.parser.add_mutually_exclusive_group()
self.group.add_argument("--dump", action="store_true", required=False, default=False, help="Get new dump")
self.group.add_argument("--diff", action="store", type=int, choices=choice_rb_diff, required=False,
default=None, help="difference dump")
self.group.add_argument("--rollback", action="store", type=int, choices=choice_rb_diff, required=False,
default=None, help="rollback dump")
self.group.add_argument("--stat", action="store", type=int, choices=choice_rb_diff, required=False,
default=None, help="dump statistics")
self.parser.add_argument("--url", action="store_true", required=False, default=False, help="url list show")
self.parser.add_argument("--ip", action="store_true", required=False, default=False, help="ip list show")
self.parser.add_argument("--domain", action="store_true", required=False, default=False,
help="domain list show")
self.parser.add_argument("--history", action="store_true", required=False, default=False,
help="history list show")
self.parser.add_argument('--bt', action='store', default='ignore',
choices=['default', 'ip', 'domain', 'domain-mask'], help='blockType')
self.parser.add_argument("-v", "--version", action='version', version='version 2.0.0', help="show version")
self.args = self.parser.parse_args()
# self._peewee_debug()
self.ip_print = self.args.ip
self.url_print = self.args.url
self.domain_print = self.args.domain
self.history_print = self.args.history
self.block_type = self.args.bt
self.dump = self.args.dump
self.diff = self.args.diff
self.rollback = self.args.rollback
self.stat = self.args.stat
self._cfg_logging()
logger.info('Starting script.')
self.ctl_transact = init_db(self.cfg)
self.report = Reporter(self.cfg)
if self.diff is None and self.rollback is None:
self.rollback = 0
if self.ip_print:
self.report.ip_show(bt=self.block_type, diff=self.diff, rollback=self.rollback)
elif self.url_print:
self.report.url_show(bt=self.block_type, diff=self.diff, rollback=self.rollback)
elif self.domain_print:
self.report.domain_show(bt=self.block_type, diff=self.diff, rollback=self.rollback)
elif self.history_print:
self.report.history_show()
elif self.stat is not None:
self.report.statistics_show(diff=self.stat, stdout=True)
elif self.dump:
# self._peewee_debug()
# self._parse_dump_only()
self._get_dump()
else:
self.parser.print_help()
logger.info('Script stopped.')
def _get_dump(self):
self.dump = Core(self.ctl_transact, self.cfg)
srv_msg = self.dump.check_service_upd()
if srv_msg:
if self.cfg.Notify():
self.notice = Notifier(self.cfg)
self.notice.send_mail(srv_msg, subject='vigruzki.rkn.gov.ru service update')
if self.dump.check_new_dump():
if self.cfg.GenRequest():
signer = Rutoken(self.cfg)
signer.gen_request()
signer.sign_request()
if self.dump.send_request():
if self.dump.get_request():
result_bool = self.dump.parse_dump()
if result_bool == 1:
if self.cfg.Notify():
message = self.report.statistics_show()
self.notice.send_mail(message)
elif result_bool == 0:
if self.cfg.Notify():
message = 'Houston, we have a problem'
self.notice.send_mail(message)
logger.info('parse_dump error')
def _parse_dump_only(self):
self.dump = Core(self.ctl_transact, self.cfg)
self.dump.code = 'test_' + ''.join(random.SystemRandom().
choice('abcdefgijklmnoprstuvwxyz1234567890') for _ in range(8))
History.create(requestCode=self.dump.code, date=datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
self.dump.code_id = History.get(History.requestCode == self.dump.code).id
self.dump.parse_dump()
#.........这里部分代码省略.........