A Python package to sync files with Google Drive and locally.
Project description
Syncverse
Syncverse is a Python package that helps you synchronize files between your local storage and cloud storage (Google Drive). With Syncverse, you can easily monitor and keep your files in sync—whether it's uploading, updating, or deleting files on Google Drive, or syncing files between local directories.
Features
Local File Sync - Synchronize files between two local directories. Google Drive Sync - Sync files to Google Drive from local, including support for file updates and deletions.
Installation
Install Syncverse directly from PyPI using:
pip install syncverse
Requirements
Python 3.6 or higher
watchdog for file system monitoring
Google API client libraries for Google Drive integration
To install dependencies manually using requirements.txt:
pip install -r requirements.txt
Usage
Importing the Package
import syncverse
import gdrive_sync
from syncverse.gdrive_sync import GoogleDriveSyncHandler
from syncverse.local_sync import FileSyncHandler
Synchronizing Files Locally
Sync files between two local directories:
from syncverse.local_sync import FileSyncHandler
# Define source and destination file paths
source_file = "path/to/your/sourcefile"
destination_file = "path/to/your/destinationfile"
# Initialize FileSyncHandler
local_sync = FileSyncHandler(source_file, destination_file)
# Start synchronization
local_sync.sync_file()
Explanation:
FileSyncHandler: Monitors and synchronizes changes from a source file to a destination file.
Synchronizing Files with Google Drive
Sync a local file with Google Drive:
from syncverse.gdrive_sync import GoogleDriveSyncHandler
# Authenticate Google Drive (Make sure your 'credentials.json' is in the working directory)
drive_service = authenticate_drive()
# Define local file path
local_file_path = "path/to/your/localfile"
# Initialize GoogleDriveSyncHandler
drive = GoogleDriveSyncHandler(local_file_path, drive_service, file_id=None)
# Start synchronization
drive.sync_to_drive()
Explanation:
authenticate_drive(): Authenticates and connects to Google Drive.
GoogleDriveSyncHandler: Handles synchronization between the local file and Google Drive.
file_id: If set to None, a new file will be uploaded; if an ID is provided, the file will be updated instead.
Google Drive Authentication
For Google Drive synchronization, you'll need to authenticate your Google account. The first time you run a Google Drive sync, the package will prompt you to authenticate using OAuth2.
After successful authentication, your credentials will be stored in a token.json file, so you don't need to authenticate again unless the token expires.
Steps to authenticate:
Place your credentials.json(from Google Cloud Console) in your working directory.
Run the script, and a browser window will open for authentication.
After granting permissions, a token.json file will be created.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgements
This package uses the watchdog library for monitoring file system events. The Google API Client Library for Python (google-api-python-client) is used to interact with Google Drive.
Support
If you encounter any issues, feel free to open an issue.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file syncverse-0.1.3.tar.gz.
File metadata
- Download URL: syncverse-0.1.3.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
617fcd5893c1bcad6fbd43f4b4dfc1c239bba7708f914ed66d9398263b1243f2
|
|
| MD5 |
36b831a7ec71ffb203095808ace2b8ac
|
|
| BLAKE2b-256 |
9712a419aead72c293a480cbbe9915bf9b2d9b85d31bd21deff55b96834aa2e3
|
File details
Details for the file syncverse-0.1.3-py3-none-any.whl.
File metadata
- Download URL: syncverse-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b69878ef1a8f5dffe409186b0054e45108babef4185134ae46a68ac7bdc5706
|
|
| MD5 |
5773bebf94327eed74257d92c3dbe03c
|
|
| BLAKE2b-256 |
a906da2383b8d81ddde528b09ee868232199ce4d6db224e286eaca2b1420038c
|