Sync Status module

synchronizer.syncstatus.compare_stats(src_path, trg_path, ignore_name=False, ignore_stats=['st_uid', 'st_gid', 'st_atime', 'st_ctime', 'st_ino', 'st_dev'])

Compares stats and file names for two given paths. Returns a dict with all comparison results.

Arguments:

src_path {str} – Source path, file or directory

trg_path {str} – Target path, file or directory

Keyword Arguments:

ignore_name {bool} – Ignores name comparison (default: {False})

ignore_stats {list} – Ignores this list of stats. Names correspond to what os.stat() returns. (default: [‘st_uid’, ‘st_gid’, ‘st_atime’, ‘st_ctime’, ‘st_ino’, ‘st_dev’])

-‘st_mode’: ‘File type and file mode bits’

-‘st_ino’: ‘inode or file index’

-‘st_dev’: ‘Device’

-‘st_nlink’: ‘Number of hard links’

-‘st_uid’: ‘User id of owner’

-‘st_gid’: ‘Group id of owner’

-‘st_size’: ‘File size’

-‘st_atime’: ‘Most recent access’

-‘st_mtime’: ‘Last modification’

-‘st_ctime’: ‘Most recent metadata change’

Returns:
[dict] – {Stat description: Comparison result bool}
synchronizer.syncstatus.get_dir_size(dir_path)

Walks thru given directory to calculate total size.

Arguments:
dir_path {str} – Directory to measure size.
Returns:

[int] – Size of directory in bytes, as reported by the sum of all its files os.stat()

[None] – If dir_path is not a directory, returns None

synchronizer.syncstatus.get_most_recent(src_path, trg_path, use_stat='st_mtime')

Compares two paths and returns whichever has the most recent stat time. Default stat used for comparison is st_mtime which is: Time of most recent content modification.

Arguments:

src_path {str} – Source path, file or directory

trg_path {str} – Target path, file or directory

Keyword Arguments:

use_stat {str} – Stat used for comparison (default: {‘st_mtime’})

Valid options:

-‘st_mtime’: Time of most recent content modification

-‘st_atime’: Time of most recent access

-‘st_ctime’: Time of creation on Windows, time of most recent metadata change on Unix

Returns:

[str] – Path of whichever has the most recent stat time.

[None] – If both path stats are equal or an invalid stat options is passed.

synchronizer.syncstatus.get_sync_status(src_path, trg_path, ignore_name=False, ignore_stats=['st_uid', 'st_gid', 'st_atime', 'st_ctime', 'st_ino', 'st_dev'])

Compare two files or directory paths and return sync status. Sync status refers to name and os.stat() comparisons.

Arguments:

src_path {str} – Source path, file or directory

trg_path {str} – Target path, file or directory

Keyword Arguments:

ignore_name {bool} – Ignores name comparison (default: {False})

ignore_stats {list} – Ignores this list of stats. Names correspond to what os.stat() returns. (default: [‘st_uid’, ‘st_gid’, ‘st_atime’, ‘st_ctime’, ‘st_ino’, ‘st_dev’])

-‘st_mode’: ‘File type and file mode bits’

-‘st_ino’: ‘inode or file index’

-‘st_dev’: ‘Device’

-‘st_nlink’: ‘Number of hard links’

-‘st_uid’: ‘User id of owner’

-‘st_gid’: ‘Group id of owner’

-‘st_size’: ‘File size’

-‘st_atime’: ‘Most recent access’

-‘st_mtime’: ‘Last modification’

-‘st_ctime’: ‘Most recent metadata change’

Returns:
[tuple] – (Status code, Status description)

1 = “In sync”

2 = “Out of sync”

3 = “Both paths do not exist”

4 = “Source path does not exist”

5 = “Target path does not exist”

6 = “Different kind of paths (file-dir, dir-file)”

7 = “Source and Target are the same”

[None] – Not implemented status comparison