Skip to main content

No project description provided

Project description

$ posidrive

This Python library aims to make easier use Google Drive to backup/restore your data.

Installation

pip install posidrive

Install latest development version:

pip install git+https://github.com/Positeral/posidrive

Quickstart

Let's write a simple gd.py script:

from posidrive.gdrive import GoogleDrive

gdrive = GoogleDrive(folder='test')
gdrive.cli()

Run it from command line:

python gd.py
Usage: gd.py [OPTIONS] COMMAND [ARGS]...

Options:
  --debug  Enable debug mode.
  --help   Show this message and exit.

Commands:
  auth      Authorize Google account and save credentials.
  status    Show common information.
  list      Show files in current remote folder.
  upload    Upload file to current remote folder.
  download  Download file by ID.
  delete    Delete file by ID.
  clear     Delete all files in folder.
python gd.py status
Service:               Google Drive
Current remote folder: test
Credentials file:      /home/arthur/projects/posidrive/.pgdcredentials
Authorization:         Not authorized (credentials absent)

Let's authorize the application now:

python gd.py auth
Please visit this URL to authorize this application: https://[...]
Enter the authorization code: 

Follow the link, authorize the application and paste the resulting code. By default, posidrive request you the minimal permissions. Сheck the status:

python gd.py status
Service:               Google Drive
Current remote folder: test
Credentials file:      /home/arthur/projects/posidrive/.pgdcredentials
Authorization:         Authorized
Account:               af3.inet@gmail.com
Usage:                 11.2G
Limit:                 15G

Good! Now you can use list, upload, download, delete or clear. Don't forget that every command have --help option.

Custom scripts

The following script make a compressed archive and upload it to Google Drive. Then, it will delete all remote files except the last three:

import os
import click
import tarfile

from posidrive.gdrive import GoogleDrive


class MyGoogleDrive(GoogleDrive):
    @GoogleDrive.cli.command('archive')
    @click.argument('path', required=True)
    def cmd_archive(self, path):
        '''Archive directory/file'''
        self.initialize()

        tarname = os.path.basename(path)+'.tar.lzma'
        tarpath = tarname

        tar = tarfile.open(tarpath, 'w:xz')
        tar.add(path)
        tar.close()

        self.cmd_upload(tarpath, tarname)
        self.cmd_clear(keep_last=3, yes=True)


gdrive = MyGoogleDrive(folder='test')
gdrive.cli()

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

posidrive-0.1.1.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

posidrive-0.1.1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file posidrive-0.1.1.tar.gz.

File metadata

  • Download URL: posidrive-0.1.1.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for posidrive-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ae2e02ad23e6d56d989cdbd58432497dd828cb3033a8d9784594dacf0b0d8765
MD5 46a4c150e4fd935ec417c4fa6513b6a0
BLAKE2b-256 f8232a504464d32153308b9e15b48a95f5b04ee32b6e07cf118e03fc9b65151b

See more details on using hashes here.

File details

Details for the file posidrive-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: posidrive-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.9

File hashes

Hashes for posidrive-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4dd81143447b1edb131b04a8c5e89f369d1b8d8efb9a7cb730a10e5be1a337d7
MD5 b730f8c1d8f9a35251ebd3f07fa04124
BLAKE2b-256 85e0eabfbdc9157a5f39bbc9c9c06cfe33614f31aee7b292b020a9327091f8e9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page