From 3c13f62bd15f8ebfdac368d037cd0cd8a6df5583 Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Sun, 14 Aug 2022 23:40:56 +0300 Subject: re-fettled scan upload, creates Wallet object earlier --- parsers/scans.py | 64 +++----------------------------------------------------- 1 file changed, 3 insertions(+), 61 deletions(-) (limited to 'parsers/scans.py') diff --git a/parsers/scans.py b/parsers/scans.py index 400bd74..1dbf17a 100644 --- a/parsers/scans.py +++ b/parsers/scans.py @@ -28,7 +28,7 @@ git = settings.GIT wallet_blank_json = { "cave": "", "date": "", - "description url": "/caves", + "description url": "1623/XXX", "description written": False, "electronic survey": False, "elev drawn": False, @@ -43,23 +43,7 @@ wallet_blank_json = { "survex file": [], "survex not required": False, "website updated": False} - -# wallet_blank_html = '''

Wallet WALLET

-#

List of trips: expedition/YEAR -# - troggle-processed .svx files and logbook entries on server

-#

Date:

People: Unknown,

-#

Cave Guidebook description -# - A description is indicated as being needed, so may need adding into this cave page. -#

Survex file: not identified yet -#

Issues

-#

The description needs writing

-#

The QMs needs writing

The website is marked as needing updating (using the guidebook description)

-#

Tunnel / Therion drawing files need drawing

-#

Files

-# -# -# ''' + def CheckEmptyDate(wallet): '''If date is not set, get it from a linked survex file. @@ -100,48 +84,6 @@ def LoadListScansFile(wallet): if c>=10: print(".", end='') c = 0 -def CopyWalletData(wallet): - '''Copies all the contents.json to a parallel set of folders in the drawings repo - refreshes everything during a full import, but it should all be up to date as every time - wallet data gets saved it should also be copied across and committed. - ''' - # not needed now the drawinsg repo is the master - return - - year = wallet.walletname[0:4] - destfolder = Path(settings.DRAWINGS_DATA,'walletjson', year, wallet.walletname) - destjson = destfolder / contentsjson - sourcejson = Path(wallet.fpath, contentsjson) - if not os.path.exists(Path(destfolder)): - try: - os.makedirs(destfolder) - print(f' - created folder {destfolder}..') - except PermissionError: - print(f"CANNOT save this JSON file.\nPERMISSIONS incorrectly set on server for this folder {destfolder}. Ask a nerd to fix this.") - if os.path.isfile(sourcejson): - try: - if not os.path.isfile(destjson) or not filecmp.cmp(sourcejson, destjson): - shutil.copy(sourcejson, destjson) - print(f' - Copied {sourcejson} to {destjson}') - dr_add = subprocess.run([git, "add", contentsjson], cwd=destfolder, capture_output=True, text=True) - if dr_add.returncode != 0: - msgdata = 'Ask a nerd to fix this.\n\n' + dr_add.stderr + '\n\n' + dr_add.stdout + '\n\nreturn code: ' + str(dr_add.returncode) - message = f'CANNOT git on server for this file {contentsjson}. Edits saved but not added to git.\n\n' + msgdata - print(message) - else: - # ideally we would commit many chnages to many wallets just once. But most of the time only a couple of files will change. - dr_commit = subprocess.run([git, "commit", "-m", f'Update of {contentsjson} in wallet'], cwd=destfolder, capture_output=True, text=True) - # This produces return code = 1 if it commits OK - if dr_commit.returncode != 0: - msgdata = 'Ask a nerd to fix this.\n\n' + dr_commit.stderr + '\n\n' + dr_commit.stdout + '\n\nreturn code: ' + str(dr_commit.returncode) - message = f'Error code with git on server for this {contentsjson}. File is copied, added to git, but NOT committed.\n\n' + msgdata - print(message) - - except PermissionError: - print(f"CANNOT copy this JSON file.\nPERMISSIONS incorrectly set on server for this file {destjson}. Ask a nerd to fix this.") - - - def load_all_scans(): '''This iterates through the scans directories (either here or on the remote server) @@ -186,7 +128,7 @@ def load_all_scans(): CheckEmptyPeople(wallet) wallet.save() LoadListScansFile(wallet) - CopyWalletData(wallet) + else: # but We should load all the scans, even for nonstandard names. -- cgit v1.2.3