aboutsummaryrefslogtreecommitdiff
path: root/src/gui_index.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-08-31 14:37:09 +0200
committerThomas White <taw@physics.org>2020-08-31 14:37:09 +0200
commita833b044790f9a81d62863b22a552374ab702834 (patch)
treebecf0adb638bcf68ebdcf47e29aad9292ed2c270 /src/gui_index.c
parent9d6118d03fbda80d16c3408d275514f463e0ca53 (diff)
SLURM: Give full path to indexamajig, and set up path
Diffstat (limited to 'src/gui_index.c')
-rw-r--r--src/gui_index.c74
1 files changed, 73 insertions, 1 deletions
diff --git a/src/gui_index.c b/src/gui_index.c
index f989b538..a5655a8c 100644
--- a/src/gui_index.c
+++ b/src/gui_index.c
@@ -554,6 +554,69 @@ static void add_arg_int(char **args, int pos, const char *label,
}
+GFile *get_crystfel_path_gfile()
+{
+ GFile *self;
+ GFileInfo *self_info;
+ const char *self_target;
+ GFile *tar;
+ GFile *parent_dir;
+ GError *error = NULL;
+
+ self = g_file_new_for_path("/proc/self/exe");
+ self_info = g_file_query_info(self, "standard",
+ G_FILE_QUERY_INFO_NONE,
+ NULL, &error);
+ if ( self_info == NULL ) return NULL;
+
+ self_target = g_file_info_get_symlink_target(self_info);
+ if ( self_target == NULL ) return NULL;
+
+ tar = g_file_new_for_path(self_target);
+ if ( tar == NULL ) return NULL;
+
+ parent_dir = g_file_get_parent(tar);
+ if ( parent_dir == NULL ) return NULL;
+
+ g_object_unref(self);
+ g_object_unref(self_info);
+ g_object_unref(tar);
+
+ return parent_dir;
+}
+
+
+char *get_crystfel_path_str()
+{
+ char *path;
+ GFile *crystfel_path = get_crystfel_path_gfile();
+ if ( crystfel_path == NULL ) return NULL;
+ path = g_file_get_path(crystfel_path);
+ g_object_unref(crystfel_path);
+ return path;
+}
+
+
+static char *get_indexamajig_exe()
+{
+ GFile *crystfel_path;
+ char *indexamajig_path;
+ GFile *indexamajig;
+
+ crystfel_path = get_crystfel_path_gfile();
+ if ( crystfel_path == NULL ) return NULL;
+
+ indexamajig = g_file_get_child(crystfel_path, "indexamajig");
+ if ( indexamajig == NULL ) return NULL;
+
+ indexamajig_path = g_file_get_path(indexamajig);
+ g_object_unref(indexamajig);
+ g_object_unref(crystfel_path);
+
+ return indexamajig_path;
+}
+
+
char **indexamajig_command_line(const char *geom_filename,
const char *n_thread_str,
struct peak_params *peak_search_params,
@@ -561,13 +624,22 @@ char **indexamajig_command_line(const char *geom_filename,
{
char **args;
char tols[2048];
+ char *indexamajig_path;
int n_args = 0;
args = malloc(64*sizeof(char *));
if ( args == NULL ) return NULL;
+ indexamajig_path = get_indexamajig_exe();
+ if ( indexamajig_path == NULL ) {
+ ERROR("Couldn't determine indexamajig path. "
+ "This is OK provided the executable path is set "
+ "correctly.\n");
+ indexamajig_path = strdup("indexamajig");
+ }
+
/* The basics */
- add_arg(args, n_args++, "indexamajig");
+ add_arg(args, n_args++, indexamajig_path);
add_arg(args, n_args++, "-i");
add_arg(args, n_args++, "files.lst");
add_arg(args, n_args++, "-g");