pcloud


Namepcloud JSON
Version 1.3 PyPI version JSON
download
home_pagehttps://pypi.python.org/pypi/pcloud
SummaryA client library for pCloud
upload_time2024-03-01 06:18:05
maintainer
docs_urlNone
authorTom Gross
requires_python
licenseMIT
keywords python pcloud rest
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ==============================================================================
pcloud - A Python API client for pCloud
==============================================================================

.. image:: https://github.com/tomgross/pcloud/actions/workflows/pcloud-test.yml/badge.svg
    :target: https://github.com/tomgross/pcloud/actions

This Python **(Version >= 3.6 only!)** library provides a Python API to the pCloud storage.

Features
========

- Can be used as a library
- Provides a PyFileSystem implementation

Examples
========

Usage of API
------------

 >>> from pcloud import PyCloud
 >>> pc = PyCloud('email@example.com', 'SecretPassword')
 >>> pc.listfolder(folderid=0)

Use alternate endpoints (*API calls have to be made to the correct API host name depending were the user has been
registered – api.pcloud.com for United States and eapi.pcloud.com for Europe.*)

 >>> from pcloud import PyCloud
 >>> pc = PyCloud('email@example.com', 'SecretPassword', endpoint="eapi")
 >>> pc.listfolder(folderid=0)

PyCloud also provides an API method to retrieve the nearest API server, which gives
you a speed gain for some API operations. To use PyCloud with this feature create
the PyCloud-object with the *nearest* endpoint parameter:

 >>> from pcloud import PyCloud
 >>> pc = PyCloud('email@example.com', 'SecretPassword', endpoint="nearest")
 >>> pc.listfolder(folderid=0)

OAuth 2.0 authentication
------------------------

To use OAuth 2.0 authentication you need to create an App in pCloud (https://docs.pcloud.com/my_apps/).

Add the following redirect URI http://localhost:65432/
(Make sure port 65432 is available on your machine. Otherwise you need to adjust the `PORT` in oauth2.py)

Note! To see the redirect URI in the settings of pCloud you have to log out and log in again.

Once you finished adding the app and setting the redirect URI you are ready to use
OAuth 2.0 with PyCloud on your machine. For the communication with pCloud PyCloud uses the
builtin `webserver`-module. This means you need a real browser on your system available.

 >>> from pcloud import PyCloud
 >>> pc = PyCloud.oauth2_authorize(client_id="XYZ", client_secret="abc123")
 >>> pc.listfolder(folderid=0)

Headless mode
+++++++++++++

OAuth 2.0 is designed to use a browser for the authentication flow. Nevertheless Selenium
can be used to automate this process. For an example see the `pycloud_oauth2`-fixture in `test_oauth2.py`.
This method will not integrated as main functionality, since there are too many dependencies.
You can use it as example for your usecase.

Uploading files
---------------

a) from filenames:

  >>> pc.uploadfile(files=['/full/path/to/image1.jpg', '/Users/tom/another/image.png'],
  ...     path='/path-to-pcloud-dir')

b) from data:

  >>> import io
  >>> from PIL import Image
  >>> img = Image.open('image.jpg', 'r')
  >>> bio = io.BytesIO()
  >>> img.save(bio, format='jpeg')
  >>> pc.uploadfile(data=bio.getvalue(), filename="image.jpg", path='/path-to-pcloud-dir')

Usage of PyFilesystem with opener

  >>> from fs import opener
  >>> opener.open_fs('pcloud://email%40example.com:SecretPassword@/')
  <pCloudFS>

Copying files from Linux to pCloud using PyFilesystem

  >>> from fs import opener, copy
  >>> with opener.open_fs('pcloud://email%40example.com:SecretPassword@/') as pcloud_fs:
  >>>    with opener.open_fs('/opt/data_to_copy') as linux_fs:
  >>>        copy.copy_file(src_fs=linux_fs,
  >>>                       src_path='database.sqlite3',
  >>>                       dst_fs=pcloud_fs,
  >>>                       dst_path='/backup/server/database.sqlite3')

Copy directory from Linux to pCloud using PyFilesystem

  >>> from fs import opener, copy
  >>> with opener.open_fs('pcloud://email%40example.com:SecretPassword@/') as pcloud_fs:
  >>>    with opener.open_fs('/opt/data_to_copy') as linux_fs:
  >>>        copy.copy_dir(src_fs=linux_fs,
  >>>                      src_path='database/',
  >>>                      dst_fs=pcloud_fs,
  >>>                      dst_path='/backup/database/')

