Changeset 16611 for trunk/PS-IPP-Config/lib/PS/IPP/Config.pm
- Timestamp:
- Feb 22, 2008, 10:21:52 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/PS-IPP-Config/lib/PS/IPP/Config.pm (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/PS-IPP-Config/lib/PS/IPP/Config.pm
r16325 r16611 1 1 # Copyright (c) 2006 Paul Price, Joshua Hoblitt 2 2 # 3 # $Id: Config.pm,v 1.7 5 2008-02-06 02:05:44 price Exp $3 # $Id: Config.pm,v 1.76 2008-02-22 20:20:37 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 $self->load_site(); 99 $self->load_system(); 95 100 96 101 $self->define_camera($camera) if defined $camera; … … 140 145 } 141 146 147 # Load the site config file 148 sub load_site 149 { 150 my $self = shift; # Configuration object 151 152 my $i = 0; 153 154 unless (defined $self) { 155 carp "Programming error"; 156 exit($PS_EXIT_PROG_ERROR); 157 } 158 159 my $filename = metadataLookupStr($self->{_userConfig}, 'SITE'); # Site config file 160 unless (defined $filename) { 161 carp "Unable to find site configuration file\n"; 162 exit($PS_EXIT_CONFIG_ERROR); 163 } 164 165 my $realfile = $self->_find_config($filename); # Resolved filename, after hunting the PATH 166 167 # Read the file 168 my $file; # File handle 169 unless (open $file, $realfile) { 170 carp "Unable to open site configuration file $realfile: $!"; 171 exit($PS_EXIT_CONFIG_ERROR); 172 } 173 174 my @contents = <$file>; 175 close $file; 176 $self->{_siteConfig} = $parser->parse( join '', @contents); # The parsed metadata config 177 178 unless (defined $self->{_siteConfig}) { 179 carp "Failure to parse the site configuration file $realfile"; 180 exit($PS_EXIT_CONFIG_ERROR); 181 } 182 183 return $self; 184 } 185 186 # Load the system config file 187 sub load_system 188 { 189 my $self = shift; # Configuration object 190 191 unless (defined $self) { 192 carp "Programming error"; 193 exit($PS_EXIT_PROG_ERROR); 194 } 195 196 my $filename = metadataLookupStr($self->{_userConfig}, 'SYSTEM'); # System config file 197 unless (defined $filename) { 198 carp "Unable to find system configuration file\n"; 199 exit($PS_EXIT_CONFIG_ERROR); 200 } 201 202 my $realfile = $self->_find_config($filename); # Resolved filename, after hunting the PATH 203 204 # Read the file 205 my $file; # File handle 206 unless (open $file, $realfile) { 207 carp "Unable to open system configuration file $realfile: $!"; 208 exit($PS_EXIT_CONFIG_ERROR); 209 } 210 my @contents = <$file>; 211 close $file; 212 $self->{_systemConfig} = $parser->parse( join '', @contents); # The parsed metadata config 213 214 unless (defined $self->{_systemConfig}) { 215 carp "Failure to define system configuration"; 216 exit($PS_EXIT_CONFIG_ERROR); 217 } 218 219 # XXX why isn't just $self being returned here? -JH 220 return $self; 221 } 222 142 223 # Define a camera to use 143 224 sub define_camera … … 151 232 } 152 233 153 my $camera_list = metadataLookupMD($self->{_ ipprc}, 'CAMERAS'); # List of cameras234 my $camera_list = metadataLookupMD($self->{_systemConfig}, 'CAMERAS'); # List of cameras 154 235 my $filename = metadataLookupStr($camera_list, $name); # Filename of camera configuration 155 236 unless (defined $filename) { … … 233 314 } 234 315 235 my $path_list = metadataLookupMD($self->{_ ipprc}, 'DATAPATH'); # List of paths316 my $path_list = metadataLookupMD($self->{_siteConfig}, 'DATAPATH'); # List of paths 236 317 my $pathname = metadataLookupStr($path_list, $name); # Path of interest 237 318 unless (defined $pathname) { … … 258 339 return 1 if defined $self->{nebulous}; # Already started 259 340 260 my $server = metadataLookupStr( $self->{_ ipprc}, 'NEB_SERVER' ); # Nebulous server341 my $server = metadataLookupStr( $self->{_siteConfig}, 'NEB_SERVER' ); # Nebulous server 261 342 unless (defined $server) { 262 343 carp "Unable to find NEB_SERVER in camera configuration file."; … … 561 642 my @dirs = File::Spec->splitdir( $name ); 562 643 563 my $path_list = metadataLookupMD($self->{_ ipprc}, 'DATAPATH'); # List of paths644 my $path_list = metadataLookupMD($self->{_siteConfig}, 'DATAPATH'); # List of paths 564 645 my $best_path; 565 646 my $best_name; … … 790 871 my $tess_id = shift; # Tessellation identifier 791 872 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'); # Tessellations873 unless (defined $self and defined $self->{_siteConfig} and defined $tess_id) { 874 carp "Programming error"; 875 exit($PS_EXIT_PROG_ERROR); 876 } 877 878 my $tessellations = metadataLookupMD($self->{_siteConfig}, 'TESSELLATIONS'); # Tessellations 798 879 unless (defined $tessellations) { 799 880 carp "Can't find TESSELLATIONS in site configuration.\n"; … … 817 898 } 818 899 900 901 # Return catdir for the dvo db, from DVO.CATDIRS within the site configuration 902 sub dvo_catdir 903 { 904 my $self = shift; # Configuration object 905 my $dvodb = shift; # DVO db identifier 906 907 unless (defined $self and defined $self->{_siteConfig} and defined $dvodb) { 908 carp "Programming error"; 909 exit($PS_EXIT_PROG_ERROR); 910 } 911 912 my $catdirs = metadataLookupMD($self->{_siteConfig}, 'DVO.CATDIRS'); # Tessellations 913 unless (defined $catdirs) { 914 carp "Can't find DVO.CATDIRS in site configuration.\n"; 915 exit($PS_EXIT_CONFIG_ERROR); 916 } 917 918 my $catdir = metadataLookupStr($catdirs, $dvodb); 919 unless (defined $catdir) { 920 carp "Can't find dvodb identifier $dvodb in DVO.CATDIR in site configuration.\n"; 921 exit($PS_EXIT_CONFIG_ERROR); 922 } 923 924 ### Because DVO doesn't use psModules, it doesn't understand Nebulous --- check 925 my $scheme = file_scheme($catdir); # The scheme, e.g., file, path, neb 926 if (defined $scheme and lc($scheme) eq 'neb') { 927 carp "DVO catdir $dvodb refers to a Nebulous path: $catdir\n"; 928 exit($PS_EXIT_CONFIG_ERROR); 929 } 930 931 return $catdir 932 } 933 934 # Return catdir for the psastro reference, from PSASTRO.CATDIRS within the site configuration 935 sub psastro_catdir 936 { 937 my $self = shift; # Configuration object 938 my $dvodb = shift; # DVO db identifier 939 940 unless (defined $self and defined $self->{_siteConfig} and defined $dvodb) { 941 carp "Programming error"; 942 exit($PS_EXIT_PROG_ERROR); 943 } 944 945 my $catdirs = metadataLookupMD($self->{_siteConfig}, 'PSASTRO.CATDIRS'); # Tessellations 946 unless (defined $catdirs) { 947 carp "Can't find PSASTRO.CATDIRS in site configuration.\n"; 948 exit($PS_EXIT_CONFIG_ERROR); 949 } 950 951 my $catdir = metadataLookupStr($catdirs, $dvodb); 952 unless (defined $catdir) { 953 carp "Can't find dvodb identifier $dvodb in PSASTRO.CATDIR in site configuration.\n"; 954 exit($PS_EXIT_CONFIG_ERROR); 955 } 956 957 ### Because DVO doesn't use psModules, it doesn't understand Nebulous --- check 958 my $scheme = file_scheme($catdir); # The scheme, e.g., file, path, neb 959 if (defined $scheme and lc($scheme) eq 'neb') { 960 carp "PSASTRO catdir $dvodb refers to a Nebulous path: $catdir\n"; 961 exit($PS_EXIT_CONFIG_ERROR); 962 } 963 964 return $catdir 965 } 819 966 820 967 # Return the DVO.CAMERADIR in the camera configuration
Note:
See TracChangeset
for help on using the changeset viewer.
