summaryrefslogtreecommitdiff
path: root/rhimport-mz
diff options
context:
space:
mode:
Diffstat (limited to 'rhimport-mz')
-rwxr-xr-xrhimport-mz18
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";