Further Documentation
=====================

Implements the pCloud API found at https://docs.pcloud.com/


Installation
============

 $ pip install pcloud

Installation with PyFilesystem support

 $ bin/pip install pcloud[pyfs]

on zsh (Mac):

 $ bin/pip install "pcloud[pyfs]"


Development
===========

For testing purposes a mock server is provided. To use this mock server
you need to add a file with the same name as the method + the `.json` suffix
in the tests/data directory (like `getdigest.json`).
The file contains the expected JSON result.

Contribute
==========

- Issue Tracker: https://github.com/tomgross/pcloud/issues
- Source Code: https://github.com/tomgross/pcloud

License
=======

The project is licensed under MIT (see LICENSE).


Contributors
============

- Tom Gross, itconsense@gmail.com
- Massimo Vannucci (blasterspike)
- Yennick Schepers (yennicks)
- olokelo
- qo4on


Changelog
=========

1.3 (2024-03-01)
----------------

- Reimplement pyfs integration [tomgross]
- Update (test) dependencies and run tests only on Python 3.8-3.12 [tomgross]
- Added more API methods [tomgross]


1.2 (2023-06-24)
----------------

- Add `CONTRIBUTING` guideline and update `CODE_OF_CONDUCT` document [tomgross]
- Add Sonarcloud checker and report test coverage [tomgross]
- Add test for listtokens endpoint [tomgross]
- Changed repo name to https://github.com/tomgross/pcloud/ to be consistent (https://github.com/tomgross/pcloud/issues/70) [tomgross]
- Implement `sharefolder`-endpoint [tomgross]
- Replace ``cgi.FieldStorage`` by ``multipart`` avoiding
  the ``cgi`` module deprecated by Python 3.11. [tomgross]

1.1 (2022-11-14)
----------------

- Fix upload with int folderid #63 [tomgross]
- Add pytest timeout and update testing dependencies [tomgross]
- Implement `copyfile` and `downloadfileasync` methods [tomgross]
- Implement `setlanguage`, `getfeedback`, `diff` & `getfilehistory` methods [tomgross]


1.0 (2022-02-02)
----------------

- 🎉 Release unchanged as 1.0 🎉

1.0b2 (2021-12-17)
------------------

- Build wheel package [tomgross]
- Fix file upload with oauth [giust]
- Automated test for OAuth [tomgross]
- Documented headless OAuth [tomgross]

1.0b1 (2021-11-26)
------------------

