Skip to content

Commit

Permalink
OD-1729 Allow running ODAP out of any directory
Browse files Browse the repository at this point in the history
Currently, there are a few places where SQL statements are read based on
the current directory ($PWD). This will cause failures when the code is
not being run in the ODAP directory. Instead, always pull the path
relative to the code directory.
  • Loading branch information
hlieberman committed Nov 1, 2023
1 parent d5e39c4 commit 93d3079
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions 05-Create-Open-Doors-Tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ def main(args, log):
}
filter = 'WHERE id NOT IN '

sql.run_script_from_file('shared_python/create-open-doors-tables.sql',
codepath = os.path.dirname(os.path.realpath(__file__))

sql.run_script_from_file(codepath + '/shared_python/create-open-doors-tables.sql',
database=args.output_database)

# Filter out DNI stories - story_ids_to_remove must be comma-separated list of DNI ids
Expand Down Expand Up @@ -127,4 +129,4 @@ def main(args, log):
args_obj = Args()
args = args_obj.args_for_05()
log = args_obj.logger_with_filename()
main(args, log)
main(args, log)
6 changes: 5 additions & 1 deletion automated_archive/aa.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import datetime
import codecs
import re
import os
from html.parser import HTMLParser

from pymysql import connect
Expand Down Expand Up @@ -115,7 +116,10 @@ def _create_mysql(args, FILES, log):
cursor.execute(u"use {0}".format(DATABASE_NAME))

sql = Sql(args)
sql.run_script_from_file('shared_python/create-open-doors-tables.sql', DATABASE_NAME)
codepath = os.path.dirname(os.path.realpath(__file__))

sql.run_script_from_file(codepath + '/shared_python/create-open-doors-tables.sql',
database=DATABASE_NAME)
db.commit()

authors = [(FILES[i].get('Author', '').strip(), FILES[i].get('Email', FILES[i].get('EmailAuthor', '')).lower().strip()) for i in FILES]
Expand Down

0 comments on commit 93d3079

Please sign in to comment.