Created
November 5, 2019 19:23
-
-
Save paul121/e2a769e56b77b9ea9bc5e6c9bd3cae9d to your computer and use it in GitHub Desktop.
Generate random egg harvest values for a date range
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import date, timedelta | |
import random | |
import logging | |
from farmOS import farmOS | |
f = farmOS('tilth2019.farmos.net', 'paul', 'password') | |
log_name = 'Egg Collection' | |
log_type = 'farm_harvest' | |
log_asset = [{'id': 9}] | |
quantity_template = [{ | |
'measure': 'count', | |
'value': 0, | |
'unit': {'id': 85} | |
}] | |
log_done = 1 | |
start_date = date(2019, 10, 15) | |
end_date = date(2019, 11, 9) | |
delta = timedelta(days=1) | |
last_count = 800 | |
while start_date <= end_date: | |
new_count = last_count + int(last_count * random.gauss(0, .02)) | |
last_count = new_count | |
quantity = quantity_template | |
quantity[0]['value'] = new_count | |
log = { | |
'name': log_name, | |
'type': log_type, | |
'asset': log_asset, | |
'quantity': quantity, | |
'timestamp': start_date.strftime("%s"), | |
'done': 1 | |
} | |
f.log.send(log) | |
logging.info("send value " + str(new_count)) | |
start_date = start_date + delta |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment