- Timestamp:
- Feb 19, 2008, 10:09:10 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20080219/PS-IPP-Config/lib/PS/IPP/Config.pm
r16325 r16542 1 1 # Copyright (c) 2006 Paul Price, Joshua Hoblitt 2 2 # 3 # $Id: Config.pm,v 1.75 2008-02-06 02:05:44 price Exp $3 # $Id: Config.pm,v 1.75.2.1 2008-02-19 20:09:09 eugene Exp $ 4 4 5 5 package PS::IPP::Config; … … 62 62 my $name; # Name of ipprc file 63 63 GetOptions( 'site=s' => \$name ); 64 $name = $ENV{ PS_SITE} if not defined $name;64 $name = $ENV{IPPRC} if not defined $name; 65 65 if (not defined $name and defined $ENV{HOME}) { 66 66 $name = $ENV{HOME} . '/.ipprc'; … … 90 90 filerules => undef, # File rules from the camera configuration 91 91 rejection => undef, # Rejection data 92 _ipprc => $mdc # The parsed configuration 92 _userConfig => $mdc, # The top-level user configuration 93 _siteConfig => undef, # The site configuration (from _userConfig) 94 _systemConfig => undef # The system configuration (from _userConfig) 93 95 }; 94 96 bless $self, $class; 97 98 print "load site\n"; 99 $self->load_site(); 100 101 print "load system\n"; 102 $self->load_system(); 95 103 96 104 $self->define_camera($camera) if defined $camera; … … 140 148 } 141 149 150 # Load the site config file 151 sub load_site 152 { 153 my $self = shift; # Configuration object 154 155 my $i = 0; 156 print "$i"; $i ++; 157 158 unless (defined $self) { 159 carp "Programming error"; 160 exit($PS_EXIT_PROG_ERROR); 161 } 162 print "$i"; $i ++; 163 164 my $filename = metadataLookupStr($self->{_userConfig}, 'SITE'); # Site config file 165 unless (defined $filename) { 166 carp "Unable to find site configuration file\n"; 167 exit($PS_EXIT_CONFIG_ERROR); 168 } 169 print "$i"; $i ++; 170 171 my $realfile = $self->_find_config($filename); # Resolved filename, after hunting the PATH 172 print "$i"; $i ++; 173 174 # Read the file 175 my $file; # File handle 176 unless (open $file, $realfile) { 177 carp "Unable to open site configuration file $realfile: $!"; 178 exit($PS_EXIT_CONFIG_ERROR); 179 } 180 print "$i"; $i ++; 181 182 my @contents = <$file>; 183 close $file; 184 $self->{_siteConfig} = $parser->parse( join '', @contents); # The parsed metadata config 185 print "$i"; $i ++; 186 187 ## XXXX : the error is here 188 unless (defined $self->{_siteConfig}) { 189 carp "Failure to define site configuration"; 190 exit($PS_EXIT_CONFIG_ERROR); 191 } 192 print "$i"; $i ++; 193 194 # XXX why isn't just $self being returned here? -JH 195 return $self; 196 } 197 198 # Load the system config file 199 sub load_system 200 { 201 my $self = shift; # Configuration object 202 203 unless (defined $self) { 204 carp "Programming error"; 205 exit($PS_EXIT_PROG_ERROR); 206 } 207 208 my $filename = metadataLookupStr($self->{_userConfig}, 'SYSTEM'); # System config file 209 unless (defined $filename) { 210 carp "Unable to find system configuration file\n"; 211 exit($PS_EXIT_CONFIG_ERROR); 212 } 213 214 my $realfile = $self->_find_config($filename); # Resolved filename, after hunting the PATH 215 216 # Read the file 217 my $file; # File handle 218 unless (open $file, $realfile) { 219 carp "Unable to open system configuration file $realfile: $!"; 220 exit($PS_EXIT_CONFIG_ERROR); 221 } 222 my @contents = <$file>; 223 close $file; 224 $self->{_systemConfig} = $parser->parse( join '', @contents); # The parsed metadata config 225 226 unless (defined $self->{_systemConfig}) { 227 carp "Failure to define system configuration"; 228 exit($PS_EXIT_CONFIG_ERROR); 229 } 230 231 # XXX why isn't just $self being returned here? -JH 232 return $self; 233 } 234 142 235 # Define a camera to use 143 236 sub define_camera … … 151 244 } 152 245 153 my $camera_list = metadataLookupMD($self->{_ ipprc}, 'CAMERAS'); # List of cameras246 my $camera_list = metadataLookupMD($self->{_systemConfig}, 'CAMERAS'); # List of cameras 154 247 my $filename = metadataLookupStr($camera_list, $name); # Filename of camera configuration 155 248 unless (defined $filename) { … … 233 326 } 234 327 235 my $path_list = metadataLookupMD($self->{_ ipprc}, 'DATAPATH'); # List of paths328 my $path_list = metadataLookupMD($self->{_siteConfig}, 'DATAPATH'); # List of paths 236 329 my $pathname = metadataLookupStr($path_list, $name); # Path of interest 237 330 unless (defined $pathname) { … … 258 351 return 1 if defined $self->{nebulous}; # Already started 259 352 260 my $server = metadataLookupStr( $self->{_ ipprc}, 'NEB_SERVER' ); # Nebulous server353 my $server = metadataLookupStr( $self->{_siteConfig}, 'NEB_SERVER' ); # Nebulous server 261 354 unless (defined $server) { 262 355 carp "Unable to find NEB_SERVER in camera configuration file."; … … 561 654 my @dirs = File::Spec->splitdir( $name ); 562 655 563 my $path_list = metadataLookupMD($self->{_ ipprc}, 'DATAPATH'); # List of paths656 my $path_list = metadataLookupMD($self->{_siteConfig}, 'DATAPATH'); # List of paths 564 657 my $best_path; 565 658 my $best_name; … … 790 883 my $tess_id = shift; # Tessellation identifier 791 884 792 unless (defined $self and defined $self->{_ ipprc} and defined $tess_id) {793 carp "Programming error"; 794 exit($PS_EXIT_PROG_ERROR); 795 } 796 797 my $tessellations = metadataLookupMD($self->{_ ipprc}, 'TESSELLATIONS'); # Tessellations885 unless (defined $self and defined $self->{_siteConfig} and defined $tess_id) { 886 carp "Programming error"; 887 exit($PS_EXIT_PROG_ERROR); 888 } 889 890 my $tessellations = metadataLookupMD($self->{_siteConfig}, 'TESSELLATIONS'); # Tessellations 798 891 unless (defined $tessellations) { 799 892 carp "Can't find TESSELLATIONS in site configuration.\n"; … … 817 910 } 818 911 912 913 # Return catdir for the dvo db, from DVO.CATDIRS within the site configuration 914 sub dvo_catdir 915 { 916 my $self = shift; # Configuration object 917 my $dvodb = shift; # DVO db identifier 918 919 unless (defined $self and defined $self->{_siteConfig} and defined $dvodb) { 920 carp "Programming error"; 921 exit($PS_EXIT_PROG_ERROR); 922 } 923 924 my $catdirs = metadataLookupMD($self->{_siteConfig}, 'DVO.CATDIRS'); # Tessellations 925 unless (defined $catdirs) { 926 carp "Can't find DVO.CATDIRS in site configuration.\n"; 927 exit($PS_EXIT_CONFIG_ERROR); 928 } 929 930 my $catdir = metadataLookupStr($catdirs, $dvodb); 931 unless (defined $catdir) { 932 carp "Can't find dvodb identifier $dvodb in DVO.CATDIR in site configuration.\n"; 933 exit($PS_EXIT_CONFIG_ERROR); 934 } 935 936 ### Because DVO doesn't use psModules, it doesn't understand Nebulous --- check 937 my $scheme = file_scheme($catdir); # The scheme, e.g., file, path, neb 938 if (defined $scheme and lc($scheme) eq 'neb') { 939 carp "DVO catdir $dvodb refers to a Nebulous path: $catdir\n"; 940 exit($PS_EXIT_CONFIG_ERROR); 941 } 942 943 return $catdir 944 } 945 946 # Return catdir for the psastro reference, from PSASTRO.CATDIRS within the site configuration 947 sub psastro_catdir 948 { 949 my $self = shift; # Configuration object 950 my $dvodb = shift; # DVO db identifier 951 952 unless (defined $self and defined $self->{_siteConfig} and defined $dvodb) { 953 carp "Programming error"; 954 exit($PS_EXIT_PROG_ERROR); 955 } 956 957 my $catdirs = metadataLookupMD($self->{_siteConfig}, 'PSASTRO.CATDIRS'); # Tessellations 958 unless (defined $catdirs) { 959 carp "Can't find PSASTRO.CATDIRS in site configuration.\n"; 960 exit($PS_EXIT_CONFIG_ERROR); 961 } 962 963 my $catdir = metadataLookupStr($catdirs, $dvodb); 964 unless (defined $catdir) { 965 carp "Can't find dvodb identifier $dvodb in PSASTRO.CATDIR in site configuration.\n"; 966 exit($PS_EXIT_CONFIG_ERROR); 967 } 968 969 ### Because DVO doesn't use psModules, it doesn't understand Nebulous --- check 970 my $scheme = file_scheme($catdir); # The scheme, e.g., file, path, neb 971 if (defined $scheme and lc($scheme) eq 'neb') { 972 carp "PSASTRO catdir $dvodb refers to a Nebulous path: $catdir\n"; 973 exit($PS_EXIT_CONFIG_ERROR); 974 } 975 976 return $catdir 977 } 819 978 820 979 # Return the DVO.CAMERADIR in the camera configuration
Note:
See TracChangeset
for help on using the changeset viewer.
