Skip to content

Commit

Permalink
convert_to error; playground modules showing as undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
jhpyle committed Jan 25, 2022
1 parent 6c6a1ed commit fbbbe56
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## [1.3.20] - 2022-01-25
### Fixed
- Error with the `.convert_to()` method of `DAFile`.
- Issue with display of modules in the Playground variables.

## [1.3.19] - 2022-01-17
### Fixed
- Issue with the sizing of images inside of `terms` descriptions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@
"Paraguay": Null
"Password and Retype Password did not match": Null
"Password is required": Null
"Password must be at least six characters long with at least one lowercase letter, at least one uppercase letter, and at least one number.": Null
"Password must have at least 6 characters with one lowercase letter, one uppercase letter and one number": Null
"password": Null
"Password": Null
Expand Down
19 changes: 11 additions & 8 deletions docassemble_base/docassemble/base/pandoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,20 +500,21 @@ def rtf_to_docx(in_file, out_file):
def convert_file(in_file, out_file, input_extension, output_extension):
if not UNOCONV_AVAILABLE:
initialize_libreoffice()
tempdir = tempfile.mkdtemp()
from_file = os.path.join(tempdir, "file1." + input_extension)
to_file = os.path.join(tempdir, "file2." + output_extension)
tempdir1 = tempfile.mkdtemp()
tempdir2 = tempfile.mkdtemp()
from_file = os.path.join(tempdir1, "file." + input_extension)
to_file = os.path.join(tempdir2, "file." + output_extension)
shutil.copyfile(in_file, from_file)
if UNOCONV_AVAILABLE:
subprocess_arguments = [UNOCONV_PATH, '-f', output_extension, '-o', to_file, from_file]
else:
subprocess_arguments = [LIBREOFFICE_PATH, '--headless', '--invisible', '--convert-to', output_extension, from_file, '--outdir', tempdir]
subprocess_arguments = [LIBREOFFICE_PATH, '--headless', '--invisible', '--convert-to', output_extension, from_file, '--outdir', tempdir2]
#logmessage("convert_to: creating " + to_file + " by doing " + " ".join(subprocess_arguments))
tries = 0
while tries < 5:
if UNOCONV_AVAILABLE:
try:
result = subprocess.run(subprocess_arguments, cwd=tempdir, timeout=120, check=False).returncode
result = subprocess.run(subprocess_arguments, cwd=tempdir1, timeout=120, check=False).returncode
except subprocess.TimeoutExpired:
logmessage("convert_file: unoconv took too long")
result = 1
Expand All @@ -523,7 +524,7 @@ def convert_file(in_file, out_file, input_extension, output_extension):
else:
docassemble.base.functions.server.applock('obtain', 'libreoffice')
try:
result = subprocess.run(subprocess_arguments, cwd=tempdir, timeout=120, check=False).returncode
result = subprocess.run(subprocess_arguments, cwd=tempdir1, timeout=120, check=False).returncode
except subprocess.TimeoutExpired:
logmessage("convert_file: libreoffice took too long")
result = 1
Expand All @@ -543,8 +544,10 @@ def convert_file(in_file, out_file, input_extension, output_extension):
time.sleep(0.5 + tries*random.random())
if result == 0:
shutil.copyfile(to_file, out_file)
if tempdir is not None:
shutil.rmtree(tempdir)
if tempdir1 is not None:
shutil.rmtree(tempdir1)
if tempdir2 is not None:
shutil.rmtree(tempdir2)
if result != 0:
return False
return True
Expand Down
15 changes: 7 additions & 8 deletions docassemble_webapp/docassemble/webapp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,7 @@ def password_validator(form, field):
if 'error message' in rules:
error_message = str(rules['error message'])
else:
#word("Password must be at least six characters long with at least one lowercase letter, at least one uppercase letter, and at least one number.")
error_message = 'Password must be at least ' + docassemble.base.functions.quantity_noun(rules.get('length', 6), 'character', language='en') + ' long'
standards = []
if rules.get('lowercase', 1) > 0:
Expand Down Expand Up @@ -3481,11 +3482,6 @@ def get_vars_in_use(interview, interview_status, debug_mode=False, return_json=F
if key not in field_origins:
field_origins[key] = set()
field_origins[key].add(question.from_source)
# if key == 'advocate':
# try:
# logmessage("Found advocate in " + question.content.original_text)
# except:
# logmessage("Found advocate")
for val in interview.questions:
names_used.add(val)
if val not in name_origins:
Expand Down Expand Up @@ -3539,9 +3535,8 @@ def get_vars_in_use(interview, interview_status, debug_mode=False, return_json=F
pg_code_cache[val] = {'doc': noquotetrunc(inspect.getdoc(user_dict[val])), 'name': str(val), 'insert': str(val), 'git': source_code_url(user_dict[val], datatype='module')}
except:
pg_code_cache[val] = {'doc': '', 'name': str(val), 'insert': str(val), 'git': source_code_url(user_dict[val], datatype='module')}
name_info[val] = copy.copy(pg_code_cache[val])
if 'git' in name_info[val]:
modules.add(val)
name_info[val] = copy.copy(pg_code_cache[val])
modules.add(val)
elif isinstance(user_dict[val], TypeType):
if val not in pg_code_cache:
bases = []
Expand Down Expand Up @@ -3638,6 +3633,10 @@ def get_vars_in_use(interview, interview_status, debug_mode=False, return_json=F
vocab_set.discard(var)
for var in [x for x in undefined_names if x.endswith(']')]:
undefined_names.discard(var)
for var in (functions | classes | modules):
undefined_names.discard(var)
for var in user_dict:
undefined_names.discard(var)
names_used = names_used.difference( undefined_names )
if return_json:
if len(names_used) > 0:
Expand Down

0 comments on commit fbbbe56

Please sign in to comment.