Skip to content

Instantly share code, notes, and snippets.

View paul121's full-sized avatar

Paul Weidner paul121

View GitHub Profile

Setup client

# !pip install farmOS==1.0.0b3
from farmOS import farmOS
hostname="http://localhost"
client = farmOS(hostname, client_id="farm", scope="farm_manager")
current_token = client.authorize()
@paul121
paul121 / harvest_import.py
Created August 5, 2022 21:13
GSOC Harvest data example
import os
import csv
import argparse
import logging
from datetime import datetime
from time import time
from farmOS import farmOS
### Setup
@paul121
paul121 / asset_dedup.php
Last active August 17, 2022 23:54
Script for detecting duplicate assets & merging log records
<?php
use Drupal\asset\Entity\Asset;
use Drupal\log\Entity\Log;
// Debug flag, leave TRUE to not perform any actions.
$debug = TRUE;
#$debug = FALSE;
// Only query assets created by this username.
@paul121
paul121 / asset_merge.php
Created August 18, 2022 18:25
Script for merging logs from two assets
<?php
use Drupal\asset\Entity\Asset;
use Drupal\log\Entity\Log;
// Debug flag, leave TRUE to not perform any actions.
$debug = TRUE;
#$debug = FALSE;
// Hosts to to not run this script on.
@paul121
paul121 / template-definition.yaml
Last active October 31, 2022 20:06
farmOS platformsh template
# Platform.sh Project Initialization Template
#
# This file defines settings and workflow modifications that allow a git
# repository to be deployed to Platform.sh and its white-label partners. A
# project template can be a fully functioning ready-made application or a
# quick-start point for custom development work.
#
# It contains elements that affect the behaviour upon the initialisation of
# a new project (for example minimal plan sizes) as well as elements that
# allow Platform.sh to present it in a user interface (such as the description
@paul121
paul121 / data.json
Last active March 12, 2024 00:58
LinkML Project Posts
{
"title": "Post title",
"comment": "Post description",
"files": [
{
"iri": "regen:1111.png",
"name": "Image file name",
"description": "Image description",
"credit": "Paul",
"location": {"wkt": "POINT(1 2)"}
@paul121
paul121 / plan-log-quantities.py
Created April 18, 2024 03:40
Experiment plan log quantity export
import asyncio
from collections import ChainMap
import csv
import time
from farmOS import AsyncFarmClient
from httpx_auth import OAuth2ResourceOwnerPasswordCredentials
from httpx import Limits
hostname = "https://rothamstedfarm.farmos.net"