diff --git a/MSID_limit/compare_database_and_update.py b/MSID_limit/compare_database_and_update.py index c11030a..acf1126 100755 --- a/MSID_limit/compare_database_and_update.py +++ b/MSID_limit/compare_database_and_update.py @@ -21,6 +21,9 @@ import unittest import time import Chandra.Time +from pathlib import Path +from kadi.occweb import get_auth +import requests #--- reading directory list # @@ -361,16 +364,15 @@ def download_glimmon(): cmd = 'mv -f ' + glimmon + ' ' + glimmon + '~' os.system(cmd) - with open('/home/isobe/.occpass' , 'r') as f: - out = f.read().strip() # #--- download the database # - cmd = 'curl -u tisobe:' + out - cmd = cmd + ' https://occweb.cfa.harvard.edu/occweb/FOT/engineering/thermal/' - cmd = cmd + 'AXAFAUTO_RSYNC/G_LIMMON_Archive/glimmondb.sqlite3 > ' + glimmon - os.system(cmd) + url = 'https://occweb.cfa.harvard.edu/occweb/FOT/engineering/thermal/AXAFAUTO_RSYNC/G_LIMMON_Archive/glimmondb.sqlite3' + # get_auth() will look for occweb credentials in $HOME/.netrc + response = requests.get(url, auth=get_auth(), timeout=30) + Path('glimmondb.sqlite3').write_bytes(response.content) + #----------------------------------------------------------------------------------------- #-- test_and_save: save a copy of op_limit.db and glimon to Past_data directory -- @@ -401,20 +403,20 @@ def test_and_save(): #--- update the main mta limit database # if len(data) < 1: - cmd = 'rm ' + temp_opfile + cmd = f'rm {temp_opfile}' os.system(cmd) else: - cmd = 'mv ' + temp_opfile + ' ' + main_dir +'op_limits.db' + cmd = f'mv {temp_opfile} {main_dir}/op_limits.db' os.system(cmd) tail = time.strftime("%m%d%y", time.gmtime()) - cmd = 'cp ' + main_dir + 'op_limits.db ' + main_dir + 'Past_data/op_limits.db_' + tail + cmd = f'cp {main_dir}/op_limits.db {main_dir}/Past_data/op_limits.db_{tail}' os.system(cmd) - cmd = 'cp -f ' + main_dir + glimmon + '/data/mta4/MTA/data/op_limits/.' + cmd = f'cp -f {glimmon} /data/mta4/MTA/data/op_limits/.' os.system(cmd) - cmd = 'cp ' + main_dir + glimmon + ' ' + main_dir + 'Past_data/' + glimmon + '_' + tail + cmd = f'cp {glimmon} {main_dir}/Past_data/glimmondb.sqlite3_{tail}' os.system(cmd) # #--- notify the changes to admin person