Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
#17: change from relative to absolute import to be able to debug appl…
Browse files Browse the repository at this point in the history
…ication.
  • Loading branch information
derrix060 committed Sep 19, 2018
1 parent 2eb40f0 commit 7bedac8
Show file tree
Hide file tree
Showing 22 changed files with 88 additions and 72 deletions.
2 changes: 1 addition & 1 deletion onedrived/od_api_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import onedrivesdk.error
import requests

from . import od_dateutils
from onedrived import od_dateutils

THROTTLE_PAUSE_SEC = 60

Expand Down
4 changes: 2 additions & 2 deletions onedrived/od_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import os
import yaml

from . import od_api_session
from .od_models import account_profile
from onedrived import od_api_session
from onedrived.od_models import account_profile

PATH = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
with open(os.path.join(PATH, 'onedrived', 'data', 'security_config.yml')) as config:
Expand Down
6 changes: 3 additions & 3 deletions onedrived/od_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import click


from . import mkdir, get_resource, od_webhooks
from .od_models import account_profile
from .od_models import drive_config as _drive_config
from onedrived import mkdir, get_resource, od_webhooks
from onedrived.od_models import account_profile
from onedrived.od_models import drive_config as _drive_config


def is_invalid_username(s):
Expand Down
2 changes: 1 addition & 1 deletion onedrived/od_i18n.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json

from . import get_resource
from onedrived import get_resource


class Translator:
Expand Down
16 changes: 8 additions & 8 deletions onedrived/od_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
import click
import daemonocle.cli

from . import od_repo
from . import od_task
from . import od_threads
from . import od_webhook
from .od_tasks import start_repo, merge_dir, update_subscriptions
from .od_auth import get_authenticator_and_drives
from .od_context import load_context
from .od_watcher import LocalRepositoryWatcher
from onedrived import od_repo
from onedrived import od_task
from onedrived import od_threads
from onedrived import od_webhook
from onedrived.od_tasks import start_repo, merge_dir, update_subscriptions
from onedrived.od_auth import get_authenticator_and_drives
from onedrived.od_context import load_context
from onedrived.od_watcher import LocalRepositoryWatcher


