poobrains/fill.py

197 lines
5.0 KiB
Python
Raw Permalink Normal View History

import math
import random
import example
u = example.poobrains.auth.User.load('root')
g = example.poobrains.auth.Group.load('administrators')
2017-11-14 17:37:40 +00:00
2017-12-13 00:20:20 +00:00
def news():
2017-11-14 17:37:40 +00:00
for i in range(0, 100):
n = example.News()
n.name = "test-%d" % i
n.title = "Test #%d" % i
n.text = "Blargh."
n.owner = u
n.group = g
n.save()
print("Saved News test-%d" % i)
2017-11-14 17:37:40 +00:00
2017-12-13 00:20:20 +00:00
def datasets():
2017-11-14 17:37:40 +00:00
2019-03-04 14:10:14 +00:00
sine = example.poobrains.svg.StoredDataset()
2017-11-14 17:37:40 +00:00
sine.owner = u
sine.group = g
sine.name = 'sine'
sine.title = 'Give me a sine'
sine.description = 'And Eris spoke "Okay, I guess."'
sine.label_x = 'Sine X'
sine.label_y = 'Sine Y'
sine.save()
2019-03-04 14:10:14 +00:00
fucksgiven = example.poobrains.svg.StoredDataset()
2017-11-14 17:37:40 +00:00
fucksgiven.owner = u
fucksgiven.group = g
fucksgiven.name = 'fucksgiven'
fucksgiven.title = 'Fucks given'
fucksgiven.description = "Fucks given over time"
fucksgiven.label_x = "Time"
fucksgiven.label_y = "Fucks given"
fucksgiven.save()
sine_steps = 33
2017-11-14 17:37:40 +00:00
for i in range(0,sine_steps):
2019-03-04 14:10:14 +00:00
dp = example.poobrains.svg.StoredDatapoint()
2017-11-14 17:37:40 +00:00
dp.dataset = sine
dp.owner = u
dp.group = g
2017-11-14 17:37:40 +00:00
dp.x = i
dp.y = math.sin(i/float(sine_steps-1) * 2 * math.pi)
2017-11-14 17:37:40 +00:00
dp.save(force_insert=True)
2019-03-04 14:10:14 +00:00
fuck = example.poobrains.svg.StoredDatapoint()
2017-11-14 17:37:40 +00:00
fuck.dataset = fucksgiven
fuck.owner = u
fuck.group = g
2017-11-14 17:37:40 +00:00
fuck.x = i
fuck.y = random.randint(-100,100) / 100.0
if fuck.y < 0:
fuck.error_upper = abs(fuck.y)
else:
fuck.error_lower = abs(fuck.y)
2017-11-14 17:37:40 +00:00
fuck.save(force_insert=True)
2019-03-04 14:10:14 +00:00
cont_a = example.poobrains.svg.StoredDataset()
2017-12-30 00:20:41 +00:00
cont_a.owner = u
cont_a.group = g
cont_a.name = 'cont_a'
cont_a.title = 'Continued thingie A'
cont_a.description = "The first of a two part plot thingamabob"
cont_a.label_x = "Florp"
cont_a.label_y = "Plonk"
cont_a.save()
for i in range(-23, 6):
2019-03-04 14:10:14 +00:00
dp = example.poobrains.svg.StoredDatapoint()
2017-12-30 00:20:41 +00:00
dp.dataset = cont_a
dp.owner = u
dp.group = g
dp.x = i
dp.y = random.random()
dp.save(force_insert=True)
2019-03-04 14:10:14 +00:00
cont_b = example.poobrains.svg.StoredDataset()
2017-12-30 00:20:41 +00:00
cont_b.owner = u
cont_b.group = g
cont_b.name = 'cont_b'
cont_b.title = 'Continued thingie B'
cont_b.description = "The **second** part of a two part plot thingamabob"
cont_b.label_x = "Florp"
cont_b.label_y = "Plonk"
cont_b.save()
for i in range(2, 24):
2019-03-04 14:10:14 +00:00
dp = example.poobrains.svg.StoredDatapoint()
2017-12-30 00:20:41 +00:00
dp.dataset = cont_b
dp.owner = u
dp.group = g
dp.x = i
dp.y = random.random()
dp.save(force_insert=True)
2017-11-14 17:37:40 +00:00
2017-12-13 00:20:20 +00:00
def map():
2017-11-14 17:37:40 +00:00
2019-03-04 14:10:14 +00:00
m = example.poobrains.svg.MapStoredDataset()
2017-11-14 17:37:40 +00:00
m.owner = u
m.group = g
2017-12-13 00:20:20 +00:00
m.name = 'grid'
m.title = 'Grid'
m.description = 'Markers every 30 degrees. Automatically created from fill.py.'
m.bbox_left = -180
m.bbox_right = 180
m.bbox_top = 75
m.bbox_bottom = -75
2017-11-14 17:37:40 +00:00
m.save()
2017-12-13 00:20:20 +00:00
for lat in range(-75, 76, 15):
for lon in range(-180, 181, 15):
2019-03-04 14:10:14 +00:00
dp = example.poobrains.svg.MapStoredDatapoint()
2017-11-14 17:37:40 +00:00
dp.owner = u
dp.group = g
dp.dataset = m
dp.title = 'Zee test at %d / %d' % (lat, lon)
dp.description = 'Test marker on map at %d %d' % (lat, lon)
dp.latitude = lat
dp.longitude = lon
dp.save(force_insert=True)
2017-12-13 00:20:20 +00:00
2019-03-04 14:10:14 +00:00
places = example.poobrains.svg.MapStoredDataset()
2017-12-13 00:20:20 +00:00
places.owner = u
places.group = g
places.name = 'places'
places.title = 'Some Places'
2019-03-04 14:10:14 +00:00
places.description = 'Sample MapStoredDataset from fill.py'
places.bbox_left = -180
places.bbox_right = 180
places.bbox_top = 75
places.bbox_bottom = -75
2017-12-13 00:20:20 +00:00
places.save()
2019-03-04 14:10:14 +00:00
dp = example.poobrains.svg.MapStoredDatapoint()
2017-12-13 00:20:20 +00:00
dp.owner = u
dp.group = g
dp.dataset = places
dp.latitude = 0
dp.longitude = 0
dp.title = 'Center'
dp.description = 'Center of the map at 0,0. Near the african west coast.'
dp.save(force_insert=True)
2019-03-04 14:10:14 +00:00
dp = example.poobrains.svg.MapStoredDatapoint()
2017-12-13 00:20:20 +00:00
dp.owner = u
dp.group = g
dp.dataset = places
dp.latitude = 51.34897
dp.longitude = 12.37115
dp.title = 'Leipzig'
dp.description = 'Where 34C3 will be'
dp.save(force_insert=True)
2019-03-04 14:10:14 +00:00
dp = example.poobrains.svg.MapStoredDatapoint()
2017-12-13 00:20:20 +00:00
dp.owner = u
dp.group = g
dp.dataset = places
dp.latitude = 8.0817
dp.longitude = 77.5497
dp.title = 'Kanyakumari'
dp.description = 'Southernmost town of mainland India'
dp.save(force_insert=True)
2019-03-04 14:10:14 +00:00
dp = example.poobrains.svg.MapStoredDatapoint()
2017-12-13 00:20:20 +00:00
dp.owner = u
dp.group = g
dp.dataset = places
dp.latitude = -41.86385
dp.longitude = 146.73089
dp.title = 'Great Lake'
dp.description = '"Great Lake" in Tansania (or rather a tiny island on it)'
dp.save(force_insert=True)
if __name__ == '__main__':
news()
datasets()
map()