mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-12-01 22:31:53 +00:00
fix python2 python3 issues
This commit is contained in:
parent
8861e2e240
commit
37553da556
32
core/views_survex.py
Normal file → Executable file
32
core/views_survex.py
Normal file → Executable file
@ -15,7 +15,9 @@ from parsers.people import GetPersonExpeditionNameLookup
|
|||||||
import troggle.settings as settings
|
import troggle.settings as settings
|
||||||
import parsers.survex
|
import parsers.survex
|
||||||
|
|
||||||
survextemplatefile = """; *** DO NOT SAVE THIS FILE WITHOUT RENAMING IT !! ***
|
survextemplatefile = """; *** THIS IS A TEMPLATE FILE NOT WHAT YOU MIGHT BE EXPECTING ***
|
||||||
|
|
||||||
|
*** DO NOT SAVE THIS FILE WITHOUT RENAMING IT !! ***
|
||||||
;[Stuff in square brackets is example text to be replaced with real data,
|
;[Stuff in square brackets is example text to be replaced with real data,
|
||||||
; removing the square brackets]
|
; removing the square brackets]
|
||||||
|
|
||||||
@ -27,14 +29,14 @@ survextemplatefile = """; *** DO NOT SAVE THIS FILE WITHOUT RENAMING IT !! ***
|
|||||||
; Cave:
|
; Cave:
|
||||||
; Area in cave/QM:
|
; Area in cave/QM:
|
||||||
*title ""
|
*title ""
|
||||||
*date [2040.07.04]
|
*date [2040.07.04] ; <-- CHANGE THIS DATE
|
||||||
*team Insts [Fred Foo]
|
*team Insts [Fred Fossa]
|
||||||
*team Notes [Brenda Bar]
|
*team Notes [Brenda Badger]
|
||||||
*team Pics [Brenda Bar]
|
*team Pics [Luke Lynx]
|
||||||
*team Tape [Albert Anyone]
|
*team Tape [Albert Aadvark]
|
||||||
*instrument [SAP #+Laser Tape/DistoX/Compass # ; Clino #]
|
*instrument [SAP #+Laser Tape/DistoX/Compass # ; Clino #]
|
||||||
; Calibration: [Where, readings]
|
; Calibration: [Where, readings]
|
||||||
*ref 2040#00
|
*ref [2040#00] ; <-- CHANGE THIS TOO
|
||||||
; the #number is on the clear pocket containing the original notes
|
; the #number is on the clear pocket containing the original notes
|
||||||
|
|
||||||
; if using a tape:
|
; if using a tape:
|
||||||
@ -90,7 +92,7 @@ class SvxForm(forms.Form):
|
|||||||
filename = forms.CharField(widget=forms.TextInput(attrs={"readonly":True}))
|
filename = forms.CharField(widget=forms.TextInput(attrs={"readonly":True}))
|
||||||
datetime = forms.DateTimeField(widget=forms.TextInput(attrs={"readonly":True}))
|
datetime = forms.DateTimeField(widget=forms.TextInput(attrs={"readonly":True}))
|
||||||
outputtype = forms.CharField(widget=forms.TextInput(attrs={"readonly":True}))
|
outputtype = forms.CharField(widget=forms.TextInput(attrs={"readonly":True}))
|
||||||
code = forms.CharField(widget=forms.Textarea(attrs={"cols":150, "rows":18}))
|
code = forms.CharField(widget=forms.Textarea(attrs={"cols":150, "rows":36}))
|
||||||
|
|
||||||
def GetDiscCode(self):
|
def GetDiscCode(self):
|
||||||
fname = settings.SURVEX_DATA + self.data['filename'] + ".svx"
|
fname = settings.SURVEX_DATA + self.data['filename'] + ".svx"
|
||||||
@ -118,8 +120,17 @@ class SvxForm(forms.Form):
|
|||||||
if mbeginend.group(1) != mbeginend.group(2):
|
if mbeginend.group(1) != mbeginend.group(2):
|
||||||
return "Error: mismatching begin/end labels"
|
return "Error: mismatching begin/end labels"
|
||||||
|
|
||||||
fout = open(fname, "wt")
|
# Make this create new survex folders if needed
|
||||||
# javascript seems to insert CRLF on WSL1.
|
try:
|
||||||
|
fout = open(fname, "wb")
|
||||||
|
except IOError:
|
||||||
|
pth = os.path.dirname(self.data['filename'])
|
||||||
|
newpath = os.path.join(settings.SURVEX_DATA, pth)
|
||||||
|
if not os.path.exists(newpath):
|
||||||
|
os.makedirs(newpath)
|
||||||
|
fout = open(fname, "wb")
|
||||||
|
|
||||||
|
# javascript seems to insert CRLF on WSL1 whatever you say. So fix that:
|
||||||
res = fout.write(rcode.replace("\r",""))
|
res = fout.write(rcode.replace("\r",""))
|
||||||
fout.close()
|
fout.close()
|
||||||
return "SAVED ."
|
return "SAVED ."
|
||||||
@ -170,7 +181,6 @@ def svx(request, survex_file):
|
|||||||
form.data['code'] = rcode
|
form.data['code'] = rcode
|
||||||
if "save" in rform.data:
|
if "save" in rform.data:
|
||||||
if request.user.is_authenticated():
|
if request.user.is_authenticated():
|
||||||
#print("sssavvving")
|
|
||||||
message = form.SaveCode(rcode)
|
message = form.SaveCode(rcode)
|
||||||
else:
|
else:
|
||||||
message = "You do not have authority to save this file"
|
message = "You do not have authority to save this file"
|
||||||
|
Loading…
Reference in New Issue
Block a user