• Openweathermap

    From Mortifis@1:103/705 to All on Thu Aug 15 11:21:14 2019
    I noticed that since I updated on Aug 10th my openweathermap.ssjs is notpulling a json file but there is no log as to why. I tried jsexecopenweathermap.js but nothing is displayed. Any ideas?
    My doctor said I have the body of a 25 year old ... and the mind of a 10 :-/

    ---
    þ Synchronet þ AlleyCat! BBS - http://alleycat.synchro.net:81
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From echicken@1:103/705 to Mortifis on Thu Aug 15 10:45:36 2019
    Re: Openweathermap
    By: Mortifis to All on Thu Aug 15 2019 11:21:14

    I noticed that since I updated on Aug 10th my openweathermap.ssjs is not pulling a json file but there is no log as to why.

    For whatever reason I wrapped the entire working part of that script in a try ... catch
    block and didn't bother to log the error.

    You could at a log statement to line 21 in place of the "// meh" comment. Or you could just
    add "writeln(err)", and if there's an exception it'll be written into your sidebar. Not
    pretty, but for momentary debugging it'll do.

    If there's no debug output from that, then the next most likely things are:

    - Failure in geoip lookup (also a silent error)
    - Empty response from openweathermap

    I tried jsexec openweathermap.js but nothing is displayed. Any ideas?

    That's a library script, so it doesn't do anything on its own.

    You could make a test script such as:

    require('openweathermap.js', 'OpenWeatherMap');
    const owm = new OpenWeatherMap();
    const res = owm.call_api('weather', {
    units: 'metric',
    mode: 'html',
    q: 'Halifax,ca'
    }, true);
    writeln(JSON.stringify(res));

    This should dump an object to the console when run from jsexec, or produce an error.

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Mortifis@1:103/705 to echicken on Thu Aug 15 12:53:02 2019
    @VIA: ECBBS
    @MSGID: <5D557010.24065.sync_sys@bbs.electronicchicken.com>
    @REPLY: <5D556A5A.1188.dove-syncops@alleycat.synchro.net>
    @TZ: c12c
    Re: Openweathermap
    By: Mortifis to All on Thu Aug 15 2019 11:21:14

    I noticed that since I updated on Aug 10th my openweathermap.ssjs is not pulling a json file but there is no log as to why.

    For whatever reason I wrapped the entire working part of that script in a try ... catch
    block and didn't bother to log the error.

    You could at a log statement to line 21 in place of the "// meh" comment.
    Or you could just
    add "writeln(err)", and if there's an exception it'll be written into your sidebar. Not
    pretty, but for momentary debugging it'll do.

    Thank you very much, though I am not using webv4, I am using a hackery of my own css and nightshade :-| ... but for whatever reason it started working again
    after 5 days, not sure what was up with it, now if I can figure out where the new .json file is stored, it used to me /sbbs/ctrl ... or /sbbs/temp

    If there's no debug output from that, then the next most likely things are:

    - Failure in geoip lookup (also a silent error)
    - Empty response from openweathermap

    I tried jsexec openweathermap.js but nothing is displayed. Any ideas?

    That's a library script, so it doesn't do anything on its own.

    You could make a test script such as:

    require('openweathermap.js', 'OpenWeatherMap');
    const owm = new OpenWeatherMap();
    const res = owm.call_api('weather', {
    units: 'metric',
    mode: 'html',
    q: 'Halifax,ca'
    }, true);
    writeln(JSON.stringify(res));

    This should dump an object to the console when run from jsexec, or produce an error.

    Very nice, I'll give that a try thank you!



    My doctor said I have the body of a 25 year old ... and the mind of a 10 :-/

    ---
    þ Synchronet þ AlleyCat! BBS - http://alleycat.synchro.net:81
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Mortifis@1:103/705 to echicken on Thu Aug 15 20:33:46 2019
    owm is working great now, thank you, though, as I delve into all of the js/ssjs
    I realize I totally suck at script'n ... trying to get a 5 day forecast and calling writeln(owm.call_api('forecast', wq, true).data); renders a blank page ... so, not asking you to write the script, but where would I look to 'adjust' the output, or, eve, any ideas why calling 'forecast' render a blank page?

    Thanks, brah!



    My doctor said I have the body of a 25 year old ... and the mind of a 10 :-/

    ---
    þ Synchronet þ AlleyCat! BBS - http://alleycat.synchro.net:81
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From echicken@1:103/705 to Mortifis on Thu Aug 15 21:04:37 2019
    Re: Re: Openweathermap
    By: Mortifis to echicken on Thu Aug 15 2019 20:33:46

    forecast and calling writeln(owm.call_api('forecast', wq, true).data); renders a blank page ... so, not asking you to write the script, but
    where
    would I look to 'adjust' the output, or, eve, any ideas why calling 'forecast' render a blank page?

    What's the value of 'wq' in this instance?

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Mortifis@1:103/705 to echicken on Fri Aug 16 04:54:47 2019
    @VIA: ECBBS
    @MSGID: <5D560125.24070.sync_sys@bbs.electronicchicken.com>
    @REPLY: <5D55EBDA.1193.dove-syncops@alleycat.synchro.net>
    @TZ: c12c
    Re: Re: Openweathermap
    By: Mortifis to echicken on Thu Aug 15 2019 20:33:46

    forecast and calling writeln(owm.call_api('forecast', wq, true).data); renders a blank page ... so, not asking you to write the script, but where would I look to 'adjust' the output, or, even, any ideas why calling 'forecast' renders a blank page?

    What's the value of 'wq' in this instance?

    writeln(JSON.stringify(wq)); produces:

    {"units":"metric","mode":"html","lat":"44.6564","lon":"-63.5961"}

    lat/lon acquired via if(geoip.latitude && geoip.longitude)

    My doctor said I have the body of a 25 year old ... and the mind of a 10 :-/

    ---
    þ Synchronet þ AlleyCat! BBS - http://alleycat.synchro.net:81
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Mortifis@1:103/705 to echicken on Fri Aug 16 05:25:29 2019
    @VIA: ECBBS
    @MSGID: <5D560125.24070.sync_sys@bbs.electronicchicken.com>
    @REPLY: <5D55EBDA.1193.dove-syncops@alleycat.synchro.net>
    @TZ: c12c
    Re: Re: Openweathermap
    By: Mortifis to echicken on Thu Aug 15 2019 20:33:46

    forecast and calling writeln(owm.call_api('forecast', wq, true).data); renders a blank page ... so, not asking you to write the script, but where would I look to 'adjust' the output, or, eve, any ideas why calling 'forecast' render a blank page?

    What's the value of 'wq' in this instance?

    Ok, I see what's going on, the 5 day forecast is only mode json or xml, so omitting the mode I do get a response, just no pretty parsed contents LOL

    Thank you, EC

    My doctor said I have the body of a 25 year old ... and the mind of a 10 :-/

    ---
    þ Synchronet þ AlleyCat! BBS - http://alleycat.synchro.net:81
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From echicken@1:103/705 to Mortifis on Fri Aug 16 10:54:00 2019
    Re: Re: Openweathermap
    By: Mortifis to echicken on Fri Aug 16 2019 05:25:29

    Ok, I see what's going on, the 5 day forecast is only mode json or xml,
    so
    omitting the mode I do get a response, just no pretty parsed contents LOL

    That makes sense, then.

    So what you would want instead is something like:

    require('openweathermap.js', 'OpenWeatherMap');

    const owm = new OpenWeatherMap();
    const wq = { units: 'metric', mode: 'json', q: 'Halifax,ca' };
    const fc = owm.call_api('forecast', wq);

    writeln(fc.list[0]); // See what an 'fc.list' element looks like

    fc.list.forEach(function (e) {
    writeln(new Date(e.dt).toLocaleString());
    writeln(e.main.temp + ',' + e.main.temp_min + ',' + e.main.temp_max);
    writeln(e.weather[0].main + ', ' + e.weather[0].description);
    writeln(e.clouds.all + '% cloudy');
    });

    The above should work properly with jsexec. Easily adapted to run on your webserver, using geoip and wrapping stuff in HTML (I would suggest an XJS file instead of SSJS).

    ---
    echicken
    electronic chicken bbs - bbs.electronicchicken.com
    þ Synchronet þ electronic chicken bbs - bbs.electronicchicken.com
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Mortifis@1:103/705 to echicken on Sat Aug 17 20:24:06 2019
    @VIA: ECBBS
    @MSGID: <5D56C388.24076.sync_sys@bbs.electronicchicken.com>
    @REPLY: <5D566879.1198.dove-syncops@alleycat.synchro.net>
    @TZ: c12c
    Re: Re: Openweathermap
    By: Mortifis to echicken on Fri Aug 16 2019 05:25:29

    Ok, I see what's going on, the 5 day forecast is only mode json or
    xml,
    so omitting the mode I do get a response, just no pretty parsed contents LOL

    That makes sense, then.

    So what you would want instead is something like:

    require('openweathermap.js', 'OpenWeatherMap');

    const owm = new OpenWeatherMap();
    const wq = { units: 'metric', mode: 'json', q: 'Halifax,ca' };
    const fc = owm.call_api('forecast', wq);

    writeln(fc.list[0]); // See what an 'fc.list' element looks like

    fc.list.forEach(function (e) {
    writeln(new Date(e.dt).toLocaleString());
    writeln(e.main.temp + ',' + e.main.temp_min + ',' + e.main.temp_max);
    writeln(e.weather[0].main + ', ' + e.weather[0].description);
    writeln(e.clouds.all + '% cloudy');
    });

    The above should work properly with jsexec. Easily adapted to run on your webserver, using geoip and wrapping stuff in HTML (I would suggest an XJS file instead of SSJS).

    Thank you very much, I appreciate it, now back to another night of hippie/old fart rocker music festival in West Chezzetcook, NS called ClamStock LOL


    Cheers



    My doctor said I have the body of a 25 year old ... and the mind of a 10 :-/

    ---
    þ Synchronet þ AlleyCat! BBS - http://alleycat.synchro.net:81
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)