~siretart/gnucash/ubuntu-fullsource

« back to all changes in this revision

Viewing changes to src/quotes/gnc-fq-check.in

  • Committer: Reinhard Tartler
  • Date: 2008-08-03 07:25:46 UTC
  • Revision ID: siretart@tauware.de-20080803072546-y6p8xda8zpfi62ys
import gnucash_2.2.4.orig.tar.gz

The original tarball had the md5sum: 27e660297dc5b8ce574515779d05a5a5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!@-PERL-@ -w
 
2
######################################################################
 
3
### gnc-fq-check - check for the presence of  Finance::Quote
 
4
### From gnc-fq-helper.
 
5
### Copyright 2001 Rob Browning <rlb@cs.utexas.edu>
 
6
### 
 
7
### This program is free software; you can redistribute it and/or    
 
8
### modify it under the terms of the GNU General Public License as   
 
9
### published by the Free Software Foundation; either version 2 of   
 
10
### the License, or (at your option) any later version.              
 
11
###                                                                  
 
12
### This program is distributed in the hope that it will be useful,  
 
13
### but WITHOUT ANY WARRANTY; without even the implied warranty of   
 
14
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    
 
15
### GNU General Public License for more details.                     
 
16
###                                                                  
 
17
### You should have received a copy of the GNU General Public License
 
18
### along with this program# if not, contact:
 
19
###
 
20
### Free Software Foundation           Voice:  +1-617-542-5942
 
21
### 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
 
22
### Boston, MA  02110-1301,  USA       gnu@gnu.org
 
23
######################################################################
 
24
 
 
25
use lib '@-PERLINCL-@';
 
26
 
 
27
use strict;
 
28
use English;
 
29
use FileHandle;
 
30
 
 
31
# Input: <none>
 
32
#
 
33
# Output (on standard output, one output form per input line):
 
34
#
 
35
# A list of quote sources supported by Finance::Quote, or the single
 
36
# term missing-lib if finance quote could not be executed.
 
37
#
 
38
# Exit status
 
39
#
 
40
# 0 - success
 
41
# non-zero - failure
 
42
 
 
43
sub check_modules {
 
44
  my @modules = qw(Finance::Quote LWP HTML::Parser HTML::TableExtract Crypt::SSLeay Date::Manip);
 
45
  my @missing;
 
46
 
 
47
  foreach my $mod (@modules) {
 
48
    if (eval "require $mod") {
 
49
      $mod->import();
 
50
    }
 
51
    else {
 
52
      push (@missing, $mod);
 
53
    }
 
54
  }
 
55
 
 
56
  return unless @missing;
 
57
 
 
58
  print STDERR "\n";
 
59
  print STDERR "You need to install the following Perl modules:\n";
 
60
  foreach my $mod (@missing) {
 
61
    print STDERR "  ".$mod."\n";
 
62
  }
 
63
 
 
64
  print STDERR "\n";
 
65
  print STDERR "Use your system's package manager to install them,\n";
 
66
  print STDERR "or run 'gnc-fq-update' as root.\n";
 
67
 
 
68
  print "missing-lib\n";
 
69
 
 
70
  exit 1;
 
71
}
 
72
 
 
73
#---------------------------------------------------------------------------
 
74
# Runtime.
 
75
 
 
76
# Check for and load non-standard modules
 
77
check_modules ();
 
78
 
 
79
# Create a stockquote object.
 
80
my $quoter = Finance::Quote->new();
 
81
my $prgnam = "gnc-fq-check";
 
82
 
 
83
my @qsources;
 
84
my @sources = $quoter->sources();
 
85
foreach my $source (@sources) {
 
86
  push(@qsources, "\"$source\"");
 
87
}
 
88
printf "(\"%s\" %s)\n", $Finance::Quote::VERSION, join(" ", qq/@qsources/);
 
89
 
 
90
## Local Variables:
 
91
## mode: perl
 
92
## End: