< 192019-08-20⋎21 >

farmOS (farmos.org) is a free and open source, web-based farm management system. User guide: farmos.org/guide/ - Feature requests and bug reports: github.com/farmOS/farmOS/issuesSet by ChanServ on 2018-08-16 at 14:32
01:50*JustTB has quit (Ping timeout: 272 seconds)
02:28*JustTB has joined
05:17*JustTB has quit (Quit: Leaving.)
07:33skipper_is[m]Ah cheers for that, it is similar in a way to my egg one, just that my posting didn't work... I'll try again with the new library I'm writing, and figure out what is going wrong where.. if it still does, just getting cookies and auth tokens to work at the moment, it is showing success! I have aquired the cookies from the request.....
08:03*JustTB has joined
08:11*JustTB has quit (Ping timeout: 258 seconds)
08:28*JustTB has joined
08:43*JustTB has quit (Quit: Leaving.)
09:18*sent a long message: < matrix.org/_matrix/media/v1/download/mat >
12:46skipper_is[m]Cannot seem to get the /user/login to work...
12:47skipper_is[m]posting {"name":"blablabla","pass":asdasd","form_id":"user_login"} to /user/login
12:47skipper_is[m]Not getting redirected to the actual login
12:48skipper_is[m]Just getting shunted back to the login page
12:48mstenta[m]Are you getting 403?
12:48skipper_is[m]Nope, just a boring 200
12:48mstenta[m]The login page is not like the other endpoints, it doesn't accept json, it is a form that needs to be submitted
12:49skipper_is[m]Looked like it was text/plain encoded in farmOS.py
12:49mstenta[m]Take a look at how farmOS.py does it
12:49skipper_is[m]Yea, thats what I was working off
12:49mstenta[m]Oh ok
12:49mstenta[m]Sorry not at my computer
12:49*sent a long message: < matrix.org/_matrix/media/v1/download/mat >
12:49mstenta[m]Ok I think that looks good
12:50skipper_is[m]is the line of code, if contains 'data' send data:{name etc etc}
12:50mstenta[m]If you're getting 200 then maybe it worked? Can you access other pages?
12:50skipper_is[m]I'm just trying to get the damned cookie XD
12:50mstenta[m]Oh
12:50skipper_is[m]All this for a biscuit
12:51mstenta[m]Maybe that's the problem... The form will redirect to /user if it's successful
12:51mstenta[m]But if you don't have the cookie stored then it would show the login again
12:51mstenta[m]I think
12:52skipper_is[m]It should... should... give me a 302 status, the Set-Cookie, and the redirect under Location
12:52skipper_is[m]I could probably just do it through form-urlencoded
12:53skipper_is[m]But I'm not so keen on that method....
13:01mstenta[m]Oh I thought that's what farmOS.py was doing
13:02mstenta[m]I think the "data" piece actually gets put into form-urlencode
13:02mstenta[m]Via the Python requests lovely
13:02mstenta[m]Library*
13:03skipper_is[m]XD
13:03mstenta[m]Double check that though I'm not sure
13:03skipper_is[m]I've been trying to pass some sort of JSON mash up to see if it works XD
13:04skipper_is[m]I think you might be right actually XD
13:05skipper_is[m]form-irlencoded worked first time... Why didn't I use that an hour ago..
13:05skipper_is[m]*urlencoded
13:05mstenta[m]Hooray! :-D
13:15skipper_is[m]I am so glad my FarmOS is self hosted, I'd have an angry admin thinking someone was trying to hack in otherwise... so many failed attempts XD
13:16mstenta[m]Ha
13:51skipper_is[m]github.com/Skipper-is/micropython-farmOS
13:51skipper_is[m] I'm going to make it public, at the moment, it does..literally nothing
13:56paul121[m]Cool!
13:56skipper_is[m]I've just about manage to get the authentication to work...
13:56skipper_is[m]...just
13:57skipper_is[m]With some duct tape and glue
14:05mstenta[m]skipper_is: awesome!
14:59*farmBOT has joined
15:00skipper_is[m]farmBOT needs to sort his phobia of emojis out..
15:01*farmBOT has joined
15:02mstenta[m]hey cut that out :-P
15:02mstenta[m]stop picking on farmBOT
16:59skipper_is[m]For getting individual logs.... Lets say a harvest log, is the request farmOS/log/23.json?
16:59mstenta[m]yep!
16:59mstenta[m]`/log/23.json`
16:59*sent a long message: < matrix.org/_matrix/media/v1/download/mat >
16:59skipper_is[m]farmOS/log/23.json
17:00skipper_is[m]I suspect it might be another PostGresql error
17:01*farmBOT has joined
17:01*sent a long message: < matrix.org/_matrix/media/v1/download/mat >
17:01mstenta[m]should be `/log/23.json`
17:01skipper_is[m]Well, my full path is home.skipper-iwb.co.uk/farmOS/log/69.jso
17:01mstenta[m]oh ok
17:02skipper_is[m]farmOS is my base directory
17:02mstenta[m]gotcha
17:02mstenta[m]ok well....
17:02skipper_is[m]Other records work, just not logs
17:02skipper_is[m]From the error invalid input syntax for integer:    &amp;quot;69.json&amp;quot;
17:02skipper_is[m]It is saying that "69" isn't correct, because it is in quotes..
17:02skipper_is[m]Maybe?
17:02mstenta[m]weird
17:03mstenta[m]where is 69 coming from?
17:03skipper_is[m]Oh I tried a different log
17:03skipper_is[m]sorry
17:03mstenta[m]oh ok
17:03skipper_is[m]They both didnt work
17:03skipper_is[m]same error
17:03mstenta[m]same thing if you go to that path directly in your browser?
17:03mstenta[m]but assets work?
17:04skipper_is[m]Yup, leme try assets
17:04mstenta[m]so.... this is strange because: the other issues with postrgresql involved complex queries for finding asset location or group membership, so it made sense that we would run into issues
17:05mstenta[m]with logs, it should be a simple query
17:05mstenta[m]nothing extra is being added on to logs
17:05mstenta[m]as far as i can remember
17:05mstenta[m]can you try a few different logs with different amounts of info in them?
17:05skipper_is[m]farm_asset/8.json
17:05skipper_is[m] is fine
17:05mstenta[m]i wonder if it's specific to the logs you tried
17:05skipper_is[m]23 was quite a big one, 69 was just collected 10 eggs
17:05mstenta[m]eg: try making an observation log with just a title
17:06mstenta[m]no quantities or anything else
17:06mstenta[m]just to see
17:06skipper_is[m]I'll try one no
17:06skipper_is[m]now
17:06skipper_is[m]ERROR: invalid input syntax for integer:    &amp;quot;70.json&amp;quot;
17:07skipper_is[m] "id": "70", "name": "Hello World", "type": "farm_observation",
17:07skipper_is[m]That was very simple that one
17:08skipper_is[m]Supper time, I'll have a bit more of a poke later
17:08mstenta[m]ok thanks!
17:08mstenta[m]strange...
17:16skipper_is[m]But I do think it is trying to select by ID and putting " around an int
17:17skipper_is[m]Which PostGresql doesn't like, maybe mysql doesn't mind?
17:17mstenta[m]i'm loading up my pgsql env to test
17:17mstenta[m]yup. same error
17:18mstenta[m]alright whelp... wanna submit a bug report? :-)
17:18mstenta[m]you're on a roll finding the postgresql issues haha
17:18mstenta[m](thank you for that)
17:18mstenta[m]i'll try to take a quick look...
17:20skipper_is[m]Yea, I'll flag it up in a minute (well, 30-45mins) putting my toddler to bed
17:20mstenta[m]:-)
17:21mstenta[m](I'll be doing that myself in ~6 hours)
17:21mstenta[m]Here's the error I'm seeing in `/admin/reports/dblog`:
17:21*sent a long message: < matrix.org/_matrix/media/v1/download/mat >
17:21mstenta[m](a little more readable)
17:21mstenta[m]> `invalid input syntax for integer: "11.json"`
17:22mstenta[m]weird... seems to be passing `11.json` to the query when it should only pass `11`
17:28skipper_is[m]Oo, that is odd
17:28skipper_is[m]But not for mysql?
17:28mstenta[m]Very strange that it's not happening for farm assets
17:29skipper_is[m]Yea...
17:29mstenta[m]when i created the `farm_asset` module, i copied and modified the `log` module - so they are VERY nearly the same
17:29mstenta[m]now i'm curious...
17:29mstenta[m]firing up the debugger
17:34mstenta[m]ok i'm on the trail...
17:36skipper_is[m]Toddler kicked me out of the room as he wanted a poo, so I've submitted the issue
17:37skipper_is[m]GitHub doesn't appear to be very mobile friendly...
17:37mstenta[m]lol
17:37mstenta[m]thanks! i'll pick it up in that issue...
17:42skipper_is[m]Any joy with the area issue in PostGresql?
17:43skipper_is[m]github.com/farmOS/farmOS/issues/193
17:44mstenta[m]Haven't had a chance :-(
17:45skipper_is[m]No worries, your little patch worked for noe
17:45mstenta[m]But I did add a comment for how you can bypass it in the meantime
17:45skipper_is[m]Now
17:45mstenta[m]Oh good
17:45mstenta[m]Yea... that issue just requires a lot of brain power to get back into too
17:46skipper_is[m]I'll be rolling it out to my new team in a week and a half, so it is awesome that the FarmOS.app works
17:46skipper_is[m]So no more "made a cup of tea" logs for me :)
17:47mstenta[m]Great!!
18:53skipper_is[m]For additional pages of data, ( I can't test this as I don't have that much data...) do you just add &page=#?
18:53skipper_is[m]farm_asset.json?type=equipment&page=1
18:53skipper_is[m]Like this
18:53mstenta[m]yep
18:54mstenta[m]there will be 100 per page
18:54skipper_is[m]How many logs per page?
18:54skipper_is[m]....Snap
18:56mstenta[m]skipper_is: Interesting... I just tested the `/log/[id].json` on MySQL and it *also* passes `[id].json` into the database query.....
18:56mstenta[m]But for whatever reason, MySQL accepts that
18:57mstenta[m]So it's not a postgres specific issue... it's just the postgres refuses to work with it (rightly so!)
18:58mstenta[m]Now I just need to figure out why it's including ".json" in the ID for logs
18:58skipper_is[m]I wonder whether MySQL's int() function (or whatever it has) is like my egg logger one... Just add up all the numbers and disregard the rest...
18:59skipper_is[m]Can you send a request of /log/1.json2 and see what happens?
18:59skipper_is[m]or 1a2.json
18:59mstenta[m]Wow that is crazy... I can run this query in MySQL and it works:
18:59mstenta[m]`SELECT * FROM log WHERE id = '3.json';`
18:59mstenta[m]wtf
19:00mstenta[m]So does this:
19:00mstenta[m]`SELECT * FROM log WHERE id = '3.jsonfdsfsdfsdfasddfsdfsdfsdfsd';`
19:00mstenta[m](both return log 3)
19:01skipper_is[m]PGAdmin isn't working for me at the moment...
19:01mstenta[m]skipper_is: you seem to have a knack for finding really deep bugs :-P
19:01skipper_is[m]XD
19:02skipper_is[m]ERROR: invalid input syntax for integer: "5.json"
19:02skipper_is[m]LINE 1: SELECT * FROM public.log WHERE id = '5.json'
19:02skipper_is[m]Nope, PG doesnt like it
19:02mstenta[m]yup, so that's why we see the error only on pgsql sites
19:02mstenta[m]pgsql is more strict
19:03mstenta[m](or rather... perfectly sane... it's insane that mysql accepts "5.json" and converts it to 5)
19:03mstenta[m]so now i just need to figure out WHY it's being set to "5.json" and not "5" before it gets passed into the query
19:04mstenta[m]i think it has something to do with the way the `restws` module alters the `log` module's menu router items
19:04skipper_is[m]Did you try mixing numbers and letters mid stream?
19:04mstenta[m]but it may actually be an issue in the `log` module code
19:04skipper_is[m]*string
19:05mstenta[m]`SELECT * FROM log WHERE id = 'x3';` returns no results
19:05skipper_is[m]Aww :(
19:05mstenta[m]`SELECT * FROM log WHERE id = '3x';` returns log 3
19:05skipper_is[m]So it is only the first part
19:06mstenta[m]yea weird
19:06mstenta[m]anyway... i'm debugging the menu router item now
19:08skipper_is[m]... urequests didn't have a params function, so now I have to write a new one of those too.... Is it usually just ?bundle= and ?page= ?
19:08skipper_is[m]or ?bundle=&page= if you want to run them together, or are there a load more I've missed?
19:08skipper_is[m]Oh type as well...
19:09skipper_is[m]Oh.. you can select any variable as a parameter...
19:09mstenta[m]there's a bunch
19:10mstenta[m]yea
19:10mstenta[m]`page` might be the only one unique to the JSON endpoints
19:10skipper_is[m]farm_asset.json has a bunch...
19:11skipper_is[m]Such a shame I can't use wildcards in params though
19:11mstenta[m]This documents most of them I think: farmos.org/development/api/
19:12skipper_is[m]Yea, it is most of the JSON attributes
19:13mstenta[m]yea
19:13skipper_is[m]So I will have to write a param handler, rather than just implement one or two
19:13mstenta[m]the only ones that won't work are the field collections i believe
19:13mstenta[m](for filtering)
19:13skipper_is[m]I can just append them to the URL...
19:14skipper_is[m]Well... That is where they go..
19:31skipper_is[m]I'll implement the Accept: application/json in micropython_farmOS
19:43mstenta[m]skipper_is: ok... but i think i found the core issue
19:44mstenta[m]Can you try something?
19:46mstenta[m]This will fix it:
19:46mstenta[m]Edit `[webroot]/profiles/farm/modules/contrib/entity/includes/entity.controller.inc`
19:47mstenta[m]Go to line 243
19:47mstenta[m]And insert this:
19:47*sent a long message: < matrix.org/_matrix/media/v1/download/mat >
19:47mstenta[m]In context it should look like:
19:47*sent a long message: < matrix.org/_matrix/media/v1/download/mat >
19:50skipper_is[m]..just buying a fridge..one moment
19:50mstenta[m]haha
19:51*JustTB has joined
20:08skipper_is[m]I sincerely hope it worked, because it has been a long time since I ran a backup
20:09skipper_is[m]Indeed it worked
20:09skipper_is[m]I'll still use the header for micropython-farmos
20:09mstenta[m]Great!
20:12skipper_is[m]Keep getting these notices:
20:12skipper_is[m]Notice: Trying to get property of non-object in restws_file_restws_request_alter() (line 30 of /var/www/html/farmOS/profiles/farm/modules/contrib/restws_file/restws_file.module).
20:12skipper_is[m]Rather annoying, but they're not stopping anything...
20:12skipper_is[m]Maybe restws is out of date..
20:12skipper_is[m]Last time I updated it though, it broke EVERYTHING
20:12mstenta[m]Nah that's an outstanding issue with the `restws_file` module
20:13mstenta[m]www.drupal.org/project/restws_file/issue
20:13mstenta[m]You can safely ignore it
20:13mstenta[m]It doesn't cause any harm, so I haven't bothered digging into it
20:13mstenta[m]Advice: disable logging to the screen
20:14mstenta[m]`/admin/config/development/logging`
20:14skipper_is[m]Yea, already done
20:16skipper_is[m]Woo, get log by ID works :)
20:17mstenta[m]Yay!
20:27*JustTB has quit (Ping timeout: 246 seconds)
20:28*JustTB has joined
20:30*JustTB has quit (Client Quit)
20:46*JustTB has joined
20:58skipper_is[m]github.com/Skipper-is/micropython_farmOS
20:58skipper_is[m]Well, that's it for tonight, but parts of it work well! Can send any request/post to farmOS, but you've got to set it up yourself, unless you want to get a log by ID...
20:58skipper_is[m]It has OAuth2 authentication, and a rewritten urequests that takes cookies and parameters
20:59skipper_is[m]And the readme is almost the same size as the module...
21:02*JustTB has quit (Quit: Leaving.)
21:05mstenta[m]Awesome!!!!
21:05mstenta[m]> It has OAuth2 authentication
21:05mstenta[m]Oh?? how does this work?
21:05mstenta[m]Do you have something installed on the server?
21:08*sent a long message: < matrix.org/_matrix/media/v1/download/mat >
21:09mstenta[m]I ask because we are hoping to implement OAuth2 in farmOS in the future
21:09mstenta[m]As an alternative to username/password API authentication
21:10mstenta[m]const layers = map.getLayers().getArray()[0].getLayers();
21:10mstenta[m]www.drupal.org/project/farm/issues/30342

< 192019-08-20⋏21 >