Skip to content

Commit

Permalink
Update selection of path to psn.conf
Browse files Browse the repository at this point in the history
Fix problem with desktop not being used when using the latest
File::HomeDir.
Introduce env variable PSNCONFPATH as an option
  • Loading branch information
rikardn committed May 8, 2024
1 parent ed49e2e commit 9bbf34e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion development/release_notes/release_notes_PsN_5_4_0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Changes and bug fixes from PsN 5.3.1 to 5.4.0
___General___

* Using File::Copy::copy instead of File::Copy::cp everywhere. This will use the default file permissions for the destination file.

* The environment variable PSNCONFPATH can be used to set a preferred path where to find psn.conf

___common_options___

Expand Down
2 changes: 1 addition & 1 deletion doc/psn_configuration.tex
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ \section{psn.conf overview}
In psn.conf it is also possible to specify personal default values, see more information below. Comment lines in psn.conf start with a semicolon (;). Throughout the default psn.conf distributed with PsN there are examples of settings for UNIX and Windows. The user can review the settings, add and remove semicolons, and change selected paths.

\subsection{Location of psn.conf}
PsN will look for psn.conf at two different places. Primarily (depending on operative system) in the user's home directory (UNIX) or on the user's desktop (Windows) and then in the PsN installation directory. If psn.conf is found in the home directory (UNIX) or on the user's desktop (Windows) the settings in this psn.conf will override the settings in the system-wide (PsN installation directory) present psn.conf, which is important to remember when trying to sort out a psn.conf-related problem.
PsN will look for psn.conf at two different places. Primarily (depending on operative system) in the user's home directory (UNIX) or on the user's desktop (Windows) and then in the PsN installation directory. If psn.conf is found in the home directory (UNIX) or on the user's desktop (Windows) the settings in this psn.conf will override the settings in the system-wide (PsN installation directory) present psn.conf, which is important to remember when trying to sort out a psn.conf-related problem. It is also possible to set the path to psn.conf by using the \verb|PSNCONFPATH| environment variable.

\subsection{Sections in psn.conf}
The organizing of settings in psn.conf is important. They must be set in the correct section.\\
Expand Down
14 changes: 10 additions & 4 deletions lib/PsN.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ $lib_dir = Cwd::abs_path($volume . $directory);
$Rscripts_dir = get_Rscripts_dir($lib_dir);


$config_file = $lib_dir . '/psn.conf';

use File::HomeDir;
use ext::Config::Tiny;

Expand All @@ -39,8 +37,16 @@ our @nm7_extensions = ('.ext','.cov','.cor','.coi','.phi','.phm', '.shk','.grd',
'.imp','.npd','.npe','.npi','.fgh','.log.xml','.cpu','.shm','.agh',
'.vpd','.clt','.npl', '.ets'); #nm74

if( -e home() . "/psn.conf" ){
$config_file = home() . "/psn.conf";
my $envconfig = $ENV{PSNCONFPATH};

if (defined $envconfig and -e "$envconfig/psn.conf") {
$config_file = "$envconfig/psn.conf";
} elsif (-e File::HomeDir::my_home . "/psn.conf") {
$config_file = File::HomeDir::my_home . "/psn.conf";
} elsif (-e File::HomeDir::my_desktop . "/psn.conf") {
$config_file = File::HomeDir::my_desktop . "/psn.conf";
} else {
$config_file = $lib_dir . '/psn.conf';
}

sub get_Rscripts_dir{
Expand Down

0 comments on commit 9bbf34e

Please sign in to comment.