Skip to content

Commit

Permalink
Refactor update_share_id.cgi to use more relative paths
Browse files Browse the repository at this point in the history
  • Loading branch information
adkinsrs committed Aug 12, 2024
1 parent 62052c2 commit 47beec9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions www/cgi/update_share_id.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ lib_path = os.path.abspath(os.path.join('..', '..', 'lib'))
sys.path.append(lib_path)
import geardb

from pathlib import Path
abs_path_www = Path(__file__).resolve().parents[1] # web-root dir
CARTS_BASE_DIR = abs_path_www.joinpath("carts")
BY_DATASET_DIR = abs_path_www.joinpath("projections", "by_dataset")
BY_GENECART_DIR = abs_path_www.joinpath("projections", "by_genecart")


def main():
cnx = geardb.Connection()
print('Content-Type: application/json\n\n')
Expand Down Expand Up @@ -115,7 +122,7 @@ def main():

# rename carts
if gene_cart.gctype == "weighted":
os.chdir("/var/www/carts")
os.chdir(str(CARTS_BASE_DIR))

for filename in os.listdir("."):
if not share_id in filename:
Expand All @@ -131,7 +138,7 @@ def main():

# rename projections
# the "by_dataset" directory only needs projections.json files updated
os.chdir("/var/www/projections/by_dataset")
os.chdir(str(BY_DATASET_DIR))
for root, dirs, files in os.walk("."):
for file in files:
if not file.endswith("projections.json"):
Expand All @@ -145,7 +152,7 @@ def main():
break

# the "by_genecart" directory needs both directory names updated
os.chdir("/var/www/projections/by_genecart")
os.chdir(str(BY_GENECART_DIR))
for root, dirs, files in os.walk("."):
for dirname in dirs:
if not share_id in dirname:
Expand Down

0 comments on commit 47beec9

Please sign in to comment.