diff options
author | Christian Pointner <equinox@helsinki.at> | 2015-07-22 13:34:05 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2015-07-22 13:34:05 (GMT) |
commit | 6fb972eec6953a40d57b76b7894952abdc4437d2 (patch) | |
tree | 8d0f567c0d366327ffd5a7939646ea398be549d2 /rhimport-mz | |
parent | e6035cca7cf6f23b3965f6238e41103838c48d3b (diff) |
refactoring
Diffstat (limited to 'rhimport-mz')
-rwxr-xr-x | rhimport-mz | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/rhimport-mz b/rhimport-mz index 60b91f3..f3c4535 100755 --- a/rhimport-mz +++ b/rhimport-mz @@ -23,7 +23,6 @@ use strict; use Switch; -use DBI; use Date::Calc; use Time::localtime; use IO::Handle; @@ -33,11 +32,6 @@ use File::Slurp; use lib '/usr/local/share/rhimport/'; use rhimport; -my $DBHOST = "airplay"; -my $DBUSER = "rivendell"; -my $DBPW = "lldriven"; -my $DB = "rivendell"; - my @STATIC_FILES = ($ENV{'HOME'} . "/frontex", $ENV{'HOME'} . "/maribor" ); @@ -85,11 +79,15 @@ switch($dow) { else { print("invalid day of week?!\n"); exit 1; } } -my $dbh = DBI->connect("DBI:mysql:$DB:$DBHOST","$DBUSER","$DBPW") or die "Database Error: $DBI::errstr"; +my ($dbh, $errorstring) = rhimport::opendb(); +if(!defined $dbh) { + print "$errorstring\n"; + exit 1; +} my @allowed_dbs = rhimport::get_dropboxes($dbh, $user, $group); if(scalar(@allowed_dbs) != 1) { print "found no or more than one Dropboxes for this group?!\n"; - $dbh->disconnect(); + rhimport::closedb($dbh); exit 1; } my $dropbox = $allowed_dbs[0]->{'PATH'}; @@ -99,7 +97,7 @@ my $import_date = sprintf("%04d-%02d-%02d", @import_day); my $current_date = `cat $STAT_FILE`; if($current_date eq $import_date) { print "Already downloaded file of day in question\n"; - $dbh->disconnect(); + rhimport::closedb($dbh); exit 0; } @@ -220,7 +218,7 @@ foreach my $file (@files) { $cart++; } -$dbh->disconnect(); +rhimport::closedb($dbh); if(!$ret) { print "\nImport Error:\n"; |