mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
strike one Account parameter, always do eventlogging
This commit is contained in:
@@ -26,14 +26,13 @@ class Account(object):
|
|||||||
by the underlying deltachat core library. All public Account methods are
|
by the underlying deltachat core library. All public Account methods are
|
||||||
meant to be memory-safe and return memory-safe objects.
|
meant to be memory-safe and return memory-safe objects.
|
||||||
"""
|
"""
|
||||||
def __init__(self, db_path, logid=None, eventlogging=True, os_name=None, debug=True):
|
def __init__(self, db_path, logid=None, os_name=None, debug=True):
|
||||||
""" initialize account object.
|
""" initialize account object.
|
||||||
|
|
||||||
:param db_path: a path to the account database. The database
|
:param db_path: a path to the account database. The database
|
||||||
will be created if it doesn't exist.
|
will be created if it doesn't exist.
|
||||||
:param logid: an optional logging prefix that should be used with
|
:param logid: an optional logging prefix that should be used with
|
||||||
the default internal logging.
|
the default internal logging.
|
||||||
:param eventlogging: if False no eventlogging and no context callback will be configured
|
|
||||||
:param os_name: this will be put to the X-Mailer header in outgoing messages
|
:param os_name: this will be put to the X-Mailer header in outgoing messages
|
||||||
:param debug: turn on debug logging for events.
|
:param debug: turn on debug logging for events.
|
||||||
"""
|
"""
|
||||||
@@ -41,12 +40,9 @@ class Account(object):
|
|||||||
lib.dc_context_new(lib.py_dc_callback, ffi.NULL, as_dc_charpointer(os_name)),
|
lib.dc_context_new(lib.py_dc_callback, ffi.NULL, as_dc_charpointer(os_name)),
|
||||||
_destroy_dc_context,
|
_destroy_dc_context,
|
||||||
)
|
)
|
||||||
if eventlogging:
|
self._evlogger = EventLogger(self._dc_context, logid, debug)
|
||||||
self._evlogger = EventLogger(self._dc_context, logid, debug)
|
deltachat.set_context_callback(self._dc_context, self._process_event)
|
||||||
deltachat.set_context_callback(self._dc_context, self._process_event)
|
self._threads = IOThreads(self._dc_context, self._evlogger._log_event)
|
||||||
self._threads = IOThreads(self._dc_context, self._evlogger._log_event)
|
|
||||||
else:
|
|
||||||
self._threads = IOThreads(self._dc_context)
|
|
||||||
|
|
||||||
if hasattr(db_path, "encode"):
|
if hasattr(db_path, "encode"):
|
||||||
db_path = db_path.encode("utf8")
|
db_path = db_path.encode("utf8")
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import py
|
import py
|
||||||
import pytest
|
import pytest
|
||||||
import requests
|
import requests
|
||||||
@@ -7,6 +8,7 @@ import time
|
|||||||
from deltachat import Account
|
from deltachat import Account
|
||||||
from deltachat import const
|
from deltachat import const
|
||||||
from deltachat.capi import lib
|
from deltachat.capi import lib
|
||||||
|
from _pytest.monkeypatch import MonkeyPatch
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
|
||||||
@@ -43,11 +45,14 @@ def pytest_report_header(config, startdir):
|
|||||||
summary = []
|
summary = []
|
||||||
|
|
||||||
t = tempfile.mktemp()
|
t = tempfile.mktemp()
|
||||||
|
m = MonkeyPatch()
|
||||||
try:
|
try:
|
||||||
ac = Account(t, eventlogging=False)
|
m.setattr(sys.stdout, "write", lambda x: len(x))
|
||||||
|
ac = Account(t)
|
||||||
info = ac.get_info()
|
info = ac.get_info()
|
||||||
ac.shutdown()
|
ac.shutdown()
|
||||||
finally:
|
finally:
|
||||||
|
m.undo()
|
||||||
os.remove(t)
|
os.remove(t)
|
||||||
summary.extend(['Deltachat core={} sqlite={}'.format(
|
summary.extend(['Deltachat core={} sqlite={}'.format(
|
||||||
info['deltachat_core_version'],
|
info['deltachat_core_version'],
|
||||||
|
|||||||
Reference in New Issue
Block a user