Skip to content

Commit

Permalink
Rename onedriveClient binaries to onedrive-client(-pref)
Browse files Browse the repository at this point in the history
Folder's been renamed to onedrive_client due to python,
only binaries are called with a dash.
  • Loading branch information
modelmat committed Oct 30, 2018
1 parent e1a330c commit 63858f5
Show file tree
Hide file tree
Showing 69 changed files with 2,421 additions and 2,421 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ before_script:

script:
- MOCK_KEYRING=1 python3 -m pytest
- MOCK_KEYRING=1 coverage3 run --branch --source=onedrived setup.py test
- MOCK_KEYRING=1 coverage3 run --branch --source=onedrive_client setup.py test

after_success:
- coverage3 report -m
Expand Down
158 changes: 79 additions & 79 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion onedrived/__init__.py → onedrive_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def fix_owner_and_timestamp(path, uid, t):
os.utime(path, (t, t))


def get_resource(rel_path, pkg_name='onedrived', is_text=True):
def get_resource(rel_path, pkg_name='onedrive_client', is_text=True):
"""
Read a resource file in data/.
:param str rel_path:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Hard-coded rules:
# .*.odtemp! -- onedrived temp files.
# .*.odtemp! -- onedrive_client temp files.
# *[<>?*:"|]* -- NTFS namespace violation.
# .* -- NTFS namespace violation.

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"config.scan_interval_sec.desc": "Interval, in seconds, between two actions of scanning the entire repository.",
"config.num_workers.desc": "Total number of worker threads.",
"config.webhook_renew_interval_sec.desc": "Renew webhook after this amount of time, in seconds. Ideal value should be slightly larger than the lifespan of onedrived process.",
"config.webhook_renew_interval_sec.desc": "Renew webhook after this amount of time, in seconds. Ideal value should be slightly larger than the lifespan of onedrive_client process.",
"config.start_delay_sec.desc": "Amount of time, in seconds, to sleep before main starts working.",
"config.logfile_path.desc": "Path to log file. Empty string means writing to stdout.",
"config.webhook_type.desc": "Type of webhook. Use \"direct\" only if your machine can be reached from public network.",
Expand Down Expand Up @@ -30,23 +30,23 @@
"od_pref.set_config.short_help": "Update a config parameter.",
"od_pref.print_config.short_help": "Print all config parameters along with their descriptions and values.",

"od_pref.account.submain.short_help": "Add new OneDrive account to onedrived, list or remove existing ones.",
"od_pref.authenticate_account.short_help": "Add a new OneDrive account to onedrived.",
"od_pref.account.submain.short_help": "Add new OneDrive account to onedrive_client, list or remove existing ones.",
"od_pref.authenticate_account.short_help": "Add a new OneDrive account to onedrive_client.",
"od_pref.authenticate_account.get_auth_url.help": "If set, print the authentication URL and exit.",
"od_pref.authenticate_account.code.help": "Skip interactions and try authenticating with the code directly.",
"od_pref.authenticate_account.for_business.help": "If set, add an OneDrive for Business account.",
"od_pref.save_account.success": "Successfully added account for {profile.account_name} ({profile.account_email})!",
"od_pref.save_account.print_header": "All OneDrive accounts associated with user \"{context.user_name}\":",
"od_pref.save_account.error": "Failed to save account: {error_message}.",
"od_pref.authenticate_account.for_business_unsupported": "OneDrive for Business is not yet supported.",
"od_pref.authenticate_account.permission_note": "NOTE: To better manage your OneDrive accounts, onedrived needs permission to access your account info (e.g., email address to distinguish different accounts) and read/write your OneDrive files.\n",
"od_pref.authenticate_account.paste_url_note": "Paste this URL into your browser to sign in and authorize onedrived:",
"od_pref.authenticate_account.permission_note": "NOTE: To better manage your OneDrive accounts, onedrive_client needs permission to access your account info (e.g., email address to distinguish different accounts) and read/write your OneDrive files.\n",
"od_pref.authenticate_account.paste_url_note": "Paste this URL into your browser to sign in and authorize onedrive_client:",
"od_pref.authenticate_account.paste_url_instruction": "The authentication web page will finish with a blank page whose URL starts with \"{redirect_url}\". Paste this URL after the prompt.",
"od_pref.authenticate_account.second_authentication": "Need authenticate again to get personal information'",
"od_pref.authenticate_account.paste_url_prompt": "Paste URL here",
"od_pref.authenticate_account.error.code_not_found_in_url": "Error: did not find authorization code in URL.",
"od_pref.authenticate_account.success.authorized": "Successfully authorized onedrived.",
"od_pref.authenticate_account.error.authorization": "Failed to authorize onedrived: {error_message}.",
"od_pref.authenticate_account.success.authorized": "Successfully authorized onedrive_client.",
"od_pref.authenticate_account.error.authorization": "Failed to authorize onedrive_client: {error_message}.",

"od_pref.print_all_drives.fetching_drives.note": "Reading drives information from OneDrive server...",
"od_pref.print_all_drives.all_drives_table.note": "All available Drives of authorized accounts:",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def get_drive_request_builder(repo):
def create_subscription(folder_item_request, repo, webhook_url, expiration_time):
"""
:param onedrivesdk.ItemRequestBuilder folder_item_request:
:param onedrived.od_repo.OneDriveLocalRepository repo:
:param onedrive_client.od_repo.OneDriveLocalRepository repo:
:param str webhook_url:
:param datetime.datetime.datetime expiration_time:
:return onedrivesdk.Subscription:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def get_keyring_key(account_id):
class OneDriveAPISession(onedrivesdk.session.Session):