context = load_context(asyncio.get_event_loop())
Expand Down
2 changes: 1 addition & 1 deletion onedrived/od_models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from . import (
from onedrived.od_models import (
account_profile,
bidict,
drive_config,
Expand Down
2 changes: 1 addition & 1 deletion onedrived/od_models/dict_guard/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

from . import exceptions
from onedrived.od_models.dict_guard import exceptions


class DictEntryTypes:
Expand Down
2 changes: 1 addition & 1 deletion onedrived/od_models/webhook_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
:license: MIT
"""

from .. import od_dateutils
from onedrived import od_dateutils


class WebhookNotification:
Expand Down
14 changes: 7 additions & 7 deletions onedrived/od_pref.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
import keyring
import tabulate

from . import __version__
from . import mkdir, get_resource, od_i18n, od_auth
from .od_models import pretty_api, drive_config, account_profile
from .od_api_session import OneDriveAPISession, get_keyring_key
from .od_models.dict_guard import GuardedDict, exceptions as guard_errors
from .od_context import load_context, save_context
from .od_repo import get_drive_db_path
from onedrived import __version__
from onedrived import mkdir, get_resource, od_i18n, od_auth
from onedrived.od_models import pretty_api, drive_config, account_profile
from onedrived.od_api_session import OneDriveAPISession, get_keyring_key
from onedrived.od_models.dict_guard import GuardedDict, exceptions as guard_errors
from onedrived.od_context import load_context, save_context
from onedrived.od_repo import get_drive_db_path


context = load_context()
Expand Down
8 changes: 4 additions & 4 deletions onedrived/od_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
from contextlib import closing


from . import get_resource as _get_resource
from .od_models.path_filter import PathFilter as _PathFilter
from .od_api_helper import get_item_modified_datetime, get_item_created_datetime
from .od_dateutils import str_to_datetime, datetime_to_str
from onedrived import get_resource as _get_resource
from onedrived.od_models.path_filter import PathFilter as _PathFilter
from onedrived.od_api_helper import get_item_modified_datetime, get_item_created_datetime
from onedrived.od_dateutils import str_to_datetime, datetime_to_str


class ItemRecord:
Expand Down
4 changes: 2 additions & 2 deletions onedrived/od_tasks/delete_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import onedrivesdk.error

from . import update_item_base
from .. import od_api_helper
from onedrived.od_tasks import update_item_base
from onedrived import od_api_helper


class DeleteRemoteItemTask(update_item_base.UpdateItemTaskBase):
Expand Down
12 changes: 6 additions & 6 deletions onedrived/od_tasks/download_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

import onedrivesdk.error

from . import base
from .. import fix_owner_and_timestamp
from ..od_api_helper import get_item_modified_datetime
from ..od_api_helper import item_request_call
from ..od_dateutils import datetime_to_timestamp
from ..od_hashutils import sha1_value
from onedrived.od_tasks import base
from onedrived import fix_owner_and_timestamp
from onedrived.od_api_helper import get_item_modified_datetime
from onedrived.od_api_helper import item_request_call
from onedrived.od_dateutils import datetime_to_timestamp
from onedrived.od_hashutils import sha1_value


class DownloadFileTask(base.TaskBase):
Expand Down
16 changes: 9 additions & 7 deletions onedrived/od_tasks/merge_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
from onedrivesdk import Item, Folder, ChildrenCollectionRequest
from send2trash import send2trash

from . import base
from . import delete_item, download_file, upload_file
from .. import mkdir, fix_owner_and_timestamp
from ..od_api_helper import get_item_modified_datetime, item_request_call
from ..od_dateutils import datetime_to_timestamp, diff_timestamps
from ..od_hashutils import hash_match, sha1_value
from ..od_repo import ItemRecordType
from onedrived.od_tasks import base, delete_item, download_file, upload_file
from onedrived import mkdir, fix_owner_and_timestamp
from onedrived.od_api_helper import (
get_item_modified_datetime,
item_request_call,
)
from onedrived.od_dateutils import datetime_to_timestamp, diff_timestamps
from onedrived.od_hashutils import hash_match, sha1_value
from onedrived.od_repo import ItemRecordType


def rename_with_suffix(parent_abspath, name, host_name):
Expand Down
4 changes: 2 additions & 2 deletions onedrived/od_tasks/move_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import onedrivesdk.error
from onedrivesdk import Item, ItemReference

from . import update_mtime
from ..od_api_helper import item_request_call
from onedrived.od_tasks import update_mtime
from onedrived.od_api_helper import item_request_call


class MoveItemTask(update_mtime.UpdateTimestampTask):
Expand Down
6 changes: 4 additions & 2 deletions onedrived/od_tasks/start_repo.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import logging
import os

from . import base
from . import merge_dir
from onedrived.od_tasks import (
base,
merge_dir,
)


class StartRepositoryTask(base.TaskBase):
Expand Down
2 changes: 1 addition & 1 deletion onedrived/od_tasks/update_item_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from . import base
from onedrived.od_tasks import base


class UpdateItemTaskBase(base.TaskBase):
Expand Down
12 changes: 7 additions & 5 deletions onedrived/od_tasks/update_mtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import onedrivesdk.error
from onedrivesdk import Item, FileSystemInfo

from . import update_item_base
from .. import fix_owner_and_timestamp
from ..od_api_helper import get_item_modified_datetime
from ..od_api_helper import item_request_call
from ..od_dateutils import datetime_to_timestamp
from onedrived.od_tasks import update_item_base
from onedrived import fix_owner_and_timestamp
from onedrived.od_api_helper import (
get_item_modified_datetime,
item_request_call,
)
from onedrived.od_dateutils import datetime_to_timestamp


class UpdateTimestampTask(update_item_base.UpdateItemTaskBase):
Expand Down
6 changes: 3 additions & 3 deletions onedrived/od_tasks/update_subscriptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import onedrivesdk
import onedrivesdk.error

from .base import TaskBase
from .. import od_api_helper
from onedrived.od_tasks import base
from onedrived import od_api_helper


class UpdateSubscriptionTask(TaskBase):
class UpdateSubscriptionTask(base.TaskBase):

def __init__(self, repo, task_pool, webhook_worker, subscription_id=None):
"""
Expand Down
4 changes: 2 additions & 2 deletions onedrived/od_tasks/upload_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import onedrivesdk
import onedrivesdk.error

from . import update_mtime
from ..od_api_helper import item_request_call
from onedrived.od_tasks import update_mtime
from onedrived.od_api_helper import item_request_call


class UploadFileTask(update_mtime.UpdateTimestampTask):
Expand Down
28 changes: 19 additions & 9 deletions onedrived/od_watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,25 @@
import threading

import onedrivesdk.error
from inotify_simple import flags as _inotify_flags, masks as _inotify_masks, INotify as _INotify

from .od_tasks import delete_item, move_item, merge_dir, update_mtime, upload_file
from .od_models.path_filter import PathFilter
from .od_models.bidict import loosebidict
from .od_api_helper import item_request_call
from .od_hashutils import hash_match
from .od_repo import ItemRecordType
from .od_stringutils import get_filename_with_incremented_count
from inotify_simple import (
flags as _inotify_flags,
masks as _inotify_masks,
INotify as _INotify,
)

from onedrived.od_tasks import (
delete_item,
move_item,
merge_dir,
update_mtime,
upload_file,
)
from onedrived.od_models.path_filter import PathFilter
from onedrived.od_models.bidict import loosebidict
from onedrived.od_api_helper import item_request_call
from onedrived.od_hashutils import hash_match
from onedrived.od_repo import ItemRecordType
from onedrived.od_stringutils import get_filename_with_incremented_count


class ParentTaskExistsException(Exception):
Expand Down
6 changes: 3 additions & 3 deletions onedrived/od_webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import queue
import urllib.parse

from .od_models.webhook_notification import WebhookNotification
from onedrived.od_models.webhook_notification import WebhookNotification

try:
JSONDecodeError = json.JSONDecodeError
Expand All @@ -20,10 +20,10 @@ def get_webhook_server(context):
:param onedrived.od_context.UserContext context:
"""
if context.config['webhook_type'] == 'direct':
from .od_webhooks.http_server import WebhookConfig, WebhookListener
from onedrived.od_webhooks.http_server import WebhookConfig, WebhookListener
wh_config = WebhookConfig(host=context.config['webhook_host'], port=context.config['webhook_port'])
elif context.config['webhook_type'] == 'ngrok':
from .od_webhooks.ngrok_server import WebhookConfig, WebhookListener
from onedrived.od_webhooks.ngrok_server import WebhookConfig, WebhookListener
ngrok_config_file = context.config_dir + '/' + context.DEFAULT_NGROK_CONF_FILENAME
if not os.path.isfile(ngrok_config_file):
ngrok_config_file = None
Expand Down
2 changes: 1 addition & 1 deletion onedrived/od_webhooks/ngrok_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import psutil
import requests

from . import http_server
from onedrived.od_webhooks import http_server


class WebhookConfig(http_server.WebhookConfig):
Expand Down

0 comments on commit 7bedac8

Please sign in to comment.