Python usage

foldershare_python_wrapper

This library provides a simple Python wrapper for the foldershare PHP client.

How to import this module

Once the foldershare/client folder has been downloaded to a directory of your choice, ensure that this directory is included in your environment's $PYTHONPATH variable. You can do this with something like:

PYTHONPATH="<path to foldershare/client>:$PYTHONPATH"
export PYTHONPATH

Finally, to import this module inside a script within the same environment, simply do the following:

from foldershare_wrapper_api import Foldershare
...

Usage

Create a Foldershare client instance

from foldershare_wrapper_api import Foldershare

FOLDERSHARE_CLIENT_PATH = "./foldershare"
foldershare = Foldershare(FOLDERSHARE_CLIENT_PATH, url=None, host="localhost", port=80, username=None, password=None, authfile=None, masquerade=None, apikey=None)

Be sure to fill in the appropriate authentication parameters (e.g., usernamepassword, etc.), depending on how you choose to authenticate the foldershare client with the foldershare server.

Run a Foldershare command and retrieve the response

from foldershare_wrapper_api import Foldershare
from pprint import pprint

FOLDERSHARE_CLIENT_PATH = "./foldershare"
foldershare = Foldershare(FOLDERSHARE_CLIENT_PATH, url=None, host="localhost", port=80, username=None, password=None, authfile=None, masquerade=None, apikey=None)

"""
To run any arbitrary FolderShare command, you can do:

result = foldershare.command_name()
or,
result = foldershare.command_name(arg1, arg2, ...)
"""
result = foldershare.ls("-R", "-r")
pprint(result)

The returned result of any command will be a JSON object (ie., Python dict), except for commands where the foldershare client always returns the response as a raw string and not in JSON form (e.g, foldershare help, etc.). In these cases, the result returned by this wrapper will also be a str and not a dict.

Run tests

cd foldershare/client/tests
PYTHONPATH=.. python test_client.py