Install farmOS.py using pip
. Rather
than installing system wide, it is recommended to install packages into a
virtual environment. For more information see Installing Python Packages.
# Dedicate a directory for farmOS scripts.
cd farmos_scripts
Install farmOS.py using pip
. Rather
than installing system wide, it is recommended to install packages into a
virtual environment. For more information see Installing Python Packages.
# Dedicate a directory for farmOS scripts.
cd farmos_scripts
# Library definitions prefixed with Drupal module name | |
# Some kind of a ol-federated provided entrypoint? All OL chunks depend on this? | |
farm_map/ol_federated_entrypoint: { .. } | |
# Many ol_* chunks each provided as a library. | |
farm_map/ol_core: { .. } # Ideally we can create a single chunk with all of the essential OL chunks needed for farmOS-map. | |
farm_map/ol_control_*: { .. } # Optional controls | |
farm_map/ol_interaction_*: { .. } # Optional interactions | |
farm_map/ol_source_*: { .. } # Optional sources eg: Tile, Vector, WMS, XYZ... some included in ol_core? |
{ | |
"header" : { | |
"app":"RPG Map 2", | |
"appVersion":16.2, | |
"appAuthor":"Sebastien Benard", | |
"fileType":"JSON Map", | |
"fileVersion":10, | |
"url":"https://deepnight.net/tools/rpg-map/" | |
}, | |
"version":10, |
"""Move farm info to separate table. | |
Revision ID: cbc5e5092520 | |
Revises: d2422b5a6859 | |
Create Date: 2020-06-02 23:36:50.018420 | |
""" | |
from alembic import op | |
import sqlalchemy as sa | |
from sqlalchemy.dialects import postgresql |
Just realized I'm doing something similar for the CSV Importer. I found myself querying for a taxonomy term by the term'sname
multiple times. This required me to also look up the taxonomy_vocabulary vid
multiple times... but rather than querying the farmOS server for the taxonomy vid
each time, I maintain a copy of the resources
from /farm.json
. This makes it easy to get a taxonomy vocabulary vid
from the vocabularyname
without a request to the server.
With the vid
, I then make a request for any term that matches the vocabulary name
and term name
.
Some preliminary helper code that handles getting a taxonomy term from a name
specified in a CSV file:
def _get_farmos_taxonomy_term(self, name, taxonomy_name, create=False):
taxonomy_vid = self.farm_client_info.get('resources').get('taxonomy_term').get(taxonomy_name).get('vid')
taxonomy_vid = int(taxonomy_vid)
import base64 | |
from datetime import datetime | |
from farmOS import farmOS | |
from PIL import Image | |
from PIL.ExifTags import TAGS, GPSTAGS | |
hostname = "http://localhost" | |
username = "username" | |
password = "password" |
// This file should be in a ~/dist directory (can't show directories in gists) | |
// Field Module Code here |
/** | |
* Implements hook_init(). | |
* | |
* Performs a user login from the User ID of the Authentication Token. | |
*/ | |
function restws_oauth2_server_init() { | |
// Load the OAuth2 Server and Scope that are to be authenticated against. | |
$server_name = variable_get('restws_oauth2_server_name', FALSE); | |
$scope_name = variable_get('restws_oauth2_server_scope', FALSE); |
from farmosaggregator import Tracker | |
# Define a tracker that inherits from the Aggregator Tracker base class | |
class SpinachStudy(Tracker): | |
def __init__(self): | |
self.name = "Spinach Study Tracker" | |
self.description = "Aggregate spinach plantings and field data for analysis." | |
def get_farm_data(self, farmos_client): | |
# this list represents one farm's data for the study |