source: gsdl/trunk/perllib/download.pm@ 19617

Last change on this file since 19617 was 17527, checked in by ak19, 16 years ago

Now calls new subroutine setIsGLI on the download_obj to indicate whether or not the download is run from within GLI (or from a command prompt). This is necessary since Downloads using Wget that are launched via GLI require sockets to enable premature termination of wget, whereas when downloads are run by executing downloadfrom.pl from the cmd line, the WgetDownload.pm's signal handler for Ctrl-C (SIGINT) is called instead.

  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1###########################################################################
2#
3# download.pm -- functions to handle using download modules
4# A component of the Greenstone digital library software
5# from the New Zealand Digital Library Project at the
6# University of Waikato, New Zealand.
7#
8# Copyright (C) 2005 New Zealand Digital Library Project
9#
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program; if not, write to the Free Software
22# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23#
24###########################################################################
25
26package download;
27
28use strict; # to pick up typos and undeclared variables...
29no strict 'refs'; # ...but allow filehandles to be variables and vice versa
30no strict 'subs';
31
32##require util;
33use util;
34use gsprintf 'gsprintf';
35
36
37sub load_download {
38 my ($download_name,$download_options) = @_;
39
40 my ($download_obj);
41
42 my $coldownloadname ="";
43
44 if ($ENV{'GSDLCOLLECTDIR'}){
45
46 $coldownloadname = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},
47 "perllib","downloaders",
48 "${download_name}.pm");
49
50 }
51
52 my $maindownloadname = &util::filename_cat($ENV{'GSDLHOME'},
53 "perllib","downloaders",
54 "${download_name}.pm");
55
56 if (-e $coldownloadname) { require $coldownloadname;}
57 elsif (-e $maindownloadname ) { require $maindownloadname; }
58 else {
59 &gsprintf(STDERR, "{download.could_not_find_download}\n",
60 $download_name);
61 die "\n";
62 }
63
64 eval ("\$download_obj = new \$download_name([],\$download_options)");
65 die "$@" if $@;
66
67 return $download_obj;
68}
69
70sub process {
71 my ($download_obj,$options) = @_;
72 # options: This is a hash map which maps to
73 # downloadfrom's arguments
74 # $options->{'cache_dir'}
75 # $options->{'download_mode'}
76 # $options->{'gli_call'}
77 # $options->{'info'}
78 $download_obj->setIsGLI($options->{'gli'});
79
80 ($download_obj->download($options) == 1)?
81 return "true":
82 return "false";
83}
84
85sub get_information {
86 my ($download_obj) = @_;
87
88 $download_obj->url_information();
89}
90
911;
Note: See TracBrowser for help on using the repository browser.