- Python 3.10 compatibility and dependency updates
- Change port of test server 5000 -> 5023
- Add *getpubzip* API method (https://github.com/tomgross/pcloud/issues/51)
- Allow uploading BIG files by using MultipartEncoder of requests_toolbelt
  (https://github.com/tomgross/pcloud/issues/25, https://github.com/tomgross/pcloud/issues/44)
- Log login process
  [tomgross]

1.0a10 (2021-07-11)
-------------------

- State and test Python 3.9 support [tomgross]
- OAuth 2.0 implementation [tomgross]
- Implement more general methods [tomgross]
- Implement get nearest api server [tomgross]

1.0a9 (2021-01-22)
------------------

- Missing variable in output in case a directory already exists
- Changed errors raised for makedirs
- Do not raise an errors.DirectoryExists when recreate = True
- Added examples to README
  [blasterspike]

- Fix parameter of downloadlink method
  [tomgross]

- Add more details on authentication error
  [yennicks]

- Add new stats endpoint
  [AgusRumayor]

- Add methods for archiving
  [olokelo]

- Add token expire parameter
  [olekelo]

- Start implementing trash methods
  [qo4on, tomgross]

- Add support for alternate endpoints
  [tomgross]

- Add Contributors and fix README ReST Syntax

1.0a8 (2020-02-21)
------------------

- Fix upload of multiple files from paths
  [tomgross]

- Document uploading of files
  [tomgross]

1.0a7 (2020-02-20)
------------------

- Add new API method `createfolderifnotexists` #19
  [Arkoniak, tomgross]

- Fix duplication of data transfer on file upload #17
  [blasterspike, tomgross]

- Consistently use MIT licences
  [tomgross]

1.0a6 (2019-01-18)
------------------

- Fix error while using makedirs from PyFilesystem with recreate=True
  [blasterspike]

1.0a5 (2018-10-22)
------------------

- Fix error while using makedirs from PyFilesystem
  https://github.com/tomgross/pcloud/issues/10
  [blasterspike]

- Test and claim Python 3.7 compatibility
  [tomgross]

1.0a4 (2017-10-29)
------------------

- Fix error with duplicate files parameter #3
  [tomgross]

- Fix upload of data
  [tomgross]

- Do flake8 checks
  [tomgross]


1.0a3 (2017-10-07)
------------------

- Test API with py.test
  [tomgross]

- Support for PyFileSystem
  [tomgross]

- Support for file operations
  [tomgross]

1.0a2 (2017-05-21)
------------------

- Rename to pcloud
  [tomgross]


1.0a1 (2017-05-21)
------------------

- Initial release.
  [tomgross]

            

Raw data

            {
    "_id": null,
    "home_page": "https://pypi.python.org/pypi/pcloud",
    "name": "pcloud",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "Python pCloud REST",
    "author": "Tom Gross",
    "author_email": "itconsense@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/53/06/c3fa1356701dd9b0484d35d68b40f8fcfe2d1f98b353135e6f17900492ce/pcloud-1.3.tar.gz",
    "platform": null,
    "description": "==============================================================================\npcloud - A Python API client for pCloud\n==============================================================================\n\n.. image:: https://github.com/tomgross/pcloud/actions/workflows/pcloud-test.yml/badge.svg\n    :target: https://github.com/tomgross/pcloud/actions\n\nThis Python **(Version >= 3.6 only!)** library provides a Python API to the pCloud storage.\n\nFeatures\n========\n\n- Can be used as a library\n- Provides a PyFileSystem implementation\n\nExamples\n========\n\nUsage of API\n------------\n\n >>> from pcloud import PyCloud\n >>> pc = PyCloud('email@example.com', 'SecretPassword')\n >>> pc.listfolder(folderid=0)\n\nUse alternate endpoints (*API calls have to be made to the correct API host name depending were the user has been\nregistered \u2013 api.pcloud.com for United States and eapi.pcloud.com for Europe.*)\n\n >>> from pcloud import PyCloud\n >>> pc = PyCloud('email@example.com', 'SecretPassword', endpoint=\"eapi\")\n >>> pc.listfolder(folderid=0)\n\nPyCloud also provides an API method to retrieve the nearest API server, which gives\nyou a speed gain for some API operations. To use PyCloud with this feature create\nthe PyCloud-object with the *nearest* endpoint parameter:\n\n >>> from pcloud import PyCloud\n >>> pc = PyCloud('email@example.com', 'SecretPassword', endpoint=\"nearest\")\n >>> pc.listfolder(folderid=0)\n\nOAuth 2.0 authentication\n------------------------\n\nTo use OAuth 2.0 authentication you need to create an App in pCloud (https://docs.pcloud.com/my_apps/).\n\nAdd the following redirect URI http://localhost:65432/\n(Make sure port 65432 is available on your machine. Otherwise you need to adjust the `PORT` in oauth2.py)\n\nNote! To see the redirect URI in the settings of pCloud you have to log out and log in again.\n\nOnce you finished adding the app and setting the redirect URI you are ready to use\nOAuth 2.0 with PyCloud on your machine. For the communication with pCloud PyCloud uses the\nbuiltin `webserver`-module. This means you need a real browser on your system available.\n\n >>> from pcloud import PyCloud\n >>> pc = PyCloud.oauth2_authorize(client_id=\"XYZ\", client_secret=\"abc123\")\n >>> pc.listfolder(folderid=0)\n\nHeadless mode\n+++++++++++++\n\nOAuth 2.0 is designed to use a browser for the authentication flow. Nevertheless Selenium\ncan be used to automate this process. For an example see the `pycloud_oauth2`-fixture in `test_oauth2.py`.\nThis method will not integrated as main functionality, since there are too many dependencies.\nYou can use it as example for your usecase.\n\nUploading files\n---------------\n\na) from filenames:\n\n  >>> pc.uploadfile(files=['/full/path/to/image1.jpg', '/Users/tom/another/image.png'],\n  ...     path='/path-to-pcloud-dir')\n\nb) from data:\n\n  >>> import io\n  >>> from PIL import Image\n  >>> img = Image.open('image.jpg', 'r')\n  >>> bio = io.BytesIO()\n  >>> img.save(bio, format='jpeg')\n  >>> pc.uploadfile(data=bio.getvalue(), filename=\"image.jpg\", path='/path-to-pcloud-dir')\n\nUsage of PyFilesystem with opener\n\n  >>> from fs import opener\n  >>> opener.open_fs('pcloud://email%40example.com:SecretPassword@/')\n  <pCloudFS>\n\nCopying files from Linux to pCloud using PyFilesystem\n\n  >>> from fs import opener, copy\n  >>> with opener.open_fs('pcloud://email%40example.com:SecretPassword@/') as pcloud_fs:\n  >>>    with opener.open_fs('/opt/data_to_copy') as linux_fs:\n  >>>        copy.copy_file(src_fs=linux_fs,\n  >>>                       src_path='database.sqlite3',\n  >>>                       dst_fs=pcloud_fs,\n  >>>                       dst_path='/backup/server/database.sqlite3')\n\nCopy directory from Linux to pCloud using PyFilesystem\n\n  >>> from fs import opener, copy\n  >>> with opener.open_fs('pcloud://email%40example.com:SecretPassword@/') as pcloud_fs:\n  >>>    with opener.open_fs('/opt/data_to_copy') as linux_fs:\n  >>>        copy.copy_dir(src_fs=linux_fs,\n  >>>                      src_path='database/',\n  >>>                      dst_fs=pcloud_fs,\n  >>>                      dst_path='/backup/database/')\n\nFurther Documentation\n=====================\n\nImplements the pCloud API found at https://docs.pcloud.com/\n\n\nInstallation\n============\n\n $ pip install pcloud\n\nInstallation with PyFilesystem support\n\n $ bin/pip install pcloud[pyfs]\n\non zsh (Mac):\n\n $ bin/pip install \"pcloud[pyfs]\"\n\n\nDevelopment\n===========\n\nFor testing purposes a mock server is provided. To use this mock server\nyou need to add a file with the same name as the method + the `.json` suffix\nin the tests/data directory (like `getdigest.json`).\nThe file contains the expected JSON result.\n\nContribute\n==========\n\n- Issue Tracker: https://github.com/tomgross/pcloud/issues\n- Source Code: https://github.com/tomgross/pcloud\n\nLicense\n=======\n\nThe project is licensed under MIT (see LICENSE).\n\n\nContributors\n============\n\n- Tom Gross, itconsense@gmail.com\n- Massimo Vannucci (blasterspike)\n- Yennick Schepers (yennicks)\n- olokelo\n- qo4on\n\n\nChangelog\n=========\n\n1.3 (2024-03-01)\n----------------\n\n- Reimplement pyfs integration [tomgross]\n- Update (test) dependencies and run tests only on Python 3.8-3.12 [tomgross]\n- Added more API methods [tomgross]\n\n\n1.2 (2023-06-24)\n----------------\n\n- Add `CONTRIBUTING` guideline and update `CODE_OF_CONDUCT` document [tomgross]\n- Add Sonarcloud checker and report test coverage [tomgross]\n- Add test for listtokens endpoint [tomgross]\n- Changed repo name to https://github.com/tomgross/pcloud/ to be consistent (https://github.com/tomgross/pcloud/issues/70) [tomgross]\n- Implement `sharefolder`-endpoint [tomgross]\n- Replace ``cgi.FieldStorage`` by ``multipart`` avoiding\n  the ``cgi`` module deprecated by Python 3.11. [tomgross]\n\n1.1 (2022-11-14)\n----------------\n\n- Fix upload with int folderid #63 [tomgross]\n- Add pytest timeout and update testing dependencies [tomgross]\n- Implement `copyfile` and `downloadfileasync` methods [tomgross]\n- Implement `setlanguage`, `getfeedback`, `diff` & `getfilehistory` methods [tomgross]\n\n\n1.0 (2022-02-02)\n----------------\n\n- \ud83c\udf89 Release unchanged as 1.0 \ud83c\udf89\n\n1.0b2 (2021-12-17)\n------------------\n\n- Build wheel package [tomgross]\n- Fix file upload with oauth [giust]\n- Automated test for OAuth [tomgross]\n- Documented headless OAuth [tomgross]\n\n1.0b1 (2021-11-26)\n------------------\n\n- Python 3.10 compatibility and dependency updates\n- Change port of test server 5000 -> 5023\n- Add *getpubzip* API method (https://github.com/tomgross/pcloud/issues/51)\n- Allow uploading BIG files by using MultipartEncoder of requests_toolbelt\n  (https://github.com/tomgross/pcloud/issues/25, https://github.com/tomgross/pcloud/issues/44)\n- Log login process\n  [tomgross]\n\n1.0a10 (2021-07-11)\n-------------------\n\n- State and test Python 3.9 support [tomgross]\n- OAuth 2.0 implementation [tomgross]\n- Implement more general methods [tomgross]\n- Implement get nearest api server [tomgross]\n\n1.0a9 (2021-01-22)\n------------------\n\n- Missing variable in output in case a directory already exists\n- Changed errors raised for makedirs\n- Do not raise an errors.DirectoryExists when recreate = True\n- Added examples to README\n  [blasterspike]\n\n- Fix parameter of downloadlink method\n  [tomgross]\n\n- Add more details on authentication error\n  [yennicks]\n\n- Add new stats endpoint\n  [AgusRumayor]\n\n- Add methods for archiving\n  [olokelo]\n\n- Add token expire parameter\n  [olekelo]\n\n- Start implementing trash methods\n  [qo4on, tomgross]\n\n- Add support for alternate endpoints\n  [tomgross]\n\n- Add Contributors and fix README ReST Syntax\n\n1.0a8 (2020-02-21)\n------------------\n\n- Fix upload of multiple files from paths\n  [tomgross]\n\n- Document uploading of files\n  [tomgross]\n\n1.0a7 (2020-02-20)\n------------------\n\n- Add new API method `createfolderifnotexists` #19\n  [Arkoniak, tomgross]\n\n- Fix duplication of data transfer on file upload #17\n  [blasterspike, tomgross]\n\n- Consistently use MIT licences\n  [tomgross]\n\n1.0a6 (2019-01-18)\n------------------\n\n- Fix error while using makedirs from PyFilesystem with recreate=True\n  [blasterspike]\n\n1.0a5 (2018-10-22)\n------------------\n\n- Fix error while using makedirs from PyFilesystem\n  https://github.com/tomgross/pcloud/issues/10\n  [blasterspike]\n\n- Test and claim Python 3.7 compatibility\n  [tomgross]\n\n1.0a4 (2017-10-29)\n------------------\n\n- Fix error with duplicate files parameter #3\n  [tomgross]\n\n- Fix upload of data\n  [tomgross]\n\n- Do flake8 checks\n  [tomgross]\n\n\n1.0a3 (2017-10-07)\n------------------\n\n- Test API with py.test\n  [tomgross]\n\n- Support for PyFileSystem\n  [tomgross]\n\n- Support for file operations\n  [tomgross]\n\n1.0a2 (2017-05-21)\n------------------\n\n- Rename to pcloud\n  [tomgross]\n\n\n1.0a1 (2017-05-21)\n------------------\n\n- Initial release.\n  [tomgross]\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A client library for pCloud",
    "version": "1.3",
    "project_urls": {
        "Homepage": "https://pypi.python.org/pypi/pcloud"
    },
    "split_keywords": [
        "python",
        "pcloud",
        "rest"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8c78575888fde38b63a495390e5ee84e9454cc0666bb17976c476dc932299054",
                "md5": "addd856870bff25746d11a8a4af2f569",
                "sha256": "a70ac20ba715ebe575a2e280e5d2d20e0ed761476bfc76f648c827d5abbdd0fa"
            },
            "downloads": -1,
            "filename": "pcloud-1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "addd856870bff25746d11a8a4af2f569",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 23565,
            "upload_time": "2024-03-01T06:18:03",
            "upload_time_iso_8601": "2024-03-01T06:18:03.803009Z",
            "url": "https://files.pythonhosted.org/packages/8c/78/575888fde38b63a495390e5ee84e9454cc0666bb17976c476dc932299054/pcloud-1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5306c3fa1356701dd9b0484d35d68b40f8fcfe2d1f98b353135e6f17900492ce",
                "md5": "c0d840cd1cb49915a67c68a8ec7c2d2b",
                "sha256": "01d9409ddad5f5aaea914f468eaca6cfb54a5d60adf6bf95a7dae10de52c9350"
            },
            "downloads": -1,
            "filename": "pcloud-1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "c0d840cd1cb49915a67c68a8ec7c2d2b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 29246,
            "upload_time": "2024-03-01T06:18:05",
            "upload_time_iso_8601": "2024-03-01T06:18:05.304997Z",
            "url": "https://files.pythonhosted.org/packages/53/06/c3fa1356701dd9b0484d35d68b40f8fcfe2d1f98b353135e6f17900492ce/pcloud-1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-01 06:18:05",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "pcloud"
}
        
Elapsed time: 0.19848s