API¶
bsync.cli¶
bsync¶
Syncs the contents of local folder to your Box account
SOURCE_FOLDER is the path of an existing local folder. Additional, optional PATHS can be added as a glob expression after the folder.
BOX_FOLDER_ID is the ID for the folder in Box where you want the files sent
Example:
bsync -s 12345.json -l DEBUG images::*.jpg 123456789
bsync [OPTIONS] SOURCE_FOLDER[::PATHS] BOX_FOLDER_ID
Options
- --version¶
Show the version and exit.
- -s, --settings <settings>¶
- -o, --output <output>¶
File to write created items as CSV report
- -c, --concurrency <concurrency>¶
Number of threads used to access the Box API using asyncio. The default is the number of CPUs available on your system.
- -l, --log-level <log_level>¶
Log level
- Options
critical | fatal | error | warn | warning | info | debug
- --log-file <log_file>¶
Log file
- -i, --ipdb¶
Drop into ipdb shell on error
Arguments
- SOURCE_FOLDER[::PATHS]¶
Required argument
- BOX_FOLDER_ID¶
Required argument
Environment variables
- SOURCE_FOLDER
Provide a default for
SOURCE_FOLDER[::PATHS]
- BOX_FOLDER_ID
Provide a default for
BOX_FOLDER_ID
- BOX_SETTINGS_FILE
Provide a default for
-s
bsync.api¶
- class bsync.api.BoxAPI(logger, settings)[source]¶
Bases:
object
Wraps boxsdk to create a client and perform actions, logging results
- property client¶
Gets a boxsdk.Client instance from the JSON settings file using JWT
- send_chunked(path, session_func)[source]¶
Uses the chunked upload API from Box to upload sequential segments of a file
bsync.sync¶
- class bsync.sync.BoxSync(api, logger, concurrency, box_folder_id, source_folder_paths)[source]¶
Bases:
object
Syncs the parent folder files to Box.
Compares current files, checks for any missing in Box or any changed locally, creates directory structure and finally uploads all files
- has_changed(boxfile, path)[source]¶
Compares the file on Box with the path on disk Used to see if the local file has changed
- property parent_folder¶
Gets the parent folder in Box via API GET
- prepare()[source]¶
Loads entries from local filesystem and Box Used to decide later which items to sync
- run()[source]¶
Main method that finds local files and matching files on Box. Then syncs the folder/subfolder structure and finally syncs any files to Box from the local machine
- async sync_files()[source]¶
Uploads the new or updated files to Box.com Folder structure must be created before running