-
-
Save hpk42/2e45d4ae16e61ae14099631d7ba83e64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import shutil | |
from deltachat.account import as_dc_charpointer, from_dc_charpointer, Account | |
from deltachat.capi import lib | |
from deltachat.capi import ffi | |
def remove_db_path(db_path): | |
try: | |
os.remove(db_path) | |
shutil.rmtree(db_path + "-blobs") | |
except FileNotFoundError: | |
pass | |
return db_path | |
def main(db_path): | |
remove_db_path(db_path) | |
print("new context with db-path:", db_path) | |
dc_context = ffi.gc( | |
lib.dc_context_new(lib.py_dc_callback, ffi.NULL, as_dc_charpointer("os")), | |
lib.dc_context_unref | |
) | |
if not lib.dc_open(dc_context, db_path.encode("utf8"), ffi.NULL): | |
raise ValueError("Could not dc_open: {}".format(db_path)) | |
def main2(db_path): | |
remove_db_path(db_path) | |
print("new Account with db-path:", db_path) | |
acc = Account(db_path) | |
return | |
print(acc.get_info()) | |
if __name__ == "__main__": | |
main("/tmp/dctmp123") | |
#main2("/tmp/dctmpxxx") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment