55_GDS.pm: code cleanup
git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@9751 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
@@ -35,17 +35,13 @@ package main;
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use feature qw/say switch/;
|
use feature qw/switch/;
|
||||||
|
|
||||||
use Blocking;
|
use Blocking;
|
||||||
use Archive::Extract;
|
use Archive::Extract;
|
||||||
use Net::FTP;
|
use Net::FTP;
|
||||||
use XML::Simple;
|
use XML::Simple;
|
||||||
|
|
||||||
#use Archive::Zip qw( :ERROR_CODES :CONSTANTS );
|
|
||||||
|
|
||||||
#use Data::Dumper;
|
|
||||||
|
|
||||||
eval "use GDSweblink";
|
eval "use GDSweblink";
|
||||||
|
|
||||||
no if $] >= 5.017011, warnings => 'experimental';
|
no if $] >= 5.017011, warnings => 'experimental';
|
||||||
@@ -875,60 +871,10 @@ sub gds_calctz($@) {
|
|||||||
return (12-$gt[2]);
|
return (12-$gt[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub ua_test($$$) {
|
|
||||||
my ($hash,$dir,$file) = @_;
|
|
||||||
|
|
||||||
my $name = $hash->{NAME};
|
|
||||||
my $user = $hash->{helper}{USER};
|
|
||||||
my $pass = $hash->{helper}{PASS};
|
|
||||||
my $host = $hash->{helper}{URL};
|
|
||||||
|
|
||||||
use LWP::UserAgent;
|
|
||||||
my $ua;
|
|
||||||
$ua = LWP::UserAgent->new;
|
|
||||||
$ua->timeout(10);
|
|
||||||
$ua->env_proxy;
|
|
||||||
|
|
||||||
my $urlString = "ftp://$user:$pass\@$host/";
|
|
||||||
$urlString .= $dir;
|
|
||||||
$urlString .= $file;
|
|
||||||
my $response = $ua->get($urlString); #,':content_file' => $file_handle);
|
|
||||||
|
|
||||||
if ($response->is_success) {
|
|
||||||
return $response->decoded_content;
|
|
||||||
} else {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
###################################################################################################
|
###################################################################################################
|
||||||
#
|
#
|
||||||
# Data retrieval (internal)
|
# Data retrieval (internal)
|
||||||
|
|
||||||
sub getListCapStations($$){
|
|
||||||
my ($hash, $command) = @_;
|
|
||||||
my $name = $hash->{NAME};
|
|
||||||
my (%capHash, $file, @columns, $key, $cList, $count);
|
|
||||||
|
|
||||||
$file = $tempDir.'capstations.csv';
|
|
||||||
return "GDS error: $file not found." unless(-e $file);
|
|
||||||
|
|
||||||
# CSV öffnen und parsen
|
|
||||||
my ($err,@a) = FileRead({FileName=>$file,ForceType=>"file" });
|
|
||||||
return "GDS error reading $file" if($err);
|
|
||||||
foreach my $l (@a) {
|
|
||||||
next if (substr($l,0,1) eq '#');
|
|
||||||
@columns = split(";",$l);
|
|
||||||
$capHash{latin1ToUtf8($columns[4])} = $columns[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
# Ausgabe sortieren und zusammenstellen
|
|
||||||
foreach $key (sort keys %capHash) {
|
|
||||||
$cList .= $capHash{$key}."\t".$key."\n";
|
|
||||||
}
|
|
||||||
return $cList;
|
|
||||||
}
|
|
||||||
|
|
||||||
sub getConditions($$@){
|
sub getConditions($$@){
|
||||||
my ($hash, $prefix, @a) = @_;
|
my ($hash, $prefix, @a) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
@@ -1017,6 +963,29 @@ sub _readItem {
|
|||||||
return $x;
|
return $x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub getListCapStations($$){
|
||||||
|
my ($hash, $command) = @_;
|
||||||
|
my $name = $hash->{NAME};
|
||||||
|
my (%capHash, $file, @columns, $key, $cList, $count);
|
||||||
|
|
||||||
|
$file = $tempDir.'capstations.csv';
|
||||||
|
return "GDS error: $file not found." unless(-e $file);
|
||||||
|
|
||||||
|
# CSV öffnen und parsen
|
||||||
|
my ($err,@a) = FileRead({FileName=>$file,ForceType=>"file" });
|
||||||
|
return "GDS error reading $file" if($err);
|
||||||
|
foreach my $l (@a) {
|
||||||
|
next if (substr($l,0,1) eq '#');
|
||||||
|
@columns = split(";",$l);
|
||||||
|
$capHash{latin1ToUtf8($columns[4])} = $columns[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
# Ausgabe sortieren und zusammenstellen
|
||||||
|
foreach $key (sort keys %capHash) {
|
||||||
|
$cList .= $capHash{$key}."\t".$key."\n";
|
||||||
|
}
|
||||||
|
return $cList;
|
||||||
|
}
|
||||||
sub retrieveListCapStations($){
|
sub retrieveListCapStations($){
|
||||||
my ($hash) = @_;
|
my ($hash) = @_;
|
||||||
$hash->{file}{dir} = "gds/help/";
|
$hash->{file}{dir} = "gds/help/";
|
||||||
@@ -1030,7 +999,6 @@ sub retrieveListCapStations($){
|
|||||||
retrieveData($hash,'FILE') if ($alter > 86400);
|
retrieveData($hash,'FILE') if ($alter > 86400);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub decodeCAPData($$$){
|
sub decodeCAPData($$$){
|
||||||
my ($hash, $datensatz, $anum) = @_;
|
my ($hash, $datensatz, $anum) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
|
|||||||
Reference in New Issue
Block a user