本文整理匯總了Python中logzero.logger.debug方法的典型用法代碼示例。如果您正苦於以下問題:Python logger.debug方法的具體用法?Python logger.debug怎麽用?Python logger.debug使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類logzero.logger
的用法示例。
在下文中一共展示了logger.debug方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: delete_replica_set
# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import debug [as 別名]
def delete_replica_set(name: str, ns: str = "default",
label_selector: str = "name in ({name})",
secrets: Secrets = None):
"""
Delete a replica set by `name` in the namespace `ns`.
The replica set is deleted without a graceful period to trigger an abrupt
termination.
The selected resources are matched by the given `label_selector`.
"""
label_selector = label_selector.format(name=name)
api = create_k8s_api_client(secrets)
v1 = client.ExtensionsV1beta1Api(api)
if label_selector:
ret = v1.list_namespaced_replica_set(ns, label_selector=label_selector)
else:
ret = v1.list_namespaced_replica_set(ns)
logger.debug("Found {d} replica sets named '{n}'".format(
d=len(ret.items), n=name))
body = client.V1DeleteOptions()
for r in ret.items:
v1.delete_namespaced_replica_set(r.metadata.name, ns, body=body)
示例2: delete_pods
# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import debug [as 別名]
def delete_pods(name: str, ns: str = "default",
label_selector: str = "name in ({name})",
secrets: Secrets = None):
"""
Delete pods by `name` in the namespace `ns`.
The pods are deleted without a graceful period to trigger an abrupt
termination.
The selected resources are matched by the given `label_selector`.
"""
label_selector = label_selector.format(name=name)
api = create_k8s_api_client(secrets)
v1 = client.CoreV1Api(api)
if label_selector:
ret = v1.list_namespaced_pod(ns, label_selector=label_selector)
else:
ret = v1.list_namespaced_pod(ns)
logger.debug("Found {d} pods named '{n}'".format(
d=len(ret.items), n=name))
body = client.V1DeleteOptions()
for p in ret.items:
v1.delete_namespaced_pod(p.metadata.name, ns, body=body)
示例3: service_is_initialized
# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import debug [as 別名]
def service_is_initialized(name: str, ns: str = "default",
label_selector: str = "name in ({name})",
secrets: Secrets = None):
"""
Lookup a service endpoint by its name and raises :exc:`FailedProbe` when
the service was not found or not initialized.
"""
label_selector = label_selector.format(name=name)
api = create_k8s_api_client(secrets)
v1 = client.CoreV1Api(api)
if label_selector:
ret = v1.list_namespaced_service(ns, label_selector=label_selector)
else:
ret = v1.list_namespaced_service(ns)
logger.debug("Found {d} service(s) named '{n}' ins ns '{s}'".format(
d=len(ret.items), n=name, s=ns))
if not ret.items:
raise ActivityFailed(
"service '{name}' is not initialized".format(name=name))
return True
示例4: _drain_queue
# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import debug [as 別名]
def _drain_queue(self):
"""
Logic:
- send message to server when server is alive
- update local db
"""
while True:
message = await self._queue.get()
if message is None:
logger.info("Resent messages: %s", self._db)
for _, v in self._db.items():
await self._ws.write_message(v)
continue
if 'udid' in message: # ping消息不包含在裡麵
udid = message['udid']
update_recursive(self._db, {udid: message})
self._queue.task_done()
if self._ws:
try:
await self._ws.write_message(message)
logger.debug("websocket send: %s", message)
except TypeError as e:
logger.info("websocket write_message error: %s", e)
示例5: _push_stf
# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import debug [as 別名]
def _push_stf(self,
path: str,
dest: str,
zipfile_path: str,
mode=0o755):
""" push minicap and minitouch from zip """
with zipfile.ZipFile(zipfile_path) as z:
if path not in z.namelist():
logger.warning("stf stuff %s not found", path)
return
src_info = z.getinfo(path)
dest_info = self._device.sync.stat(dest)
if dest_info.size == src_info.file_size and dest_info.mode & mode == mode:
logger.debug("%s already pushed %s", self, path)
return
with z.open(path) as f:
self._device.sync.push(f, dest, mode)
示例6: mirror_download
# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import debug [as 別名]
def mirror_download(url: str, target: str) -> str:
"""
Returns:
target path
"""
if os.path.exists(target):
return target
github_host = "https://github.com"
if url.startswith(github_host):
mirror_url = "http://tool.appetizer.io" + url[len(
github_host):] # mirror of github
try:
return download(mirror_url, target)
except (requests.RequestException, ValueError) as e:
logger.debug("download from mirror error, use origin source")
return download(url, target)
示例7: send_click
# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import debug [as 別名]
def send_click(self, x, y):
if self._click_before_delay:
self.logger.debug("click before delay %.1f seconds",
self._click_after_delay)
time.sleep(self._click_before_delay)
# TODO(ssx): should use a better way
# event callbacks for report generate
for callback_func in self._event_callbacks['send_click']:
callback_func(x, y)
self._d.click(x, y)
if self._click_after_delay:
self.logger.debug("click after delay %.1f seconds",
self._click_after_delay)
time.sleep(self._click_after_delay)
示例8: mirror_download
# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import debug [as 別名]
def mirror_download(url: str, filename=None, logger: logging.Logger = logger):
"""
Download from mirror, then fallback to origin url
"""
storepath = gen_cachepath(url)
if not filename:
filename = os.path.basename(url)
github_host = "https://github.com"
if url.startswith(github_host):
mirror_url = "https://tool.appetizer.io" + url[len(
github_host):] # mirror of github
try:
return cache_download(mirror_url,
filename,
timeout=60,
storepath=storepath,
logger=logger)
except (requests.RequestException, FileNotFoundError,
AssertionError) as e:
logger.debug("download error from mirror(%s), use origin source", e)
return cache_download(url, filename, storepath=storepath, logger=logger)
示例9: push_url
# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import debug [as 別名]
def push_url(self, url, dest=None, mode=0o755, tgz=False, extract_name=None): # yapf: disable
path = mirror_download(url,
filename=os.path.basename(url),
logger=self.logger)
if tgz:
tar = tarfile.open(path, 'r:gz')
path = os.path.join(os.path.dirname(path), extract_name)
tar.extract(extract_name,
os.path.dirname(path)) # zlib.error may raise
if not dest:
dest = "/data/local/tmp/" + os.path.basename(path)
self.logger.debug("Push to %s:0%o", dest, mode)
self._device.sync.push(path, dest, mode=mode)
return dest
示例10: is_atx_agent_outdated
# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import debug [as 別名]
def is_atx_agent_outdated(self):
"""
Returns:
bool
"""
agent_version = self._device.shell(self.atx_agent_path +
" version").strip()
if agent_version == "dev":
self.logger.info("skip version check for atx-agent dev")
return False
# semver major.minor.patch
try:
real_ver = list(map(int, agent_version.split(".")))
want_ver = list(map(int, __atx_agent_version__.split(".")))
except ValueError:
return True
self.logger.debug("Real version: %s, Expect version: %s", real_ver,
want_ver)
if real_ver[:2] != want_ver[:2]:
return True
return real_ver[2] < want_ver[2]
示例11: validate
# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import debug [as 別名]
def validate(ctx: click.Context, source: str,
no_verify_tls: bool = False) -> Experiment:
"""Validate the experiment at SOURCE."""
settings = load_settings(ctx.obj["settings_path"])
try:
experiment = load_experiment(
source, settings, verify_tls=not no_verify_tls)
except InvalidSource as x:
logger.error(str(x))
logger.debug(x)
ctx.exit(1)
try:
notify(settings, ValidateFlowEvent.ValidateStarted, experiment)
ensure_experiment_is_valid(experiment)
notify(settings, ValidateFlowEvent.ValidateCompleted, experiment)
logger.info("experiment syntax and semantic look valid")
except ChaosException as x:
notify(settings, ValidateFlowEvent.ValidateFailed, experiment, x)
logger.error(str(x))
logger.debug(x)
ctx.exit(1)
return experiment
示例12: discover
# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import debug [as 別名]
def discover(ctx: click.Context, package: str,
discovery_path: str = "./discovery.json",
no_system_info: bool = False,
no_install: bool = False) -> Discovery:
"""Discover capabilities and experiments."""
settings = load_settings(ctx.obj["settings_path"])
try:
notify(settings, DiscoverFlowEvent.DiscoverStarted, package)
discovery = disco(
package_name=package, discover_system=not no_system_info,
download_and_install=not no_install)
except DiscoveryFailed as err:
notify(settings, DiscoverFlowEvent.DiscoverFailed, package, err)
logger.debug("Failed to discover {}".format(package), exc_info=err)
logger.fatal(str(err))
return
with open(discovery_path, "w") as d:
d.write(json.dumps(discovery, indent=2, default=encoder))
logger.info("Discovery outcome saved in {p}".format(
p=discovery_path))
notify(settings, DiscoverFlowEvent.DiscoverCompleted, discovery)
return discovery
示例13: device_watch
# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import debug [as 別名]
def device_watch(wda_directory: str):
"""
When iOS device plugin, launch WDA
"""
lock = locks.Lock() # WDA launch one by one
async for event in idb.track_devices():
if event.udid.startswith("ffffffffffffffffff"):
logger.debug("Invalid event: %s", event)
continue
logger.debug("Event: %s", event)
if event.present:
d = idb.WDADevice(event.udid, lock=lock, callback=_device_callback)
d.wda_directory = wda_directory
idevices[event.udid] = d
d.start()
else: # offline
await idevices[event.udid].stop()
idevices.pop(event.udid)
示例14: wda_status
# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import debug [as 別名]
def wda_status(self):
"""
Returns:
dict or None
"""
try:
request = httpclient.HTTPRequest(self.wda_device_url + "/status",
connect_timeout=3,
request_timeout=15)
client = httpclient.AsyncHTTPClient()
resp = await client.fetch(request)
info = json.loads(resp.body)
self.__wda_info = info
return info
except httpclient.HTTPError as e:
logger.debug("%s request wda/status error: %s", self, e)
return None
except (ConnectionResetError, ConnectionRefusedError):
logger.debug("%s waiting for wda", self)
return None
except Exception as e:
logger.warning("%s ping wda unknown error: %s %s", self, type(e),
e)
return None
示例15: deregister_target
# 需要導入模塊: from logzero import logger [as 別名]
# 或者: from logzero.logger import debug [as 別名]
def deregister_target(tg_name: str,
configuration: Configuration = None,
secrets: Secrets = None) -> AWSResponse:
"""Deregisters one random target from target group"""
client = aws_client('elbv2', configuration, secrets)
tg_arn = get_target_group_arns(tg_names=[tg_name], client=client)
tg_health = get_targets_health_description(tg_arns=tg_arn, client=client)
random_target = random.choice(
tg_health[tg_name]['TargetHealthDescriptions'])
logger.debug("Deregistering target {} from target group {}".format(
random_target['Target']['Id'], tg_name))
try:
return client.deregister_targets(
TargetGroupArn=tg_arn[tg_name],
Targets=[{
'Id': random_target['Target']['Id'],
'Port': random_target['Target']['Port']
}]
)
except ClientError as e:
raise FailedActivity('Exception detaching %s: %s' % (
tg_name, e.response['Error']['Message']))