mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-15 19:27:11 +00:00
re-fettled scan upload, creates Wallet object earlier
This commit is contained in:
@@ -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 = '''<html><body><H1>Wallet WALLET</H1>
|
||||
# <p>List of trips: <a href="http://expo.survex.com/expedition/YEAR">expedition/YEAR</a>
|
||||
# - troggle-processed .svx files and logbook entries on server</p>
|
||||
# <p>Date: </p><p>People: Unknown,</p>
|
||||
# <p>Cave <a href='http://expo.survex.com/caves/'>Guidebook description</a>
|
||||
# - A description is indicated as being needed, so may need adding into this cave page.
|
||||
# <p>Survex file: not identified yet
|
||||
# <H2>Issues</H2>
|
||||
# <p>The description needs writing</p>
|
||||
# <p>The QMs needs writing</p><p>The website is marked as needing updating (using the guidebook description)</p>
|
||||
# <p>Tunnel / Therion drawing files need drawing</p>
|
||||
# <H2>Files</H2>
|
||||
# <UL>
|
||||
# </UL>
|
||||
# </body></html>
|
||||
# '''
|
||||
|
||||
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user