Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Chronos
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AlekSIS®
Official
AlekSIS-App-Chronos
Commits
2138ec63
Commit
2138ec63
authored
5 years ago
by
Jonathan Weth
Browse files
Options
Downloads
Patches
Plain Diff
Fine tuning of debug logs
parent
298911b7
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
biscuit/apps/chronos/m2l.py
+5
-3
5 additions, 3 deletions
biscuit/apps/chronos/m2l.py
biscuit/apps/chronos/pdf.py
+2
-1
2 additions, 1 deletion
biscuit/apps/chronos/pdf.py
biscuit/apps/chronos/views.py
+19
-10
19 additions, 10 deletions
biscuit/apps/chronos/views.py
with
26 additions
and
14 deletions
biscuit/apps/chronos/m2l.py
+
5
−
3
View file @
2138ec63
import
os
import
os
import
subprocess
import
subprocess
from
debug.models
import
register_log_with_filename
from
schoolapps.settings
import
BASE_DIR
from
schoolapps.settings
import
BASE_DIR
...
@@ -21,9 +22,10 @@ def convert_markdown_2_latex(s):
...
@@ -21,9 +22,10 @@ def convert_markdown_2_latex(s):
os
.
path
.
join
(
BASE_DIR
,
"
latex
"
,
"
m2l.md
"
))
os
.
path
.
join
(
BASE_DIR
,
"
latex
"
,
"
m2l.md
"
))
process
=
subprocess
.
Popen
(
bash_command
.
split
(),
stdout
=
subprocess
.
PIPE
)
process
=
subprocess
.
Popen
(
bash_command
.
split
(),
stdout
=
subprocess
.
PIPE
)
output
=
process
.
communicate
()[
0
]
output
=
process
.
communicate
()[
0
]
print
(
"
[MD TO LATEX]
"
,
output
)
del
output
print
(
"
[RETURN CODE]
"
,
process
.
returncode
)
# register_log_with_filename("m2l", "m2l", "m2l.log", process.returncode)
# Register log file in debugging tool
register_log_with_filename
(
"
m2l
"
,
"
m2l
"
,
"
m2l.log
"
,
process
.
returncode
)
# Read converted latex from file
# Read converted latex from file
tex_file
=
open
(
os
.
path
.
join
(
BASE_DIR
,
"
latex
"
,
"
m2l.tex
"
),
"
r
"
,
encoding
=
"
utf8
"
)
tex_file
=
open
(
os
.
path
.
join
(
BASE_DIR
,
"
latex
"
,
"
m2l.tex
"
),
"
r
"
,
encoding
=
"
utf8
"
)
...
...
This diff is collapsed.
Click to expand it.
biscuit/apps/chronos/pdf.py
+
2
−
1
View file @
2138ec63
...
@@ -23,9 +23,10 @@ def generate_pdf(tex, filename):
...
@@ -23,9 +23,10 @@ def generate_pdf(tex, filename):
filename
))
filename
))
process
=
subprocess
.
Popen
(
bash_command
.
split
(),
stdout
=
subprocess
.
PIPE
)
process
=
subprocess
.
Popen
(
bash_command
.
split
(),
stdout
=
subprocess
.
PIPE
)
output
=
process
.
communicate
()[
0
]
output
=
process
.
communicate
()[
0
]
del
output
# Register log file in debugging tool
register_log_with_filename
(
"
latex_{}
"
.
format
(
filename
),
"
latex
"
,
"
{}.log
"
.
format
(
filename
),
process
.
returncode
)
register_log_with_filename
(
"
latex_{}
"
.
format
(
filename
),
"
latex
"
,
"
{}.log
"
.
format
(
filename
),
process
.
returncode
)
print
(
"
[LATEX]
"
,
output
)
def
generate_class_tex
(
subs
,
date
,
header_info
,
hints
=
None
):
def
generate_class_tex
(
subs
,
date
,
header_info
,
hints
=
None
):
...
...
This diff is collapsed.
Click to expand it.
biscuit/apps/chronos/views.py
+
19
−
10
View file @
2138ec63
import
datetime
import
datetime
import
os
import
os
import
traceback
from
PyPDF2
import
PdfFileMerger
from
PyPDF2
import
PdfFileMerger
from
django.contrib.auth.decorators
import
login_required
,
permission_required
from
django.contrib.auth.decorators
import
login_required
,
permission_required
...
@@ -7,6 +8,7 @@ from django.http import Http404, FileResponse
...
@@ -7,6 +8,7 @@ from django.http import Http404, FileResponse
from
django.shortcuts
import
render
,
redirect
,
get_object_or_404
from
django.shortcuts
import
render
,
redirect
,
get_object_or_404
from
django.utils
import
timezone
from
django.utils
import
timezone
from
debug.models
import
register_traceback
,
register_return_0
from
schoolapps.settings
import
SHORT_WEEK_DAYS
,
LONG_WEEK_DAYS
from
schoolapps.settings
import
SHORT_WEEK_DAYS
,
LONG_WEEK_DAYS
from
timetable.filters
import
HintFilter
from
timetable.filters
import
HintFilter
from
timetable.forms
import
HintForm
from
timetable.forms
import
HintForm
...
@@ -299,16 +301,23 @@ def sub_pdf(request):
...
@@ -299,16 +301,23 @@ def sub_pdf(request):
generate_pdf
(
tex
,
"
class{}
"
.
format
(
i
))
generate_pdf
(
tex
,
"
class{}
"
.
format
(
i
))
# Merge PDFs
# Merge PDFs
merger
=
PdfFileMerger
()
try
:
class0
=
open
(
os
.
path
.
join
(
BASE_DIR
,
"
latex
"
,
"
class0.pdf
"
),
"
rb
"
)
merger
=
PdfFileMerger
()
class1
=
open
(
os
.
path
.
join
(
BASE_DIR
,
"
latex
"
,
"
class1.pdf
"
),
"
rb
"
)
class0
=
open
(
os
.
path
.
join
(
BASE_DIR
,
"
latex
"
,
"
class0.pdf
"
),
"
rb
"
)
merger
.
append
(
fileobj
=
class0
)
class1
=
open
(
os
.
path
.
join
(
BASE_DIR
,
"
latex
"
,
"
class1.pdf
"
),
"
rb
"
)
merger
.
append
(
fileobj
=
class1
)
merger
.
append
(
fileobj
=
class0
)
merger
.
append
(
fileobj
=
class1
)
# Write merged PDF to class.pdf
output
=
open
(
os
.
path
.
join
(
BASE_DIR
,
"
latex
"
,
"
class.pdf
"
),
"
wb
"
)
# Write merged PDF to class.pdf
merger
.
write
(
output
)
output
=
open
(
os
.
path
.
join
(
BASE_DIR
,
"
latex
"
,
"
class.pdf
"
),
"
wb
"
)
output
.
close
()
merger
.
write
(
output
)
output
.
close
()
# Register successful merge in debugging tool
register_return_0
(
"
merge_class
"
,
"
pypdf2
"
)
except
Exception
:
# Register exception in debugging tool
register_traceback
(
"
merge_class
"
,
"
pypdf2
"
)
# Read and response PDF
# Read and response PDF
file
=
open
(
os
.
path
.
join
(
BASE_DIR
,
"
latex
"
,
"
class.pdf
"
),
"
rb
"
)
file
=
open
(
os
.
path
.
join
(
BASE_DIR
,
"
latex
"
,
"
class.pdf
"
),
"
rb
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment