X-Git-Url: https://git.realraum.at/?p=svn42.git;a=blobdiff_plain;f=sensor_graph%2Fget_realraum_picture.pl;fp=sensor_graph%2Fget_realraum_picture.pl;h=0000000000000000000000000000000000000000;hp=bd9714823f4a73dd61977a2772d8072a6b7822a1;hb=ff9137d257207a3a4b03c4f453cc1b7ce1e3cf17;hpb=a34e51d757fe52cb19de2937ae1b211894167524 diff --git a/sensor_graph/get_realraum_picture.pl b/sensor_graph/get_realraum_picture.pl deleted file mode 100755 index bd97148..0000000 --- a/sensor_graph/get_realraum_picture.pl +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/perl -w -# -# - -use strict; -use utf8; -require LWP::UserAgent; -my $ua = LWP::UserAgent->new(env_proxy => 1, - keep_alive => 1, - timeout => 30, - ); -use HTTP::Cookies; -use LWP; -$ua->cookie_jar({}); - -############### -$cam::url = "http://slug.realraum.at:8088/?action=snapshot"; -#$cam::get = {action=>"snapshot"}; -$cam::localpath = "/tmp/realraum.jpg"; -$cam::mintime = 0.00025; -############### - -sub output_saved_image -{ - return 0 if ( not -e $cam::localpath); - my $fh; - print STDOUT "Content-type: image/jpeg\n\n"; - open($fh,"<$cam::localpath") or exit; - while (<$fh>) {print $_}; - close($fh); - return 1; -} - -sub output_remote_image_and_save -{ - my $response; - $response = $ua->get($cam::url); - if (defined $response and $response->content =~ /^\xff\xd8/) - { - my $fh; - open($fh,">$cam::localpath"); - print $fh $response->content; - close($fh); - print STDOUT "Content-type: image/jpeg\n\n"; - print $response->content; - $response->clear; - return 1; - } - return 0; -} - -sub output_error -{ - print STDOUT "Status: 404 Not Found\n"; - print STDOUT "Content-type: text/html\n\n"; - print STDOUT "

Sorry

The picture you requested could not be found

\n"; - return 1; -} - -if (-e $cam::localpath and -M $cam::localpath < $cam::mintime) -{ - exit if (&output_saved_image); -} -else -{ - exit if (&output_remote_image_and_save); - exit if (&output_saved_image); -} -&output_error;