本文整理汇总了Python中common.logger.info方法的典型用法代码示例。如果您正苦于以下问题:Python logger.info方法的具体用法?Python logger.info怎么用?Python logger.info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common.logger
的用法示例。
在下文中一共展示了logger.info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: filter_file
# 需要导入模块: from common import logger [as 别名]
# 或者: from common.logger import info [as 别名]
def filter_file(self):
file_list = self.file_list
if len(file_list) == 0:
return False
for r in file_list:
file_size = os.path.getsize(r) / 1024 / 1024 / 1024
if file_size <= 0.02:
os.remove(r)
logger.info('过滤删除-' + r)
file_list = self.file_list
if len(file_list) == 0:
logger.info('视频过滤后无文件可传')
return False
for f in file_list:
if f.endswith('.part'):
os.rename(f, os.path.splitext(f)[0])
logger.info('%s存在已更名' % f)
return True
示例2: login
# 需要导入模块: from common import logger [as 别名]
# 或者: from common.logger import info [as 别名]
def login(driver, filename):
logger.info('准备更新cookie')
# screen_shot = driver.save_screenshot('bin/1.png')
WebDriverWait(driver, 10).until(
ec.presence_of_element_located((By.XPATH, r'//*[@id="login-username"]')))
username = driver.find_element_by_xpath(r'//*[@id="login-username"]')
username.send_keys(engine.user_name)
password = driver.find_element_by_xpath('//*[@id="login-passwd"]')
password.send_keys(engine.pass_word)
driver.find_element_by_class_name("btn-login").click()
# logger.info('第四步')
# try:
cracker = slider_cracker(driver)
cracker.crack()
# except:
# logger.exception('出错')
time.sleep(5)
if driver.title == '投稿 - 哔哩哔哩弹幕视频网 - ( ゜- ゜)つロ 乾杯~ - bilibili':
cookie = driver.get_cookies()
print(cookie)
with open(filename, "w") as f:
json.dump(cookie, f)
logger.info('更新cookie成功')
else:
logger.info('更新cookie失败')
示例3: start
# 需要导入模块: from common import logger [as 别名]
# 或者: from common.logger import info [as 别名]
def start(self):
file_name = self.file_name
self.ydl_opts = {'outtmpl': file_name}
if self.check_stream():
pid = os.getpid()
monitor = Monitoring(pid, file_name)
self.flag = monitor.flag
t = Thread(target=monitor.start)
t.start()
retval = self.download()
self.rename(file_name)
monitor.stop()
if retval != 0:
logger.debug('准备递归下载')
self.start()
else:
logger.info('下载完成' + self.fname)
示例4: kill_child_processes
# 需要导入模块: from common import logger [as 别名]
# 或者: from common.logger import info [as 别名]
def kill_child_processes(self):
file_size = os.path.getsize(self.file_name) / 1024 / 1024 / 1024
if file_size <= self.last_file_size:
logger.error('下载卡死' + self.file_name)
if self.numc == 0:
self.parent.terminate()
else:
self.terminate()
time.sleep(1)
if os.path.isfile(self.file_name):
logger.info('卡死下载进程可能未成功退出')
return
else:
self.stop()
logger.info('卡死下载进程成功退出')
return
self.last_file_size = file_size
if file_size >= 2.5:
if self.numc == 0:
self.flag.set()
else:
self.terminate()
logger.info('分段下载' + self.file_name)
示例5: _startup
# 需要导入模块: from common import logger [as 别名]
# 或者: from common.logger import info [as 别名]
def _startup(self):
logger.info("正在启动微信登录过程...")
self.__process_login()
#保存rasa的引用
logger.info("微信机器人登录结束...")
#在启动后,直接调用register来注册一个on_message函数,到指定的微信群上
#为何要在这里做呢?因为如果这个时候不做,后面这句 bot.join就会阻塞这个过程
#如果在外面调用,必须等待这个_startup运行完毕,
#但是,这里面必须要写个
#self.register(group_names)
#这个线程,会挂在这里,防止退出
#能bot.search到的群,应该都是之前注册的那些群
示例6: check_in
# 需要导入模块: from common import logger [as 别名]
# 或者: from common.logger import info [as 别名]
def check_in(self):
""" inform backend that we started a manager, sending resources info """
logger.info(f"checking-in with the API…")
host_stats = query_host_stats(self.docker, self.workdir)
success, status_code, response = self.query_api(
"PUT",
f"/workers/{self.worker_name}/check-in",
payload={
"username": self.username,
"selfish": self.selfish,
"cpu": host_stats["cpu"]["total"],
"memory": host_stats["memory"]["total"],
"disk": host_stats["disk"]["total"],
"offliners": SUPPORTED_OFFLINERS,
"platforms": PLATFORMS_TASKS,
},
)
if not success:
logger.error("\tunable to check-in with the API.")
logger.debug(status_code)
logger.debug(response)
raise SystemExit()
logger.info("\tchecked-in!")
示例7: handle_broadcast_event
# 需要导入模块: from common import logger [as 别名]
# 或者: from common.logger import info [as 别名]
def handle_broadcast_event(self, received_string):
try:
key, data = received_string.split(" ", 1)
payload = json.loads(data)
logger.info(f"received {key} - {data[:100]}")
logger.debug(f"received: {key} – {json.dumps(payload, indent=4)}")
except Exception as exc:
logger.exception(exc)
logger.info(received_string)
return
if key == "cancel-task":
if payload in self.tasks.keys():
self.cancel_and_remove_task(payload)
else:
logger.debug("not our task, discarding")
elif key in ("requested-task", "requested-tasks"):
# incoming task. wait <nb-running> x <sleep_itvl> seconds before polling
# to allow idle workers to pick this up first
time.sleep(self.sleep_interval * len(self.tasks))
self.poll()
示例8: run
# 需要导入模块: from common import logger [as 别名]
# 或者: from common.logger import info [as 别名]
def run(self):
if self.should_stop: # early exit
return 1
context = zmq.Context()
socket = context.socket(zmq.SUB)
logger.info(f"subscribing to events from {self.socket_uri}…")
socket.connect(self.socket_uri)
for event in self.events:
logger.debug(f".. {event}")
socket.setsockopt_string(zmq.SUBSCRIBE, event)
while not self.should_stop:
try:
received_string = socket.recv_string(zmq.DONTWAIT)
self.handle_broadcast_event(received_string)
except zmq.Again:
pass
if self.should_poll:
self.sync_tasks_and_containers()
self.poll()
else:
self.sleep()
示例9: check_docker
# 需要导入模块: from common import logger [as 别名]
# 或者: from common.logger import info [as 别名]
def check_docker(self):
logger.info(f"testing docker API on {DOCKER_SOCKET}…")
if (
not DOCKER_SOCKET.exists()
or not DOCKER_SOCKET.is_socket()
or not os.access(DOCKER_SOCKET, os.R_OK)
):
logger.critical(f"\tsocket ({DOCKER_SOCKET}) not available.")
sys.exit(1)
self.docker = docker.DockerClient(
base_url=f"unix://{DOCKER_SOCKET}", timeout=DOCKER_CLIENT_TIMEOUT
)
try:
if len(self.docker.containers.list(all=False)) < 1:
logger.warning("\tno running container, am I out-of-docker?")
except Exception as exc:
logger.critical("\tdocker API access failed: exiting.")
logger.exception(exc)
sys.exit(1)
else:
logger.info("\tdocker API access successful")
示例10: remove_filelist
# 需要导入模块: from common import logger [as 别名]
# 或者: from common.logger import info [as 别名]
def remove_filelist(file_list):
for r in file_list:
os.remove(r)
logger.info('删除-' + r)
示例11: add_videos
# 需要导入模块: from common import logger [as 别名]
# 或者: from common.logger import info [as 别名]
def add_videos(self, driver, title_, videopath):
WebDriverWait(driver, 20).until(
ec.presence_of_element_located((By.NAME, 'buploader')))
upload = driver.find_element_by_name('buploader')
# print(driver.title)
# logger.info(driver.title)
upload.send_keys(videopath) # send_keys
logger.info('开始上传' + title_)
time.sleep(2)
button = r'//*[@class="new-feature-guide-v2-container"]/div/div/div/div/div[1]'
if self.is_element_exist(driver, button):
sb = driver.find_element_by_xpath(button)
sb.click()
sb.click()
sb.click()
logger.debug('点击')
while True:
try:
info = driver.find_elements_by_class_name(r'item-upload-info')
for t in info:
if t.text != '':
print(t.text)
time.sleep(10)
text = driver.find_elements_by_xpath(r'//*[@class="item-upload-info"]/span')
aggregate = set()
for s in text:
if s.text != '':
aggregate.add(s.text)
print(s.text)
if len(aggregate) == 1 and ('Upload complete' in aggregate or '上传完成' in aggregate):
break
except selenium.common.exceptions.StaleElementReferenceException:
logger.exception("selenium.common.exceptions.StaleElementReferenceException")
logger.info('上传%s个数%s' % (title_, len(info)))
示例12: start
# 需要导入模块: from common import logger [as 别名]
# 或者: from common.logger import info [as 别名]
def start(self, url, date=None):
title = self.title
if date:
title = str(date) + self.title
if self.filter_file():
logger.info('准备上传' + title)
try:
self.upload(title, self.file_list, link=url)
except selenium.common.exceptions.WebDriverException:
logger.exception('WebDriverException')
# except :
# logger.exception('?')
示例13: rename
# 需要导入模块: from common import logger [as 别名]
# 或者: from common.logger import info [as 别名]
def rename(file_name):
try:
os.rename(file_name + '.part', file_name)
logger.debug('更名{0}为{1}'.format(file_name + '.part', file_name))
except FileNotFoundError:
logger.info('FileNotFoundError:' + file_name)
except FileExistsError:
os.rename(file_name + '.part', file_name)
logger.info('FileExistsError:更名{0}为{1}'.format(file_name + '.part', file_name))
示例14: get_sinfo
# 需要导入模块: from common import logger [as 别名]
# 或者: from common.logger import info [as 别名]
def get_sinfo(self):
info_list = []
with youtube_dl.YoutubeDL() as ydl:
# cu = self.url.get(self.__class__.__name__)
if self.url:
info = ydl.extract_info(self.url, download=False)
else:
logger.debug('%s不存在' % self.__class__.__name__)
return
for i in info['formats']:
info_list.append(i['format_id'])
logger.debug(info_list)
return info_list
示例15: terminate
# 需要导入模块: from common import logger [as 别名]
# 或者: from common.logger import info [as 别名]
def terminate(self):
if self.numc == 0:
logger.error("ChildrenProcess doesn't exist")
else:
for process in self.children:
process.terminate()
# logger.info('下载卡死' + self.file_name)