From 2f896d02d13eab9d587a8dfd90b6300b1a338716 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 6 Aug 2011 00:25:26 +0200 Subject: Added Kachelmann for weathermonitoring --- kachelmann/conditions.pl | 7 +++++++ kachelmann/weather.xml | 1 + 2 files changed, 8 insertions(+) create mode 100755 kachelmann/conditions.pl create mode 100644 kachelmann/weather.xml (limited to 'kachelmann') diff --git a/kachelmann/conditions.pl b/kachelmann/conditions.pl new file mode 100755 index 00000000..61c43330 --- /dev/null +++ b/kachelmann/conditions.pl @@ -0,0 +1,7 @@ +#!/usr/bin/perl +use XML::Simple; +system("w3m -dump \"http://www.google.com/ig/api?weather=70327-stuttgart&hl=de\" > weather.xml"); +my $xml = new XML::Simple; +my $data = $xml->XMLin("weather.xml"); +my $sentence = "Die Wetterkondition ist: $data->{weather}->{current_conditions}->{condition}->{data}\n bei $data->{weather}->{current_conditions}->{temp_c}->{data} Grad Celsius\n"; +system("espeak \"$sentence\""); diff --git a/kachelmann/weather.xml b/kachelmann/weather.xml new file mode 100644 index 00000000..8a785308 --- /dev/null +++ b/kachelmann/weather.xml @@ -0,0 +1 @@ + -- cgit v1.2.3 From d0a2cc1b54f789455a56e088c6a920b6dc491a38 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 6 Aug 2011 00:36:40 +0200 Subject: Changed kachelmann to write its XML file to /tmp/kachelmann/weather.xml Deleted Weather.xml Added a Makefile --- kachelmann/Makefile | 5 +++++ kachelmann/conditions.pl | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 kachelmann/Makefile (limited to 'kachelmann') diff --git a/kachelmann/Makefile b/kachelmann/Makefile new file mode 100644 index 00000000..277a5421 --- /dev/null +++ b/kachelmann/Makefile @@ -0,0 +1,5 @@ +.PHONY: infect +INSTALL_DIR = /root/bin +infect: + mkdir -p /tmp/kachelmann/ + cp kachelmann ${INSTALL_DIR} diff --git a/kachelmann/conditions.pl b/kachelmann/conditions.pl index 61c43330..6d8b5541 100755 --- a/kachelmann/conditions.pl +++ b/kachelmann/conditions.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl use XML::Simple; -system("w3m -dump \"http://www.google.com/ig/api?weather=70327-stuttgart&hl=de\" > weather.xml"); +system("w3m -dump \"http://www.google.com/ig/api?weather=70327-stuttgart&hl=de\" > /tmp/kachelmann/weather.xml"); my $xml = new XML::Simple; -my $data = $xml->XMLin("weather.xml"); +my $data = $xml->XMLin("/tmp/kachelmann/weather.xml"); my $sentence = "Die Wetterkondition ist: $data->{weather}->{current_conditions}->{condition}->{data}\n bei $data->{weather}->{current_conditions}->{temp_c}->{data} Grad Celsius\n"; system("espeak \"$sentence\""); -- cgit v1.2.3 From 4500675b3871a5683e08f4c7de4d69c5a1a0b3d7 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 6 Aug 2011 01:27:55 +0200 Subject: Fixed the Makefile and renamed conditions.pl to conditions --- kachelmann/Makefile | 5 +++-- kachelmann/conditions | 7 +++++++ kachelmann/weather.xml | 1 - 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100755 kachelmann/conditions delete mode 100644 kachelmann/weather.xml (limited to 'kachelmann') diff --git a/kachelmann/Makefile b/kachelmann/Makefile index 277a5421..813f4dec 100644 --- a/kachelmann/Makefile +++ b/kachelmann/Makefile @@ -1,5 +1,6 @@ .PHONY: infect -INSTALL_DIR = /root/bin +INSTALL_DIR = /root/bin/ infect: mkdir -p /tmp/kachelmann/ - cp kachelmann ${INSTALL_DIR} + cp conditions ${INSTALL_DIR} + chmod +x ${INSTALL_DIR}conditions diff --git a/kachelmann/conditions b/kachelmann/conditions new file mode 100755 index 00000000..6d8b5541 --- /dev/null +++ b/kachelmann/conditions @@ -0,0 +1,7 @@ +#!/usr/bin/perl +use XML::Simple; +system("w3m -dump \"http://www.google.com/ig/api?weather=70327-stuttgart&hl=de\" > /tmp/kachelmann/weather.xml"); +my $xml = new XML::Simple; +my $data = $xml->XMLin("/tmp/kachelmann/weather.xml"); +my $sentence = "Die Wetterkondition ist: $data->{weather}->{current_conditions}->{condition}->{data}\n bei $data->{weather}->{current_conditions}->{temp_c}->{data} Grad Celsius\n"; +system("espeak \"$sentence\""); diff --git a/kachelmann/weather.xml b/kachelmann/weather.xml deleted file mode 100644 index 8a785308..00000000 --- a/kachelmann/weather.xml +++ /dev/null @@ -1 +0,0 @@ - -- cgit v1.2.3 From d9feb2d6431bc4be507998a0086a0f0d1317f8ea Mon Sep 17 00:00:00 2001 From: root Date: Sat, 6 Aug 2011 01:31:44 +0200 Subject: Mde the Makefile to rename conditions to kachelmann in /root/bin --- kachelmann/Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'kachelmann') diff --git a/kachelmann/Makefile b/kachelmann/Makefile index 813f4dec..7fa3ec2d 100644 --- a/kachelmann/Makefile +++ b/kachelmann/Makefile @@ -3,4 +3,6 @@ INSTALL_DIR = /root/bin/ infect: mkdir -p /tmp/kachelmann/ cp conditions ${INSTALL_DIR} - chmod +x ${INSTALL_DIR}conditions + mv ${INSTALL_DIR}conditions ${INSTALL_DIR}kachelmann + chmod +x ${INSTALL_DIR}kachelmann + -- cgit v1.2.3 From 370d97f0a8e92be059ba4bcf3a4934c1e030a327 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 6 Aug 2011 01:34:09 +0200 Subject: Made kachelmann speak german --- kachelmann/conditions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'kachelmann') diff --git a/kachelmann/conditions b/kachelmann/conditions index 6d8b5541..9880b397 100755 --- a/kachelmann/conditions +++ b/kachelmann/conditions @@ -4,4 +4,4 @@ system("w3m -dump \"http://www.google.com/ig/api?weather=70327-stuttgart&hl=de\" my $xml = new XML::Simple; my $data = $xml->XMLin("/tmp/kachelmann/weather.xml"); my $sentence = "Die Wetterkondition ist: $data->{weather}->{current_conditions}->{condition}->{data}\n bei $data->{weather}->{current_conditions}->{temp_c}->{data} Grad Celsius\n"; -system("espeak \"$sentence\""); +system("espeak -v de \"$sentence\""); -- cgit v1.2.3 From 0330d4071b4db787129f2a94fab5b1b8c12f3b20 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 6 Aug 2011 01:36:29 +0200 Subject: Edited the output so espeak can pronounce it --- kachelmann/conditions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'kachelmann') diff --git a/kachelmann/conditions b/kachelmann/conditions index 9880b397..1a798e42 100755 --- a/kachelmann/conditions +++ b/kachelmann/conditions @@ -3,5 +3,5 @@ use XML::Simple; system("w3m -dump \"http://www.google.com/ig/api?weather=70327-stuttgart&hl=de\" > /tmp/kachelmann/weather.xml"); my $xml = new XML::Simple; my $data = $xml->XMLin("/tmp/kachelmann/weather.xml"); -my $sentence = "Die Wetterkondition ist: $data->{weather}->{current_conditions}->{condition}->{data}\n bei $data->{weather}->{current_conditions}->{temp_c}->{data} Grad Celsius\n"; +my $sentence = "Die Wetterkondition ist: $data->{weather}->{current_conditions}->{condition}->{data}\n bei $data->{weather}->{current_conditions}->{temp_c}->{data} Grad Zelsius\n"; system("espeak -v de \"$sentence\""); -- cgit v1.2.3 From 4545d08ac81eab0cd9edce793f69b41f204aaf2f Mon Sep 17 00:00:00 2001 From: Momo Date: Sat, 6 Aug 2011 03:47:06 +0200 Subject: Added changes to Kachelmann so he can notify you when the weather changes --- kachelmann/.conditions.swp | Bin 0 -> 12288 bytes kachelmann/changes | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 kachelmann/.conditions.swp create mode 100644 kachelmann/changes (limited to 'kachelmann') diff --git a/kachelmann/.conditions.swp b/kachelmann/.conditions.swp new file mode 100644 index 00000000..a7b2f79d Binary files /dev/null and b/kachelmann/.conditions.swp differ diff --git a/kachelmann/changes b/kachelmann/changes new file mode 100644 index 00000000..dfd22b64 --- /dev/null +++ b/kachelmann/changes @@ -0,0 +1,31 @@ +#!/usr/bin/perl +use XML::Simple; +my $xml = new XML::Simple; +my $data_new = undef; +my $data_old = undef; + + +&startup; +while (true) { + if($status_new != $status_old){ + system("espeak -v de \"Das Wetter hat sich von $status_old in $status_new verändert\""); + } + sleep(300); + &get_status; +} + + +# The startup sub is used to get the first weather state. it should only be used on startup. sorry. +sub startup(){ + system("w3m -dump \"http://www.google.com/ig/api?weather=70327-stuttgart&hl=de\" > /tmp/kachelmann/weather.xml"); + $data_new = $xml->XMLin("/tmp/kachelmann/weather.xml"); + $data_new = $data_new->{weather}->{current_conditions}->{condition}->{data}; +} + +# The get_status sub moves the current data to $data_old and then gets a new one from Googles API +sub get_status(){ + system("w3m -dump \"http://www.google.com/ig/api?weather=70327-stuttgart&hl=de\" > /tmp/kachelmann/weather.xml"); + $data_old = $data_new; + $data_new = $xml->XMLin("/tmp/kachelmann/weather.xml"); + $data_new = $data_new->{weather}->{current_conditions}->{condition}->{data}; +} -- cgit v1.2.3 From fcb61649f402788e5938eec75a9a678278e4e4fd Mon Sep 17 00:00:00 2001 From: Momo Date: Sat, 6 Aug 2011 03:54:03 +0200 Subject: Deleted deprecated stuff --- kachelmann/conditions.pl | 7 ------- 1 file changed, 7 deletions(-) delete mode 100755 kachelmann/conditions.pl (limited to 'kachelmann') diff --git a/kachelmann/conditions.pl b/kachelmann/conditions.pl deleted file mode 100755 index 6d8b5541..00000000 --- a/kachelmann/conditions.pl +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/perl -use XML::Simple; -system("w3m -dump \"http://www.google.com/ig/api?weather=70327-stuttgart&hl=de\" > /tmp/kachelmann/weather.xml"); -my $xml = new XML::Simple; -my $data = $xml->XMLin("/tmp/kachelmann/weather.xml"); -my $sentence = "Die Wetterkondition ist: $data->{weather}->{current_conditions}->{condition}->{data}\n bei $data->{weather}->{current_conditions}->{temp_c}->{data} Grad Celsius\n"; -system("espeak \"$sentence\""); -- cgit v1.2.3 From 7741550be14eb747516bbfa648706f72ee3fd972 Mon Sep 17 00:00:00 2001 From: Momo Date: Sat, 6 Aug 2011 03:58:02 +0200 Subject: Added .gitignore --- kachelmann/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 kachelmann/.gitignore (limited to 'kachelmann') diff --git a/kachelmann/.gitignore b/kachelmann/.gitignore new file mode 100644 index 00000000..9c17d493 --- /dev/null +++ b/kachelmann/.gitignore @@ -0,0 +1,2 @@ +conditions.pl +*.swp -- cgit v1.2.3 From ce6595bf9756ba6c3c34238137c7dd48e453b396 Mon Sep 17 00:00:00 2001 From: Momo Date: Sat, 6 Aug 2011 03:59:00 +0200 Subject: fixed my idiocy --- kachelmann/.gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'kachelmann') diff --git a/kachelmann/.gitignore b/kachelmann/.gitignore index 9c17d493..050dfb2e 100644 --- a/kachelmann/.gitignore +++ b/kachelmann/.gitignore @@ -1,2 +1,2 @@ conditions.pl -*.swp +.*.swp -- cgit v1.2.3 From 74b400f10a7adafd8ce5b1644a6b500d4e5089ed Mon Sep 17 00:00:00 2001 From: makefu Date: Sun, 7 Aug 2011 16:00:57 +0200 Subject: kachelmann: remove need for tempfile TODO: the Makefile needs to be fixed though --- kachelmann/conditions | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'kachelmann') diff --git a/kachelmann/conditions b/kachelmann/conditions index 1a798e42..ea4ba5ca 100755 --- a/kachelmann/conditions +++ b/kachelmann/conditions @@ -1,7 +1,6 @@ #!/usr/bin/perl use XML::Simple; -system("w3m -dump \"http://www.google.com/ig/api?weather=70327-stuttgart&hl=de\" > /tmp/kachelmann/weather.xml"); +my $result = `w3m -dump "http://www.google.com/ig/api?weather=70327-stuttgart&hl=de"`; my $xml = new XML::Simple; -my $data = $xml->XMLin("/tmp/kachelmann/weather.xml"); -my $sentence = "Die Wetterkondition ist: $data->{weather}->{current_conditions}->{condition}->{data}\n bei $data->{weather}->{current_conditions}->{temp_c}->{data} Grad Zelsius\n"; -system("espeak -v de \"$sentence\""); +my $data = $xml->XMLin($result); +print ("Die Wetterkondition ist: $data->{weather}->{current_conditions}->{condition}->{data}\n bei $data->{weather}->{current_conditions}->{temp_c}->{data} Grad Zelsius\n"); -- cgit v1.2.3 From 1f6932ad2c69266f6e1a1bbc22ae9dc6d673ef3c Mon Sep 17 00:00:00 2001 From: Momo Date: Tue, 9 Aug 2011 03:21:58 +0200 Subject: initial commit --- kachelmann/.conditions.swp | Bin 12288 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 kachelmann/.conditions.swp (limited to 'kachelmann') diff --git a/kachelmann/.conditions.swp b/kachelmann/.conditions.swp deleted file mode 100644 index a7b2f79d..00000000 Binary files a/kachelmann/.conditions.swp and /dev/null differ -- cgit v1.2.3 From 1fa3eb0e4e3acbe560e2091e47de3a245155baf2 Mon Sep 17 00:00:00 2001 From: Momo Date: Tue, 9 Aug 2011 08:10:37 +0200 Subject: Fixed changes and dumped the caching :) --- kachelmann/changes | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'kachelmann') diff --git a/kachelmann/changes b/kachelmann/changes index dfd22b64..1875dabd 100644 --- a/kachelmann/changes +++ b/kachelmann/changes @@ -1,31 +1,24 @@ #!/usr/bin/perl use XML::Simple; my $xml = new XML::Simple; +my $xml_store = undef; my $data_new = undef; my $data_old = undef; +my $condition_store = undef; -&startup; -while (true) { - if($status_new != $status_old){ - system("espeak -v de \"Das Wetter hat sich von $status_old in $status_new verändert\""); +my $data_old = $condition_store; +while (1) { + &xml_update(); + $data_new = $condition_store; + if($data_new == $data_old){ + system("espeak Das Wetter hat sich von $data_old in $data_new verändert"); } - sleep(300); - &get_status; + sleep 300; + $data_new = $data_old; } - - -# The startup sub is used to get the first weather state. it should only be used on startup. sorry. -sub startup(){ - system("w3m -dump \"http://www.google.com/ig/api?weather=70327-stuttgart&hl=de\" > /tmp/kachelmann/weather.xml"); - $data_new = $xml->XMLin("/tmp/kachelmann/weather.xml"); - $data_new = $data_new->{weather}->{current_conditions}->{condition}->{data}; -} - -# The get_status sub moves the current data to $data_old and then gets a new one from Googles API -sub get_status(){ - system("w3m -dump \"http://www.google.com/ig/api?weather=70327-stuttgart&hl=de\" > /tmp/kachelmann/weather.xml"); - $data_old = $data_new; - $data_new = $xml->XMLin("/tmp/kachelmann/weather.xml"); - $data_new = $data_new->{weather}->{current_conditions}->{condition}->{data}; +sub xml_update(){ + $xml_store = system("w3m -dump \"http://www.google.com/ig/api?weather=70327-stuttgart&hl=de\""); + $xml_store = $xml->XMLin($xml_store); + $condition_store = $xml_store->{weather}->{current_conditions}->{condition}->{data}; } -- cgit v1.2.3