Trixology

WeatherCat => WeatherCat General Discussion => Topic started by: xairbusdriver on January 06, 2016, 09:56:17 PM

Title: For those with no patience...
Post by: xairbusdriver on January 06, 2016, 09:56:17 PM
I got tired of seeing "Rain: 0.00 in" along with "Rain rate: 0.00 in" for this day (Current Conditions)/week (Weekly stats). So I checked to see if a meager bit of php could be added to check for anything more than 0 before printing the amount. Basically, if rain amount is > zero, print the amount (and the rate), else, don't waste electrons on printing "0.00".

Of course, we're supposed to get some rain tonight, so I can't double-check that things will work correctly after that...

Still, it's good to know that we can take the inputs from WC and use them for just about anything we want, without reverting to javascript (which is often blocked) or even AppleScript. [cheer]

The following is in a small table on my index page (Current Conditions) (http://mid-southweather.com/index.html):
Code: [Select]
<?php
$rainstring 
"STAT$RAIN:TOTAL:TODAY$ RAINUNITS$";
$rain chop($rainstring,"in");
$amount 0.01;

if (
$rain $amount) {
echo  '<td class="right">No rain during this period.</td>';
} else {
echo  '<tr>
    <td class="right">Total Rain:</td>
    <td class="left">' 
$rainstring '</td>
       </tr>
       <tr>
    <td class="right">Rain Rate:</td>
    <td class="left">CR$</td>
       </tr>'
;
}
?>
Nothing earth-shaking here! [blush] I might find more use by making a "0" wind indicate "Calm" (with or without a direction [lol] ).
Title: Re: For those with no patience...
Post by: TechnoMonkey on January 07, 2016, 05:52:42 AM
The wind speed took a bit of work, bit I got it.  I am thinking of changing all the wind speed to this chart.

http://www.weather.gov/media/iwx/webpages/skywarn/Beaufort_Wind_Chart.pdf (http://www.weather.gov/media/iwx/webpages/skywarn/Beaufort_Wind_Chart.pdf)

www.technomonkeys.com (http://www.technomonkeys.com)

Here it is.  I jacked up my hourly changes while debugging.

Don't know if it works yet.  The winds are calm for tonight.  Now I need to change the wind direction to some null when it is calm.

Code: [Select]
<?php
$light_air "1";
$light_breeze "4";
$gentle_breeze "8";
$moderate_breeze "14";
$fresh_breeze "19";
$strong_breeze "25";
$near_gale "32";
$severe_gale "47";
$storm "55";
$violent_storm "64";
$hurricane "74";
$windstring "CW$";
$pos strpos($windstring,'MPH');
$wind substr($windstring0$pos);

if ($wind $light_air)
{
echo "Calm";
}
else if ($wind $light_breeze)
{
echo "Light air";
}
else if ($wind $gentle_breeze)
{
echo "Light breeze";
}
else if ($wind $moderate_breeze)
{
echo "Gentle breeze ";
}
else if ($wind $fresh_breeze)
{
echo "Moderate breeze";
}
else if ($wind $strong_breeze)
{
echo "Fresh breeze";
}
else if ($wind $near_gale)
{
echo "Strong breeze";
}
else if ($wind $severe_gale)
{
echo "Near gale";
}
else if ($wind $storm)
{
echo "Severe gale";
}
else if ($wind $violent_storm)
{
echo "Storm";
}
else if ($wind $hurricane)
{
echo "Violent storm";
}
else
{
echo "Hurricane";
}
?>

Title: Re: For those with no patience...
Post by: xairbusdriver on January 07, 2016, 03:48:05 PM
Nice improvement! [tup]

I was thinking about something similar, using 'case' statements. ;) You could also have a small, horizontal image, with color coding, displayed along with the Beaufort text. OTOH, not sure anyone around our rather land-locked area would know what that scale means. [blush] We'd probably get more benefit from words like: "Get the clothes off the clothes line", "Nailed down objects may move", "Put more concrete blocks on the icebox on the porch", "Bring in the chickens, NOW".

If I did write some code, I'd probably not bother with "Hurricane". Even those back in the farthest hills would already know that! [rolleyes2] Most people around here have never heard of any kind of "Gale", either... unless that's part of the name of one of their lady friends... Barbara Gail, Honey Gail, Nite N. Gale (spellin' ain't always cornsis tent, neither!  [blush]

Since most of my data is displayed as a simple two-column table, I simply left out the 'direction' row when the wind value was zero/calm. That row is only inserted when the wind exists. Same for the 'rain rate' row; if there has been no rain, there's probably not much of a 'rate'! :o
Title: Re: For those with no patience...
Post by: xairbusdriver on January 12, 2016, 12:23:20 AM
After being shamed by an AppleScript guru (who shall remain unnamed) living on the Left Coast, I decided to tackle the task of including the run time of the WC computer. Stu already makes including the elapsed running time of WC this trivial. I also hoped to learn something along the way. I have accomplished my goal but I'm not sure I learned anything particularly useful.

The 4 easy steps:In summary, all you need is AppleScript, Terminal (to access Unix underpinnings of the OS), WeatherCat (does the uploading), and a bit of PHP on the web page (to display the info). PHP, Terminal, and AppleScript are "free", being included with every Apple computer. Most hosting services include PHP at no extra cost. The computer and WeatherCat are well worth their costs! [cheer]

I also decided to break down the WC app run time into its three parts to allow it to look similar to the newly created computer run time display. You can see this info outstandingly boring display on my ?Station (http://mid-southweather.com/station.html)" page. The computer run time updates every 15 minutes, the app's time updates with the timing set in WC (every two minutes, I think. Times are small now due to backing up the updating the OS, first to 10.10.5 and then to El Capitan .

After looking at the output, with very low times (less than an hour), I think I'll change the AS to do nothing more than upload the result of the Unix "uptime" command. (http://i1327.photobucket.com/albums/u666/xAirbusDriver/Thinking_zps6auyy8fj.gif) The length of the text is too variable and the string functions of PHP are so much more powerful. Oh well, I guess I did learn something... (http://i1327.photobucket.com/albums/u666/xAirbusDriver/dont_know_zpsqsndnufj.gif)
Title: Re: For those with no patience...
Post by: xairbusdriver on January 13, 2016, 12:15:23 AM
Working on making the computer uptime more robust and complete. I have completed some of the following testing using actual output from the "uptime" command.
Test strings:Many of these strings will be seen only for 60 seconds, but I detest texts such as "1 days", "1 minutes", etc. That always looks like Windos output!  [banghead] "If it takes longer, that's always my choice!" Or maybe it's; "If it's worth doing, it's worth doing the hard way!" [lol]
Title: Glutton for punishment . . . (Re: For those with no patience...)
Post by: elagache on January 13, 2016, 12:50:38 AM
Dear X-Air and WeatherCat Scripters, . . .

After being shamed by an AppleScript guru (who shall remain unnamed) living on the Left Coast, I decided to tackle the task of including the run time of the WC computer.

In the ominous voice of some game show from the 1950s . . .

 [wink] . . . . Remember, you are askin' for it!!! . . . .(http://www.canebas.org/WeatherCat/Forum_support_documents/Custom_emoticons/computer_sock_it_to_me.gif)

It turns out to be a lot harder to get than you would imagine.  Here is the "method" (subroutine to us FORTRAN types) that I use to get it:

Code: [Select]
on getMacUpTime()
-- - - - - -
-- Function to get time Macintosh has been running.
-- This information can be displayed on a website
-- for computers left running 24/7
-- - - - - -
local periodString, resultString, resultContent, bootTimeSeconds, UTCtimeSeconds, timeSeconds, uptimeSeconds
-- Set a default value in case there is a problem getting UNIX data
set periodString to "N/A"
try
-- Use system call to get boot time in UNIX seconds.
set resultString to do shell script "sysctl kern.boottime"
on error
-- If can't make UNIX call - return "N/A"
return (periodString)
end try

-- Breakup sysctl command to extract time.  Time is 4th item.
set resultContent to words of resultString
set bootTimeSeconds to item 4 of resultContent as integer

-- Get current time as universal time and adjust it to UNIX epoch
set UTCtimeSeconds to (current date) - (time to GMT)
set timeSeconds to UTCtimeSeconds - (date ("1/1/1970"))

-- Compute difference to get uptime in seconds, then covert to elapsed time.
set uptimeSeconds to timeSeconds - bootTimeSeconds
tell WChelperTools to set periodString to seconds2Elapse(uptimeSeconds, false)

return (periodString)

end getMacUpTime

To use it you would need my collection of helper routines as well.  If you want to dive into that let me know.  I could probably fish out the relevant bits.

Cheers, Edouard  [cheers1]
Title: Re: For those with no patience...
Post by: xairbusdriver on January 13, 2016, 02:30:49 AM
If it were simply the number of seconds since 1900 (or even 2000, when all computers were supposed to crash!), it would be a lot simpler! [tup] Unfortunately, the result of the "uptime" command is 'manipulated' from such a basic value before we get the result. If you look at the string offered by the OS, you'll note that there are not the 'standard' 3 sets of numbers Stu kindly provides for the WC uptime. [banghead]

Instead, there are a variety of formats. On each(?) hour, there will be a one or two digit value, along with the "hour/s" text, but there seems to be no "0 minutes". I think an exact 1 day result (again, with no hours or minutes) will simply appear as "1 day" (or X number of 'days'), instead of the WC 'standard' of "01:00:00". At least that's the formula for "1 hour", it is not presented as "1:00" or even as "00:01:00".

My solution is to chop the first part of any result, the local (24 hour) time,  and the "  up " from the original string. That leaves the 'uptime' as the next few characters. The job then becomes how many characters make up that days (if any), the hour (if any), and the minutes... (if any)! The rest of the text, I couldn't care less about.

So far, my line of attack has been to next find where the "," is and use that character position as the end of the needed text, with position of the "  up " as the beginning. This allows me to use the php 'explode' function (with ":" as the dellmiter) to create a one, two, or three part array depending on how many ":" are found. After that, it is basically testing for the integer values of the one, two, or three parts of the array.

For example, if the uptime is "3 mins", there will be only one item in the array; there is really nothing to 'explode', so "3 mins" gets written into array[0]. But now we have a number and some non-numeric characters! Fortunately, with only one array item, the length of the entire array is usually (so far!) much more than one would need for 1 or 2 numbers. This means it is possible to figure out what the actual number is. I haven't got to the case where there are only hours with no minutes, but I think the same format will appear; only one array[0] item which will most likely have something like " hour" sitting in it along with the actual number.

In the meantime, I'm watching the temperature change 1 degree an hour.  [lol2] Actually, I'm waiting to catch the mini at whole day intervals, along with single and double-digit hours (with no minutes), and single and double minutes (without hours) to verify the output.
Title: Goin' about it da' HARD way! (Re: For those with no patience...)
Post by: elagache on January 13, 2016, 10:23:27 PM
Dear X-Air and WeatherCat scripters,

I repeat from my previous post . . . . .

In the ominous voice of some game show from the 1950s . . .

 [wink] . . . . Remember, you are askin' for it!!! . . . .(http://www.canebas.org/WeatherCat/Forum_support_documents/Custom_emoticons/computer_sock_it_to_me.gif)

If it were simply the number of seconds since 1900 (or even 2000, when all computers were supposed to crash!), it would be a lot simpler! [tup]

Okay, I can't give you the time in seconds with one call, but you get getting the boot time in seconds as the 4th item of this UNIX call:

(http://www.canebas.org/misc/Voila_images/sysctrl%20kern.boottime%20call%202016-01-13.jpg)

In my AppleScript I get back that string, convert it into words (that end up in an array.)  Once I have that, I grab the 4th item of the array, convert the string to a number and finally convert the number in seconds back to an elapsed time string (using one of my subroutines in a shared library.)

I think it is truly easier do to it all in AppleScript . . . Especially since I already have!  [biggrin]

Cheers, Edouard  [cheers1]
Title: Re: For those with no patience...
Post by: xairbusdriver on January 14, 2016, 12:02:01 AM
I'm still watching/trapping the "uptime" output string to be sure I have as many of the possibilities as possible. I suspicion that the OS simply "memorizes" the start up time in seconds from some date (used to be 1900, back in the pre-X days, I think). Then it just computes the run time based on the current time in seconds and converts the difference just like you suggest. Unfortunately, it then reformats this into a slightly more human readable string. WC probably does the same thing but formats it in a more concise string.

My first assumption was that it would be similar to how Stu does it in WC; DD:HH:MM. However, it's beginning to look like it uses numbers (without leading zeros) and adds the "day(s)", "hour(s)", "minute(s)" text as needed. I am now waiting to get a more complete set of the possible strings before proceeding. It will be much easier to do the scripting if there is only one format to deal with. With the WC run time, all that is needed is the 'explode' function using the ":" to divide the WC tag into days, hours, and minutes.

I could use your AS to create my own version of what the OS is already doing. I'm sure there is a PHP script already available to do the same thing. But why buy a wheel when it's so much fun to re-invent one?! [banghead] [biggrin]

As I write...
Here is one cross-over point:
"... 1 day, 12 mins... " becomes " ...1 day, 1 hr... " 48 minutes later. Which becomes " ...1 day, 1 hr... " becomes " ...1 day,  1:01... " in another minute. What I need to know is to the output at the start of each new 24 hour period. Does it return to the " ...D days, M mins... " until the 25th hour and then to the " ...D days, H hours... " for the next 60 seconds and then reverts to the " ...D days, HH:MM... "? I wonder if I cane get my wife to run the little AS every 59 seconds, 1 hour, and once more a second later...    (http://i1327.photobucket.com/albums/u666/xAirbusDriver/Thinking_zps6auyy8fj.gif) (http://i1327.photobucket.com/albums/u666/xAirbusDriver/cheer2_zpsuajiabdd.gif)

OTOH, it just might be possible to find the various formatting possibilities at Apple.com, maybe even in the Man description of the "uptime" command. [banghead] (http://i1327.photobucket.com/albums/u666/xAirbusDriver/dont_know_zpsqsndnufj.gif)
Title: Three times a "charm" ? (Re: For those with no patience...)
Post by: elagache on January 15, 2016, 12:21:23 AM
Dear X-Air and WeatherCat wheel "reinventors" . . . . .

I could use your AS to create my own version of what the OS is already doing. I'm sure there is a PHP script already available to do the same thing. But why buy a wheel when it's so much fun to re-invent one?! [banghead] [biggrin]

As long as I'm on a winning streak . . . 

In the ominous voice of some game show from the 1950s . . .

 [wink] . . . . Remember, you are askin' for it!!! . . . .(http://www.canebas.org/WeatherCat/Forum_support_documents/Custom_emoticons/computer_sock_it_to_me.gif)

Still looks to me like you are goin' about it da' hard way! . . .   [banghead]

Cheers, Edouard  [cheers1]
Title: Re: For those with no patience...
Post by: xairbusdriver on January 15, 2016, 02:43:00 AM
Thanks Edouard, that "sysctl kern.boottime" was what I needed. I had found the current time in epoc seconds with "date +%s". But I needed the start up seconds to do the simple math!

I was a bit confused, at first, about your "4th item" in post #7 above. Now I get it! duh! [goofy]
Title: Ye' of little faith . . . . . (Re: For those with no patience...)
Post by: elagache on January 15, 2016, 10:21:18 PM
Dear X-Air and WeatherCat users . . . . of "little faith" . . . .

Thanks Edouard, that "sysctl kern.boottime" was what I needed. I had found the current time in epoc seconds with "date +%s". But I needed the start up seconds to do the simple math!

I was a bit confused, at first, about your "4th item" in post #7 above. Now I get it! duh! [goofy]

A a voice from a great movie that I have long since forgotten . . . . .

 . . . . Would I lie to you about a thing like this!! . . . .  [biggrin]

Cheers, Edouard  [cheers1]
Title: Re: For those with no patience...
Post by: xairbusdriver on January 16, 2016, 04:51:56 AM
I think it's working right now. A minor tweak to remove the leading zero on the day value. Whatever I did on The WC tag should work there, as well.

I've already shut down the access to my apple scripting mini, so I'll have to check to morrow. My question is if AS is still 32 bits? I had trouble getting it to write a "small" value to the text file without converting it to scientific notation. Setting a variable to the value 'as integer' or 'as text' still converted it. Even had trouble with 'as string', but by adding a tiny piece of text to it, it was forced to stay as i wanted it. I'll check the numbers tomorrow...
Title: Re: For those with no patience...
Post by: xairbusdriver on January 16, 2016, 05:39:01 PM
Here's a little script that demonstrates my question about how AS handles numbers as large as 327495:
-- Easier to work with epoc seconds (seconds since 1/1/1970) for all times
--
set now_time to do shell script "date +%s"
-- Output-> "1452896555"

set boot_time to do shell script "sysctl kern.boottime"
-- Output->"kern.boottime: { sec = 1452638263, usec = 0 } Tu..."

set run_time to (characters 24 thru 33 of boot_time) as text
-- or string (OK), can't use integer

set running_string to (now_time - run_time) as string
set running_text to running_string as text
set running_integer to running_string as integer

set result to "STRING -->" & running_string & "
TEXT -->" & running_text & "
INTEGER --> " & running_integer
As you'll see, the output is:It's probably my not 'casting' the variables correctly, along with my lack of AS knowledge! [blush]
Title: AppleScript handles this calculation correctly (Re: . . with no patience...)
Post by: elagache on January 16, 2016, 10:17:30 PM
Dear X-Air and WeatherCat fans of "big numbers" (besides powerball . . .  ;D )

I've already shut down the access to my apple scripting mini, so I'll have to check to morrow. My question is if AS is still 32 bits? I had trouble getting it to write a "small" value to the text file without converting it to scientific notation. Setting a variable to the value 'as integer' or 'as text' still converted it. Even had trouble with 'as string', but by adding a tiny piece of text to it, it was forced to stay as i wanted it. I'll check the numbers tomorrow...

I see what you are saying, but even with the conversion to scientific notation, AppleScript appears to preserve the data of integers that large.  I cut and paste my own solution into something that just runs from the Script Editor.  It is attached to this posting and the code is below:

Code: [Select]
-- *** Applescript code snippet to compute system uptime ***


-- Use system call to get boot time in UNIX seconds.
set resultString to do shell script "sysctl kern.boottime"


-- Breakup sysctl command to extract time.  Time is 4th item.
set resultContent to words of resultString
set bootTimeSeconds to item 4 of resultContent as integer

-- Get current time as universal time and adjust it to UNIX epoch
set UTCtimeSeconds to (current date) - (time to GMT)
set timeSeconds to UTCtimeSeconds - (date ("1/1/1970"))

-- Compute difference to get uptime in seconds, then covert to elapsed time.
set uptimeSeconds to timeSeconds - bootTimeSeconds
seconds2Elapse(uptimeSeconds, false)

on seconds2Elapse(totalSeconds, countSeconds)
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-- Function to convert elapsed seconds into a string
-- describing the amount of time that has passed in days,
-- hours, minutes, and optionally seconds
--
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-- 3600 seconds in an hour
-- 86400 seconds in a day

set elapsedTime to " "
set elapsedDays to 0
set elapsedhours to 0
set elapsedMinutes to 0
set elapsedSeconds to 0
set needComma to false

-- Catch limiting case of no elapsed time and return a "reasonable answer"
if (totalSeconds = 0) then
return ("0 seconds")
end if

-- Compute the number of days since event started.
if (totalSeconds is greater than 86400) then
set elapsedDays to totalSeconds div 86400
set totalSeconds to totalSeconds mod 86400
end if

-- Compute the number of hours rain has fallen (after removing days.)
if (totalSeconds is greater than 3600) then
set elapsedhours to totalSeconds div 3600
set totalSeconds to totalSeconds mod 3600
end if

-- Compute number of minutes rain has fallen (after removing hours)
if (totalSeconds is greater than 60) then
set elapsedMinutes to totalSeconds div 60
set elapsedSeconds to totalSeconds mod 60
else
-- if nothing else, their must be seconds

set elapsedSeconds to totalSeconds as integer

end if

-- If countSeconds flag is false ignore leftover seconds.
if (not countSeconds) then
set elapsedSeconds to 0
end if

-- Now create a human readable string by assembling the "pieces."
if (elapsedDays is greater than 0) then
set elapsedTime to elapsedTime & elapsedDays & " " & makePlural(elapsedDays, "day", "days")
set needComma to true
end if

if (elapsedhours is greater than 0) then
if (needComma) then
set elapsedTime to elapsedTime & ", "
end if
set elapsedTime to elapsedTime & elapsedhours & " " & makePlural(elapsedhours, "hour", "hours")
set needComma to true
end if

if (elapsedMinutes is greater than 0) then
if (needComma) then
set elapsedTime to elapsedTime & ", "
end if
set elapsedTime to elapsedTime & elapsedMinutes & " " & makePlural(elapsedMinutes, "minute", "minutes")
set needComma to true
end if

if (elapsedSeconds is greater than 0) then
if (needComma) then
set elapsedTime to elapsedTime & ", "
end if
set elapsedTime to elapsedTime & elapsedSeconds & " " & makePlural(elapsedSeconds, "second", "seconds")
end if

return (elapsedTime)
end seconds2Elapse

on makePlural(value, singularUnit, pluralUnit)
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-- Function to add an 's' to the end of text if the value is greater
-- than one.  It is a simple-minded way to get the tense of the unit
-- correct
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if ((value is greater than 1) or (value = 0)) then
return (localized string pluralUnit)
else
return (localized string singularUnit)
end if
end makePlural

If you load the script into the Script Editor it will run and give the correct value for uptime.

Cheers, Edouard
Title: Re: For those with no patience...
Post by: TechnoMonkey on January 18, 2016, 07:29:30 AM
This may be a tad bit more info than you want, but it does have uptime and last boot.

http://sourceforge.net/projects/phpsysinfo/ (http://sourceforge.net/projects/phpsysinfo/)
Title: Re: For those with no patience...
Post by: xairbusdriver on January 18, 2016, 06:59:59 PM
Thanks! I'll take a look/download that. I finally noticed late yesterday that the computer uptime was not changing, a subtle hint that it just might be broken? Nothing gets by me! [rolleyes2] What my script was actually doing was converting the small (relative to the boot time and the current time seconds) unix epoc seconds into a date which was never going to work for the days, since very few months have more than 31 of those! [citation needed] [banghead]

There are several answers to my quest, that almost provide what I need, and it is extremely frustrating. Only thing worse would be caving to Edouard's AS (assuming it does what I want: Up time in Days, Hours, Minutes). [blush] [lol]

In the meantime, I have an intermittent crashing of WC and email settings that didn't get corrected in WC when I had problems with Comcast a couple of weeks ago. Those problems may be easier to fix and are really more important, anyway. Time for lunch and a trip to Sam's...
Title: For someone with no patience . . . (Re: For those with no patience...)
Post by: elagache on January 18, 2016, 11:25:21 PM
Dear X-Air, TechnoMonkey, and WeatherCat scripters, .  .

Only thing worse would be caving to Edouard's AS (assuming it does what I want: Up time in Days, Hours, Minutes). [blush] [lol]

 ;) . . . Uh before you submit to a fate worse than death (or so it seems . . . )  did you actually download the script file from my previous posting, load it into your Script Editor, and press the run button just to see if - possibly, perhaps, maybe, could it be? - it actually does what you are looking for?  [biggrin]

Cheers, Edouard  [cheers1]
Title: Re: For those with no patience...
Post by: Steve on January 19, 2016, 03:37:06 AM
Mine has been working fine for several years and several OS versions. Se the link above my banner, below.

Thanks for all the work put into these, Edouard!
Title: Re: For those with no patience...
Post by: TechnoMonkey on January 19, 2016, 03:57:52 AM
OK. I give up. How do I get that script to run on the webpage?  I can run it from the script editor and from the terminal and as an app, but I have noy been able to get it to run in the webpage.  I am googled out.
Title: Re: For those with no patience...
Post by: xairbusdriver on January 19, 2016, 05:00:57 AM
I have not yet run the script, although I may have downloaded it!  :P So, I have no idea what it does.

As for using it in your wed page (assuming the script does not provide for that), you can add a few lines of AS to create a file with almost any text you want. I have mine now writing both the boot time and the current time (in epoc seconds) to a txt file on the Desktop. I then have that file listed in the "Additional Files" group in WC Prefs so it gets uploaded every 60 seconds. You can then use either an html file or a PHP script on the web page where it needs to display and have either method insert the data for you. The PHP can use a simple three statement Open, Read, Close combo, setting a variable or two or six(!) to whatever is in the txt file. All those steps are trivial, as I'm sure you know. The problem I'm having is getting the difference in seconds to compute the correct years, months, days, hours, minutes, and seconds. Actually, I don't bother with years, not expecting to run any of my computers that long! Nor am I going to bother with seconds. I have a logic error in the hours routine, the months (and even the years), days, and minutes work fine. I'm just a bit cross-eyed at the moment to see where the erer iz! [banghead] [lol]

I promise to take a look at Edouard's AS tomorrow... maybe.  :o
Title: Re: For those with no patience...
Post by: xairbusdriver on January 19, 2016, 11:31:48 PM
Quick! Look at the Station page and see the results of my 'patient' labors! [tup] Should you care, anyway. [rolleyes2] Right now the Software and the Computer times are almost identical because just before I could test the erer I found this morning, the power went out! Then my wife need transportation... finally after a few hours, things seem to be working. [computer] [cheer]

Even though I didn't use Edouardo's well documented AS, I couldn't have made this work without his sysctl kern.boottime shell command!

Now we have a freezing rain, sleet, and snow forecast. [rolleyes2] That almost always means downed power lines, usually by breaking limbs. Fortunately, I got our two ventless gas logs checked out with the power outage earlier today. At least we'll have heat and hot water in the house!  ;D
Title: Need to run the whole package (Re: For those with no patience...)
Post by: elagache on January 20, 2016, 12:01:44 AM
Dear Steve, TechnoMonkey, X-Air, and WeatherCat scripters,

Thanks for all the work put into these, Edouard!

You're welcome!  :)

OK. I give up. How do I get that script to run on the webpage?  I can run it from the script editor and from the terminal and as an app, but I have noy been able to get it to run in the webpage.  I am googled out.

You need to run the entire package of AppleScripts in order to get this data on a webpage.  Here is the link to the package:

http://athena.trixology.com/index.php?topic=1039.0 (http://athena.trixology.com/index.php?topic=1039.0)

The way it works is that the script WC Status Growler collects that information as part of its operation and then it hands off the data to WC AppleScript Tags Processor  The WC AppleScript Tags Processor script basically replicates how WeatherCat substitutes values for web tags. 

All these scripts are alas now many years old having been last developed under OS 10.6.  People who installed them back then have been able to get them to work with new versions of OS X, but it appears that Apple won't allow you to install these AppleScripts without some trickery.

If you are interested, download the package and take a look a the copious documentation.  If you are still game to try to run them, let me know and I can give you files that you can get to run on your Mac.

Cheers, Edouard  [cheers1]
Title: Re: For those with no patience...
Post by: xairbusdriver on January 29, 2016, 02:01:31 AM
Just about completely re-wrote the PHP to create the Computer Up-Time code last week. I tested single values for single minute, hour, day, month, and even year. Then made single and multiple values for every possible pair, trio, and quartet. OK, I cheated on the years testing; I just can't see running the mini for more than 1 year, 11 months, 30 days, 23 hours, 59 minutes without a restart for some reason! But, based on the other tests, I think it will still work even then!

It's very basic, repetitive code, begging to be converted to a function or two... later... [rolleyes2]

However, if you should ever see a mangled/mal-formatted output on the "Station" page, please copy and paste what you see and send it to me! I'm sure Stu has heard this before, but I got a laugh when I read it today:
Title: Remember . . . . (Re: For those with no patience...)
Post by: elagache on January 29, 2016, 11:53:58 PM
Dear X-Air and WeatherCat amateur coding monkeys, . . . .

I'm sure Stu has heard this before, but I got a laugh when I read it today:
    Ninety-nine little bugs in the code,
    Take one down, patch it around,
    117 little bugs in the code.

Remember, . . . . .

If debugging is the process by which bugs are removed from software, then surely programming is the process by which bugs are inserted into software! . . .  [banghead]

Alas, it appears that Apple Computer has lost sight of this perennial bit of wisdom . . . .  [rolleyes2]

Cheers, Edouard  [cheers1]
Title: Re: For those with no patience...
Post by: xairbusdriver on January 30, 2016, 12:19:19 AM
I stole borrowed that quote from an Aviation Week & Space Technology article discussing the software problems facing the F-35, Jpint Strike Fighter (One aircraft for Air Force, Navy, and Marine use [all with different needs, of course]). Airborne, ground, simulator, and mission planning data must be running in one huge application in many different environments and interactions with other airborne devices may require almost instantaneous updates.

The code must be checked / validated / tested every time a change is made. One commenter stated:"... The best debugged code in history is reputed to be the Space Shuttle code which is about 410,000 [Single Lines of Code]. It is believed that there is 1 UNDISCOVERED bug in every 10,000 lines." No one knows, right now, how many lines of code are in the JSF, but an over-site organization claims the lack of operational software is delaying the actual production of the aircraft.

Writing the software is the easy part, testing it becomes exponentially harder as the size/complexity increases. When the software is critical to the life of a human, there is no such thing as an "little bug"!