return cls(cached_state)
else:
msg = f'{cache_file} is invalid: only {len(cached_state)} entries. Deleting it.'
- warnings.warn(msg)
logger.warning(msg)
+ warnings.warn(msg, stacklevel=2)
os.remove(cache_file)
logger.debug('No usable saved state found')
return None
except Exception as e:
logger.exception(e)
msg = "Can't see the cabin right now; presence detection impared."
- logger.warning(msg)
warnings.warn(msg)
+ logger.warning(msg, stacklevel=2)
self.dark_locations.add(Location.CABIN)
def update_from_cabin(self) -> None:
logger.exception(e)
msg = "Can't see the house right now; presence detection impared."
logger.warning(msg)
- warnings.warn(msg)
+ warnings.warn(msg, stacklevel=2)
self.dark_locations.add(Location.HOUSE)
def read_persisted_macs_file(
if len(self.dark_locations) > 0:
msg = f"Can't see {self.dark_locations} right now; answer confidence impacted"
logger.warning(msg)
- warnings.warn(msg)
+ warnings.warn(msg, stacklevel=2)
logger.debug(f'Looking for {name}...')
if name is Person.UNKNOWN:
logger.exception(e)
msg = f"Got a bad image or HTTP error from {url}; returning None."
logger.warning(msg)
- warnings.warn(msg)
+ warnings.warn(msg, stacklevel=2)
return None
except Exception as e:
logger.exception(e)
msg = "Failed to retrieve image via RTSP {stream}, returning None."
- warnings.warn(msg)
logger.warning(msg)
+ warnings.warn(msg, stacklevel=2)
return None
)
msg = "Failed to retieve image from both video server and direct RTSP stream"
logger.warning(msg)
- warnings.warn(msg)
+ warnings.warn(msg, stacklevel=2)
return RawJpgHsv(None, None, None)
exc[1] = sys.exc_info() # (type, value, traceback)
msg = f"Thunkify has thrown an exception (will be raised on thunk()):\n{traceback.format_exc()}"
logger.warning(msg)
- warnings.warn(msg)
finally:
wait_event.set()
return worker
msg = 'Unexpectedly could not find a worker, retrying...'
logger.warning(msg)
- warnings.warn(msg)
return None
if x == self.index:
msg = 'Unexpectedly could not find a worker, retrying...'
logger.warning(msg)
- warnings.warn(msg)
return None
msg += 'We\'re a backup and this may be caused by the original (or some '
msg += 'other backup) already finishing this work. Ignoring this.'
logger.warning(msg)
- warnings.warn(msg)
return None
# Kick off the work. Note that if this fails we let
if p is not None:
msg = f"{bundle}: Failed to wrap up \"done\" bundle, re-waiting on active ssh."
logger.warning(msg)
- warnings.warn(msg)
return self.wait_for_process(p, bundle, depth + 1)
else:
self.status.record_release_worker(
logger.exception(e)
msg = 'Unable to parse Google assistant\'s response.'
logger.warning(msg)
- warnings.warn(msg)
+ warnings.warn(msg, stacklevel=3)
audio_transcription = None
return GoogleResponse(
success=success,
pass
msg = f'Could not acquire {self.lockfile}.'
logger.warning(msg)
- warnings.warn(msg)
return False
def acquire_with_retries(
return self
msg = f"Couldn't acquire {self.lockfile}; giving up."
logger.warning(msg)
- warnings.warn(msg)
raise LockFileException(msg)
def __exit__(self, type, value, traceback):
except OSError:
msg = f'Lockfile {self.lockfile}\'s pid ({contents.pid}) is stale; force acquiring'
logger.warning(msg)
- warnings.warn(msg)
self.release()
# Has the lock expiration expired?
if now > contents.expiration_datetime:
msg = f'Lockfile {self.lockfile} expiration time has passed; force acquiring'
logger.warning(msg)
- warnings.warn(msg)
self.release()
except Exception:
pass
import random
import sys
from typing import Callable, Iterable, Mapping, Optional
-import warnings
from overrides import overrides
import pytz
if config.config['logging_clear_preexisting_handlers'] and preexisting_handlers_count > 0:
msg = 'Logging cleared {preexisting_handlers_count} global handlers (--logging_clear_preexisting_handlers)'
logger.warning(msg)
- warnings.warn(msg)
logger.debug(f'Logging format specification is "{fmt}"')
if config.config['logging_debug_threads']:
logger.debug('...Logging format spec captures tid/pid (--logging_debug_threads)')
if not self.instance:
msg = 'Loading from cache failed.'
logger.warning(msg)
- warnings.warn(msg)
+ warnings.warn(msg, stacklevel=2)
logger.debug(f'Attempting to instantiate {cls.__name__} directly.')
self.instance = cls(*args, **kwargs)
else:
import subprocess
import sys
from typing import Any, Dict, List, Optional, Tuple
-import warnings
from overrides import overrides
import tinytuya as tt
if signal != 0:
msg = f'{command} died with signal {signal}'
logger.warning(msg)
- warnings.warn(msg)
logging_utils.hlog(msg)
return False
else:
if exit_value != 0:
msg = f'{command} failed, exited {exit_value}'
logger.warning(msg)
- warnings.warn(msg)
logging_utils.hlog(msg)
return False
logger.debug(f'{command} succeeded.')
import subprocess
import sys
from typing import Any, Dict, List, Optional
-import warnings
from meross_iot.http_api import MerossHttpClient
from meross_iot.manager import MerossManager
if signal != 0:
msg = f'{command} died with signal {signal}'
logger.warning(msg)
- warnings.warn(msg)
logging_utils.hlog(msg)
return False
else:
if exit_value != 0:
msg = f'{command} failed, exited {exit_value}'
logger.warning(msg)
- warnings.warn(msg)
logging_utils.hlog(msg)
return False
logger.debug(f'{command} succeeded.')
import logging
import re
from typing import List, Optional, Set
-import warnings
import argparse_utils
import config
try:
(mac, name, keywords) = line.split(",")
except ValueError:
- msg = f'SH-CONFIG> {line} is malformed?!'
+ msg = f'SH-CONFIG> "{line}" is malformed?! Skipping it.'
logger.warning(msg)
- warnings.warn(msg)
continue
mac = mac.strip()
name = name.strip()
return device.Device(name, mac, kws)
msg = f'{mac} is not a known smart home device, returning None'
logger.warning(msg)
- warnings.warn(msg)
return None
def query(self, query: str) -> List[device.Device]:
except dp.ParseException:
msg = f'Unable to parse date {in_str}.'
logger.warning(msg)
- warnings.warn(msg)
return None
except dp.ParseException:
msg = f'Unable to parse date {in_str}.'
logger.warning(msg)
- warnings.warn(msg)
return False
except ValueError:
msg = f'Unable to parse datetime {in_str}.'
logger.warning(msg)
- warnings.warn(msg)
return None
return True
msg = f'Unable to parse datetime {in_str}.'
logger.warning(msg)
- warnings.warn(msg)
return False
if len(txt) % chunk_size != 0:
msg = f'String to chunk\'s length ({len(txt)} is not an even multiple of chunk_size ({chunk_size})'
logger.warning(msg)
- warnings.warn(msg)
+ warnings.warn(msg, stacklevel=2)
for x in range(0, len(txt), chunk_size):
yield txt[x:x+chunk_size]
import tempfile
from typing import Callable
import unittest
-import warnings
import bootstrap
import config
logger.exception(e)
msg = f'Unable to load perfdb from {_db}'
logger.warning(msg)
- warnings.warn(msg)
perfdb = {}
# This is a unique identifier for a test: filepath!function