From 6f683003c47c43c8842c071f81898c36ff348ce0 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 2432589707a1153c14de4d43533a1a3bc31dbc9e 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 66cf9c25fff2686c90a632422386f17bd835243e 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 925e7b3da5cd12734d66201b95744ef5f9c09917 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 135bdbc139f1aefb8d05d2de5e01e52982f4437a 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 1318d17d4908f5213da91e424b5f574e159ffd11 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 e0622cb1ea37de31ec7bb20e7c100fd2ce54ce2c 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 c89f52712da303995c07d367e7ec097a5e49e1bb 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 1fdde2c2db21f69a3751c44d858b9179fe1a0131 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 25d427e60136ca349791f7fce3bb717aba8f0512 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 d29aa166348fd3fdb309f4038ad9216652334bb4 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