SESSION_ARG_KEYNAME = 'key'
KEYRING_SERVICE_NAME = 'onedrived_v2'
KEYRING_SERVICE_NAME = 'onedrive_client_v2'
KEYRING_ACCOUNT_KEY_PREFIX = 'user.'
PICKLE_PROTOCOL = 3

Expand All @@ -32,7 +32,7 @@ def save_session(self, **save_session_kwargs):
def load_session(**load_session_kwargs):
"""
:param dict[str, str] load_session_kwargs:
:return onedrived.od_api_session.OneDriveAPISession:
:return onedrive_client.od_api_session.OneDriveAPISession:
"""
keyarg = OneDriveAPISession.SESSION_ARG_KEYNAME
if keyarg not in load_session_kwargs:
Expand Down
2 changes: 1 addition & 1 deletion onedrived/od_auth.py → onedrive_client/od_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from .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:
with open(os.path.join(PATH, 'onedrive_client', 'data', 'security_config.yml')) as config:
SECURITY_CONFIG = yaml.safe_load(config)


Expand Down
6 changes: 3 additions & 3 deletions onedrived/od_context.py → onedrive_client/od_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class UserContext:
'logfile_path': ''
}

DEFAULT_CONFIG_FILENAME = 'onedrived_config_v2.json'
DEFAULT_CONFIG_FILENAME = 'onedrive_client_config_v2.json'
DEFAULT_IGNORE_FILENAME = 'ignore_v2.txt'
DEFAULT_NGROK_CONF_FILENAME = 'ngrok_conf.yaml'

Expand All @@ -71,7 +71,7 @@ def __init__(self, loop):
self.user_name = get_login_username()
self.user_uid = getpwnam(self.user_name).pw_uid
self.user_home = os.path.expanduser('~' + self.user_name)
self.config_dir = click.get_app_dir('onedrived')
self.config_dir = click.get_app_dir('onedrive_client')
self._create_config_dir_if_missing()
self.config = self.DEFAULT_CONFIG
self.loop = loop
Expand Down Expand Up @@ -106,7 +106,7 @@ def loop(self, v):
@property
def watcher(self):
"""
:return onedrived.od_watcher.LocalRepositoryWatcher:
:return onedrive_client.od_watcher.LocalRepositoryWatcher:
"""
return self._watcher

Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions onedrived/od_i18n.py → onedrive_client/od_i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ def __init__(self, lang_resources, locale_str='en_US'):
self.string_resources = dict()
for lang in lang_resources:
try:
t = get_resource('lang/%s.%s.json' % (lang, locale_str), pkg_name='onedrived')
t = get_resource('lang/%s.%s.json' % (lang, locale_str), pkg_name='onedrive_client')
except FileNotFoundError:
t = get_resource('lang/%s.%s.json' % (lang, self.DEFAULT_LOCALE), pkg_name='onedrived')
t = get_resource('lang/%s.%s.json' % (lang, self.DEFAULT_LOCALE), pkg_name='onedrive_client')
data = json.loads(t)
self.string_resources.update(data)

Expand Down
18 changes: 9 additions & 9 deletions onedrived/od_main.py → onedrive_client/od_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


