Skip to main content

A Python library for interacting with farmOS over API.

Project description

farmOS.py

Licence Release Last commit Twitter Chat

farmOS.py is a Python library for interacting with farmOS over API.

For more information on farmOS, visit farmOS.org.

USAGE

import farmOS

hostname = 'myfarm.farmos.net'
username = 'My Name'
password = 'mYPa$$w0rd'

farm = farmOS.farmOS(hostname, username, password)
success = farm.authenticate()

# Get farm info
info = farm.info()

# Get all logs
logs = farm.log.get()
# Get harvest logs
harvests = farm.log.get({
  'type':'farm_harvest'
  })
# Get log number 37
log = farm.log.get(37)

# Get all assets
assets = farm.asset.get()
# Get all animal assets
animals = farm.asset.get({
  'type':'animal'
  })

# Get all areas
areas = farm.area.get()
# Get field areas
fields = farm.area.get({
  'area_type':'field'
  })

# Get all terms
terms = farm.term.get()
# Get all terms from farm_crops vocabulary
crops = farm.term.get('farm_crops')

You can configure how farmOS logs are displayed with the following:

import logging

# Required to init a config on the ROOT logger, that all other inherit from
logging.basicConfig()

 # Configure all loggers under farmOS (farmOS.client, famrOS.session) to desired level
logging.getLogger("farmOS").setLevel(logging.DEBUG)

 # Hide debug logging from the farmOS.session module
logging.getLogger("farmOS.session").setLevel(logging.WARNING)

More info on logging in Python here.

TESTING

Functional tests require a live instance of farmOS to communicate with. Configure credentials for the farmOS instance to test against by setting the following environment variables:

For farmOS Drupal Authentication: FARMOS_HOSTNAME, FARMOS_RESTWS_USERNAME, and FARMOS_RESTWS_PASSWORD

For farmOS OAuth Authentication (Password Flow): FARMOS_HOSTNAME, FARMOS_OAUTH_USERNAME, FARMOS_OAUTH_PASSWORD, FARMOS_OAUTH_CLIENT_ID, FARMOS_OAUTH_CLIENT_SECRET

Automated tests are run with pytest

python setup.py test

MAINTAINERS

This project has been sponsored by:

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

farmOS-0.1.6b2.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

farmOS-0.1.6b2-py3-none-any.whl (26.6 kB view details)

Uploaded Python 3

File details

Details for the file farmOS-0.1.6b2.tar.gz.

File metadata

  • Download URL: farmOS-0.1.6b2.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.3

File hashes

Hashes for farmOS-0.1.6b2.tar.gz
Algorithm Hash digest
SHA256 ac6b2110c6695a6415d0aeb4e525c9b81a8786a6c2f872b5760ee9698cba50ff
MD5 7780bd0ccb668f9b90a4d1bd749840b2
BLAKE2b-256 fc77b99f550e3620baa8f9c339473e8c69bb67edfaeb039f5b83b7eb4163f59a

See more details on using hashes here.

File details

Details for the file farmOS-0.1.6b2-py3-none-any.whl.

File metadata

  • Download URL: farmOS-0.1.6b2-py3-none-any.whl
  • Upload date:
  • Size: 26.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.3

File hashes

Hashes for farmOS-0.1.6b2-py3-none-any.whl
Algorithm Hash digest
SHA256 8ed03a152aab1053f532588d921d6e3a2e61f8c1ac196ff6756387ca33a7dcc2
MD5 82df793425dd803f3d4389e1035311c3
BLAKE2b-256 6a5d565aad4ae6cdaa47007bdf693ff6b3ab2f187ee0b1d36dfee5f19c6b3f3b

See more details on using hashes here.

Supported by

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