Exemple #1
0
 def __init__(self, db_path, personal_client=None, business_client=None):
     self._conn = sqlite3.connect(db_path, isolation_level=None)
     self._cursor = self._conn.cursor()
     self._cursor.execute(get_content("onedrive_accounts.sql"))
     self._conn.commit()
     self.personal_client = personal_client
     self.business_client = business_client
     self._all_accounts = {}
     atexit.register(self.close)
Exemple #2
0
 def __init__(self, db_path, account_store):
     """
     :param str db_path: Path to Drive database.
     :param onedrived.store.account_db.AccountStorage account_store:
     """
     self._conn = sqlite3.connect(db_path, isolation_level=None)
     self._cursor = self._conn.cursor()
     self._cursor.execute(get_content('onedrive_drives.sql'))
     self._conn.commit()
     self._all_drives = {}
     self._drive_roots = {}
     self.account_store = account_store
     atexit.register(self.close)
Exemple #3
0
 def __init__(self, db_path, account_store):
     """
     :param str db_path: Path to Drive database.
     :param onedrived.store.account_db.AccountStorage account_store:
     """
     self._conn = sqlite3.connect(db_path, isolation_level=None)
     self._cursor = self._conn.cursor()
     self._cursor.execute(get_content('onedrive_drives.sql'))
     self._conn.commit()
     self._all_drives = {}
     self._drive_roots = {}
     self.account_store = account_store
     atexit.register(self.close)
Exemple #4
0
 def __init__(self, db_path, drive):
     """
     :param str db_path: A unique path for the database to store items for the target drive.
     :param onedrived.api.drives.DriveObject drive: The underlying drive object.
     """
     if not hasattr(drive, 'storage_lock'):
         drive.storage_lock = ReadWriteLock()
     self.lock = drive.storage_lock
     self._conn = sqlite3.connect(db_path, isolation_level=None, check_same_thread=False)
     self.drive = drive
     self._cursor = self._conn.cursor()
     self._cursor.execute(get_content('onedrive_items.sql'))
     self._conn.commit()
     atexit.register(self.close)
Exemple #5
0
 def __init__(self, db_path, drive):
     """
     :param str db_path: A unique path for the database to store items for the target drive.
     :param onedrived.api.drives.DriveObject drive: The underlying drive object.
     """
     if not hasattr(drive, 'storage_lock'):
         drive.storage_lock = ReadWriteLock()
     self.lock = drive.storage_lock
     self._conn = sqlite3.connect(db_path,
                                  isolation_level=None,
                                  check_same_thread=False)
     self.drive = drive
     self._cursor = self._conn.cursor()
     self._cursor.execute(get_content('onedrive_items.sql'))
     self._conn.commit()
     atexit.register(self.close)
Exemple #6
0
import os
import sys

from clint.textui import colored, columns, indent, prompt, puts, validators

from onedrived import OS_USER_NAME, OS_USER_HOME, mkdir, get_content
from onedrived.api import accounts, clients
from onedrived.cli import CONFIG_DIR, get_current_user_config
from onedrived.common import drive_config, netman
from onedrived.store import account_db, drives_db
from onedrived.vendor.utils import pretty_print_bytes

try:
    if not os.path.exists(CONFIG_DIR):
        mkdir(CONFIG_DIR)
        default_ignore_list_data = get_content("default_ignore_list.txt", is_text=True)
        with open(CONFIG_DIR + "/odignore.txt", "w") as f:
            f.write(default_ignore_list_data)
        print(colored.green('Created path "' + CONFIG_DIR + '".'))
    user_conf = get_current_user_config()
    network_monitor = netman.NetworkMonitor()
    personal_client = clients.PersonalClient(proxies=user_conf.proxies, net_monitor=network_monitor)
    business_client = None
    account_store = account_db.AccountStorage(
        CONFIG_DIR + "/accounts.db", personal_client=personal_client, business_client=business_client
    )
    drive_store = drives_db.DriveStorage(CONFIG_DIR + "/drives.db", account_store)
except Exception as e:
    print(colored.red("Fatal error: " + str(e)))
    sys.exit(1)
Exemple #7
0
import os
import sys

from clint.textui import colored, columns, indent, prompt, puts, validators

from onedrived import OS_USER_NAME, OS_USER_HOME, mkdir, get_content
from onedrived.api import accounts, clients
from onedrived.cli import CONFIG_DIR, get_current_user_config
from onedrived.common import drive_config, netman
from onedrived.store import account_db, drives_db
from onedrived.vendor.utils import pretty_print_bytes

try:
    if not os.path.exists(CONFIG_DIR):
        mkdir(CONFIG_DIR)
        default_ignore_list_data = get_content('default_ignore_list.txt', is_text=True)
        with open(CONFIG_DIR + '/odignore.txt', 'w') as f:
            f.write(default_ignore_list_data)
        print(colored.green('Created path "' + CONFIG_DIR + '".'))
    user_conf = get_current_user_config()
    network_monitor = netman.NetworkMonitor()
    personal_client = clients.PersonalClient(proxies=user_conf.proxies, net_monitor=network_monitor)
    business_client = None
    account_store = account_db.AccountStorage(
            CONFIG_DIR + '/accounts.db', personal_client=personal_client, business_client=business_client)
    drive_store = drives_db.DriveStorage(CONFIG_DIR + '/drives.db', account_store)
except Exception as e:
    print(colored.red('Fatal error: ' + str(e)))
    sys.exit(1)