context = load_context(asyncio.get_event_loop())
pidfile = context.config_dir + '/onedrived.pid'
pidfile = context.config_dir + '/onedrive_client.pid'
task_workers = weakref.WeakSet()
task_pool = None
webhook_server = None
Expand Down Expand Up @@ -89,13 +89,13 @@ def shutdown_callback(code, _):

def get_repo_table(ctx):
"""
:param onedrived.od_context.UserContext ctx:
:return dict[str, [onedrived.od_repo.OneDriveLocalRepository]]:
:param onedrive_client.od_context.UserContext ctx:
:return dict[str, [onedrive_client.od_repo.OneDriveLocalRepository]]:
"""
all_accounts = {}
all_account_ids = ctx.all_accounts()
if len(all_account_ids) == 0:
logging.critical('onedrived is not linked with any OneDrive account. Please configure onedrived first.')
logging.critical('onedrive_client is not linked with any OneDrive account. Please configure onedrive_client first.')
sys.exit(1)
for account_id in all_account_ids:
authenticator, drives = get_authenticator_and_drives(ctx, account_id)
Expand All @@ -111,7 +111,7 @@ def get_repo_table(ctx):

def update_subscription_for_repo(repo, subscription_id=None):
"""
:param onedrived.od_repo.OneDriveLocalRepository repo:
:param onedrive_client.od_repo.OneDriveLocalRepository repo:
:param str | None subscription_id:
:return onedrivesdk.Subscription | None:
"""
Expand All @@ -128,7 +128,7 @@ def update_subscription_for_repo(repo, subscription_id=None):

def gen_start_repo_tasks(all_accounts):
"""
:param dict[str, [onedrived.od_repo.OneDriveLocalRepository]] all_accounts:
:param dict[str, [onedrive_client.od_repo.OneDriveLocalRepository]] all_accounts:
"""
if task_pool.outstanding_task_count == 0:
for repo in itertools.chain.from_iterable(all_accounts.values()):
Expand All @@ -145,11 +145,11 @@ def gen_start_repo_tasks(all_accounts):

