diff --git a/Update Missing/log/20220715.log b/Update Missing/log/20220715.log index ae3d52f..720cfe4 100644 --- a/Update Missing/log/20220715.log +++ b/Update Missing/log/20220715.log @@ -23,3 +23,7 @@ py: 882746 comics in databased not retrieved in this round. py: 0 comics updated in database. py: Ids with error in server: py: 0 +sh: Moving old file to archive +sh: git add +sh: git rm +sh: Error: cannot git rm diff --git a/Update Missing/update.sh b/Update Missing/update.sh index e83ee5c..3ff52ce 100644 --- a/Update Missing/update.sh +++ b/Update Missing/update.sh @@ -2,8 +2,11 @@ d=`date +%Y%m%d` +prj_root=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P ) +cd "$prj_root" + log2file() { - echo "sh: $1" >> "log/$d.log" + echo "sh: $1" >> "$prj_root/log/$d.log" } error_exit() { @@ -11,22 +14,25 @@ error_exit() { exit 1 } -touch "log/$d.log" -echo "log: $d" >> "log/$d.log" +touch "$prj_root/log/$d.log" +echo "log: $d" >> "$prj_root/log/$d.log" log2file "Starting update.sh" fromdate=$(ls -1 *_latest.mcl |grep -Eo '[[:digit:]]{8}') || error_exit "cannot latest mcl file" +echo $fromdate + python2 update_missing.py log2file "Moving old file to archive" -mv "$fromdate""_latest.mcl" "archive/""$fromdate"".mcl" || error_exit "cannot mv to archive" +mv "$prj_root/$fromdate""_latest.mcl" "$prj_root/archive/""$fromdate"".mcl" || error_exit "cannot mv to archive" + log2file "git add" -git add "$d""_latest.mcl" "archive/" "log/" >> "log/$d.log" || error_exit "cannot git add" +git add "$d""_latest.mcl" "Deleted_Comics.txt" "archive/" "log/" >> "log/$d.log" || error_exit "cannot git add" -log2file "git rm" -git rm "$fromdate""_latest.mcl" >> "log/$d.log" || error_exit "cannot git rm" +#log2file "git rm" +#git rm "$fromdate""_latest.mcl" >> "log/$d.log" || error_exit "cannot git rm" log2file "git commit" git commit -m "Updated $d" >> "log/$d.log" || error_exit "cannot git commit" diff --git a/Update Missing/update_missing.py b/Update Missing/update_missing.py index 61953b8..0dde506 100755 --- a/Update Missing/update_missing.py +++ b/Update Missing/update_missing.py @@ -46,16 +46,18 @@ import os import re from datetime import date,datetime +ROOT_DIR = os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), '..')), 'Update Missing/') + temp = "" -for i in os.listdir(os.getcwd()): +for i in os.listdir(ROOT_DIR): if (i.find("_latest") != -1): temp=i old_date = re.search('[0-9]{8}',temp).group() -in_file = str(temp) -out_file = str(date.today().strftime("%Y%m%d")+"_latest.mcl") +in_file = str(ROOT_DIR)+str(temp) +out_file = str(ROOT_DIR)+str(date.today().strftime("%Y%m%d")+"_latest.mcl") data=[] -with open("../.apikey", "r") as f: +with open(ROOT_DIR+"/.apikey", "r") as f: data = f.readlines() api_key = str(data[0].strip('\n')) @@ -63,7 +65,7 @@ start_date = str(datetime.strptime(re.search('[0-9]{8}',temp).group(),"%Y%m%d"). end_date = str(date.today().strftime("%Y-%m-%d")) today_date = str(date.today().strftime("%Y%m%d")) -f1=open('log/'+today_date+'.log', 'a') +f1=open(ROOT_DIR+'log/'+today_date+'.log', 'a') if len(sys.argv) > 5: print "Using argvs" @@ -78,7 +80,7 @@ issues_number = {} issues_volume = {} skip_header = True cont = 0 - +exit print >>f1, "py: Reading in current database" for line in comiclist: @@ -191,7 +193,7 @@ for issue_id in issues_number.keys(): print >>f1, "py: Writing missings to file" -deleted_file = open("Deleted_Comics.txt", "wb") +deleted_file = open(ROOT_DIR+"Deleted_Comics.txt", "wb") for issue_id in non_retrieved_comics.keys(): deleted_file.write(str(issue_id)+"\n")