def __init__(self): ''' Initialize the backup task. >>> backup_task = BackupTask() >>> backup_task is not None True >>> backup_task.__init__() >>> type(backup_task.locale_tz) <class 'zoneinfo.ZoneInfo.Atlantic/Reykjavik'> >>> backup_task._interrupted False >>> backup_task.manager is None True >>> backup_task.log_name 'blockchain_backup.bitcoin.backup.log' ''' Thread.__init__(self) self._interrupted = False self.log = Log() self.log_name = os.path.basename(get_log_path()) self.manager = None self.to_backup_dir = None self.backup_formatted_time = None self.locale_tz = ZoneInfo(TIME_ZONE)
def __init__(self, restore_dir): ''' Initialize the restore task. >>> restore_task = RestoreTask(os.path.join(gettempdir(), 'bitcoin/data/testnet3/backups/level1')) >>> restore_task is not None True >>> restore_task.__init__(os.path.join(gettempdir(), 'bitcoin/data/testnet3/backups/level1')) >>> restore_task.restore_dir '/tmp/bitcoin/data/testnet3/backups/level1' >>> restore_task._interrupted False >>> restore_task.manager is None True >>> restore_task.log_name 'blockchain_backup.bitcoin.restore.log' ''' Thread.__init__(self) self.restore_dir = restore_dir self._interrupted = False self.log = Log() self.log_name = os.path.basename(get_log_path()) self.manager = None
def _init_log(): ''' Initialize log. ''' global log if log is None: # log import delayed to avoid recursive import. from denova.python.log import Log log = Log()
def __init__(self, *args, **kwargs): ''' Initialize the preferences form. >>> prefs = PreferencesForm() >>> prefs is not None True >>> prefs.log is not None True ''' super(PreferencesForm, self).__init__(*args, **kwargs) self.log = Log()
''' from traceback import format_exc from urllib.parse import urlsplit, urlunsplit try: from django import http from django.conf import settings from django.utils.deprecation import MiddlewareMixin except ModuleNotFoundError: import sys sys.exit('Django required') from denova.python.log import Log log = Log() class Redirect404Middleware(MiddlewareMixin): def process_response(self, request, response): try: if response.status_code == 404: log('got 404') url = request.get_full_path() parts = urlsplit(url) if parts.scheme == '': if request.is_secure(): scheme = 'https'
def log(message): global _log if not _log: from denova.python.log import Log _log = Log() _log(message)
def __init__(self): self.log = Log()
Portions Copyright 2011-2020 DeNova Last modified: 2020-10-10 This file is open source, licensed under GPLv3 <http://www.gnu.org/licenses/>. ''' import os.path import builtins from itertools import takewhile from tempfile import gettempdir from denova.python.log import Log # log in non-standard dir because of concurrency issues log = Log(os.path.join(gettempdir(), 'iter.log')) def is_iterable(item): ''' Return True iff item is iterable. >>> print(is_iterable(3)) False ''' try: list(item) except TypeError: result = False else: result = True