Skip to content

Commit

Permalink
add solve-field command-line args for index directories or files
Browse files Browse the repository at this point in the history
  • Loading branch information
dstndstn committed May 6, 2024
1 parent 9635964 commit d8ce3cb
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.94"
__version__ = "0.94.dev57"
30 changes: 24 additions & 6 deletions solver/engine-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ static an_option_t myopts[] = {
"read input filenames from the given file, \"-\" for stdin"},
{'i', "index", required_argument, "file(s)",
"use the given index files (in addition to any specified in the config file); put in quotes to use wildcards, eg: \" -i 'index-*.fits' \""},
{'I', "index-dir", required_argument, "directory",
"search for index files in the given directory (in addition to any specified in the config file)"},
{'p', "in-parallel", no_argument, NULL,
"run the index files in parallel"},
{'D', "data-log file", required_argument, "file",
Expand Down Expand Up @@ -113,7 +115,8 @@ int main(int argc, char** args) {
anbool fromstdin = FALSE;

bl* opts = opts_from_array(myopts, sizeof(myopts)/sizeof(an_option_t), NULL);
sl* inds = sl_new(4);
sl* index_files = sl_new(4);
sl* index_dirs = sl_new(4);

char* datalog = NULL;

Expand All @@ -133,7 +136,10 @@ int main(int argc, char** args) {
engine->inparallel = TRUE;
break;
case 'i':
sl_append(inds, optarg);
sl_append(index_files, optarg);
break;
case 'I':
sl_append(index_dirs, optarg);
break;
case 'd':
basedir = optarg;
Expand Down Expand Up @@ -253,10 +259,21 @@ int main(int argc, char** args) {
}
}

if (sl_size(inds)) {
if (sl_size(index_dirs)) {
// save the engine_t state, add the search paths & auto-index them, then revert.
sl* saved_paths = engine->index_paths;
engine->index_paths = index_dirs;
if (engine_autoindex_search_paths(engine)) {
logerr("Failed to search directories for index files: [%s]", sl_join(index_dirs, ", "));
exit( -1);
}
engine->index_paths = saved_paths;
}

if (sl_size(index_files)) {
// Expand globs.
for (i=0; i<sl_size(inds); i++) {
char* s = sl_get(inds, i);
for (i=0; i<sl_size(index_files); i++) {
char* s = sl_get(index_files, i);
glob_t myglob;
int flags = GLOB_TILDE | GLOB_BRACE;
if (glob(s, flags, NULL, &myglob)) {
Expand Down Expand Up @@ -340,7 +357,8 @@ int main(int argc, char** args) {

engine_free(engine);
sl_free2(strings);
sl_free2(inds);
sl_free2(index_files);
sl_free2(index_dirs);

if (fin && !fromstdin)
fclose(fin);
Expand Down
12 changes: 12 additions & 0 deletions solver/solve-field.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ static an_option_t options[] = {
"use this config file for the \"astrometry-engine\" program"},
{'\x89', "config", required_argument, "filename",
"use this config file for the \"astrometry-engine\" program"},
{'\x96', "index-dir", required_argument, "dirname",
"search for index files in the given directory, for \"astrometry-engine\""},
{'\x97', "index-file", required_argument, "filename",
"add this index file to the \"astrometry-engine\" program; you can quote this and include wildcards."},
{'(', "batch", no_argument, NULL,
"run astrometry-engine once, rather than once per input file"},
{'f', "files-on-stdin", no_argument, NULL,
Expand Down Expand Up @@ -885,6 +889,14 @@ int main(int argc, char** args) {
sl_append(engineargs, "--config");
append_escape(engineargs, optarg);
break;
case '\x96':
sl_append(engineargs, "--index-dir");
append_escape(engineargs, optarg);
break;
case '\x97':
sl_append(engineargs, "--index");
append_escape(engineargs, optarg);
break;
case 'f':
fromstdin = TRUE;
break;
Expand Down

0 comments on commit d8ce3cb

Please sign in to comment.