def delete_temp_files(all_accounts):
"""
Delete all onedrived temporary files from repository.
:param dict[str, [onedrived.od_repo.OneDriveLocalRepository]] all_accounts:
Delete all onedrive_client temporary files from repository.
:param dict[str, [onedrive_client.od_repo.OneDriveLocalRepository]] all_accounts:
:return:
"""
logging.info('Sweeping onedrived temporary files from local repositories.')
logging.info('Sweeping onedrive_client temporary files from local repositories.')
for repo in itertools.chain.from_iterable(all_accounts.values()):
if os.path.isdir(repo.local_root):
subprocess.call(('find', repo.local_root, '-type', 'f',
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions onedrived/od_pref.py → onedrive_client/od_pref.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

context = load_context()
translator = od_i18n.Translator(('od_pref', ), locale_str=str(locale.getlocale()[0]))
config_schema = json.loads(get_resource('data/config_schema.json', pkg_name='onedrived'))
config_schema = json.loads(get_resource('data/config_schema.json', pkg_name='onedrive_client'))
config_guard = GuardedDict(config_dict=context.config, config_schema_dict=config_schema)


Expand Down Expand Up @@ -186,7 +186,7 @@ def list_accounts():
print_all_accounts(context)


@click.command(name='del', short_help='De-authorize and delete an existing account from onedrived.')
@click.command(name='del', short_help='De-authorize and delete an existing account from onedrive_client.')
@click.option('--yes', '-y', is_flag=True, default=False, required=False,
help='If set, do not ask for confirmation but simply delete if account exists.')
@click.option('--index', '-i', type=int, required=False, default=None,
Expand Down Expand Up @@ -230,7 +230,7 @@ def delete_account(yes=False, index=None, email=None, account_id=None):
except keyring.errors.PasswordDeleteError:
pass
save_context(context)
success('Successfully deleted account from onedrived.')
success('Successfully deleted account from onedrive_client.')
else:
click.echo('Operation canceled.')

Expand Down Expand Up @@ -288,7 +288,7 @@ def print_saved_drives():
click.echo(' Ignore file: %s' % curr_drive_config.ignorefile_path)
click.echo()
else:
click.echo(' No Drive has been setup with onedrived.\n')
click.echo(' No Drive has been setup with onedrive_client.\n')
return all_drive_ids


Expand Down Expand Up @@ -470,7 +470,7 @@ def delete_drive(drive_id=None, yes=False):
warning(translator['od_pref.del_drive.error_del_db_file'].format(error=str(e)))
context.delete_drive(drive_id)
save_context(context)
success('Successfully deleted Drive "%s" from onedrived.' % drive_id)
success('Successfully deleted Drive "%s" from onedrive_client.' % drive_id)
else:
click.echo('Operation canceled.')

Expand Down
8 changes: 4 additions & 4 deletions onedrived/od_repo.py → onedrive_client/od_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ class OneDriveLocalRepository:

def __init__(self, context, authenticator, drive, drive_config):
"""
:param onedrived.od_context.UserContext context:
:param onedrived.od_auth.OneDriveAuthenticator authenticator:
:param onedrive_client.od_context.UserContext context:
:param onedrive_client.od_auth.OneDriveAuthenticator authenticator:
:param onedrivesdk.model.drive.Drive drive:
:param onedrived.od_models.drive_config.LocalDriveConfig drive_config:
:param onedrive_client.od_models.drive_config.LocalDriveConfig drive_config:
"""
self.context = context
self.authenticator = authenticator
Expand Down Expand Up @@ -82,7 +82,7 @@ def _init_path_filter(self, ignore_file):

def _init_item_store(self):
self._conn = sqlite3.connect(self._item_store_path, check_same_thread=False)
self._conn.execute(_get_resource('data/items_db.sql', pkg_name='onedrived'))
self._conn.execute(_get_resource('data/items_db.sql', pkg_name='onedrive_client'))
atexit.register(self.close)

def refresh_session(self):
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions onedrived/od_task.py → onedrive_client/od_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def close(self, n=1):
def add_task(self, task):
"""
Add a task to internal storage. It will not add if there is already a task on the path.
:param onedrived.tasks.base.TaskBase task: The task to add.
:param onedrive_client.tasks.base.TaskBase task: The task to add.
"""
logging.debug('Adding task %s...' % task)
with self._lock:
Expand All @@ -45,7 +45,7 @@ def add_task(self, task):
def pop_task(self):
"""
Pop the oldest task. It's required that the caller first acquire the semaphore.
:return onedrived.od_tasks.base.TaskBase | None: The first qualified task, or None.
:return onedrive_client.od_tasks.base.TaskBase | None: The first qualified task, or None.
"""
# logging.debug('Getting task...')
with self._lock:
Expand All @@ -70,8 +70,8 @@ def occupy_path(self, local_abspath, task):
"""
Record a task in progress on a local path so that duplicate tasks can be avoided.
:param str local_abspath:
:param onedrived.od_tasks.base.TaskBase | None task: The task working on the path. None to blacklist the path.
:return onedrived.od_tasks.base.TaskBase | None:
:param onedrive_client.od_tasks.base.TaskBase | None task: The task working on the path. None to blacklist the path.
:return onedrive_client.od_tasks.base.TaskBase | None:
"""
with self._lock:
if local_abspath not in self.tasks_by_path:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ class TaskBase:

def __init__(self, repo, task_pool):
"""
:param onedrived.od_repo.OneDriveLocalRepository | None repo:
:param onedrived.od_task.TaskPool task_pool:
:param onedrive_client.od_repo.OneDriveLocalRepository | None repo:
:param onedrive_client.od_task.TaskPool task_pool:
"""
self.repo = repo
self.task_pool = task_pool
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class DeleteRemoteItemTask(update_item_base.UpdateItemTaskBase):

def __init__(self, repo, task_pool, parent_relpath, item_name, item_id=None, is_folder=False):
"""
:param onedrived.od_repo.OneDriveLocalRepository repo:
:param onedrived.od_task.TaskPool task_pool:
:param onedrive_client.od_repo.OneDriveLocalRepository repo:
:param onedrive_client.od_task.TaskPool task_pool:
:param str parent_relpath:
:param str item_name:
:param str | None item_id:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class DownloadFileTask(base.TaskBase):

def __init__(self, repo, task_pool, remote_item, parent_relpath):
"""
:param onedrived.od_repo.OneDriveLocalRepository repo:
:param onedrived.od_task.TaskPool task_pool:
:param onedrive_client.od_repo.OneDriveLocalRepository repo:
:param onedrive_client.od_task.TaskPool task_pool:
:param onedrivesdk.model.item.Item remote_item:
:param str parent_relpath:
"""
Expand Down
Loading

0 comments on commit 63858f5

Please sign in to comment.