Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Odevzdávací Systém MO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Mareš
Odevzdávací Systém MO
Commits
6e7d3b97
Commit
6e7d3b97
authored
3 years ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
fix-submits: Nastavujeme fixed_at
parent
7f041d63
No related branches found
No related tags found
1 merge request
!109
Automatická oprava rozbitých PDF
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/fix-submits
+5
-4
5 additions, 4 deletions
bin/fix-submits
with
5 additions
and
4 deletions
bin/fix-submits
+
5
−
4
View file @
6e7d3b97
#!/usr/bin/env python3
#!/usr/bin/env python3
import
argparse
import
argparse
import
datetime
import
os
import
os
from
sqlalchemy.orm
import
joinedload
from
sqlalchemy.orm
import
joinedload
import
subprocess
import
subprocess
...
@@ -29,7 +30,7 @@ def fix_paper(id: int):
...
@@ -29,7 +30,7 @@ def fix_paper(id: int):
.
get
(
id
))
.
get
(
id
))
assert
paper
is
not
None
assert
paper
is
not
None
assert
paper
.
orig_file_name
is
not
None
assert
paper
.
orig_file_name
is
not
None
print
(
f
"
=== Paper #
{
id
}
(
{
paper
.
orig_file_name
}
)
"
)
print
(
f
"
=== Paper #
{
id
}
(
{
paper
.
orig_file_name
}
)
{
'
[RETRY]
'
if
paper
.
fixed_at
else
''
}
"
)
tmp_file
=
tempfile
.
NamedTemporaryFile
(
dir
=
mo
.
util
.
data_dir
(
'
tmp
'
),
prefix
=
'
fix-
'
)
tmp_file
=
tempfile
.
NamedTemporaryFile
(
dir
=
mo
.
util
.
data_dir
(
'
tmp
'
),
prefix
=
'
fix-
'
)
res
=
subprocess
.
run
([
'
qpdf
'
,
os
.
path
.
join
(
mo
.
util
.
data_dir
(
'
submits
'
),
paper
.
orig_file_name
),
tmp_file
.
name
])
res
=
subprocess
.
run
([
'
qpdf
'
,
os
.
path
.
join
(
mo
.
util
.
data_dir
(
'
submits
'
),
paper
.
orig_file_name
),
tmp_file
.
name
])
...
@@ -37,16 +38,16 @@ def fix_paper(id: int):
...
@@ -37,16 +38,16 @@ def fix_paper(id: int):
sub
=
mo
.
submit
.
Submitter
()
sub
=
mo
.
submit
.
Submitter
()
try
:
try
:
sub
.
submit_fix
(
paper
,
tmp_file
.
name
)
sub
.
submit_fix
(
paper
,
tmp_file
.
name
)
sess
.
commit
()
fixed
+=
1
fixed
+=
1
except
mo
.
submit
.
SubmitException
:
except
mo
.
submit
.
SubmitException
:
sess
.
rollback
()
errors
+=
1
errors
+=
1
else
:
else
:
print
(
f
'
--> ERROR: qpdf failed with exit code
{
res
.
returncode
}
'
)
print
(
f
'
--> ERROR: qpdf failed with exit code
{
res
.
returncode
}
'
)
sess
.
rollback
()
errors
+=
1
errors
+=
1
paper
.
fixed_at
=
datetime
.
datetime
.
now
()
sess
.
commit
()
if
args
.
id
is
not
None
:
if
args
.
id
is
not
None
:
fix_paper
(
args
.
id
)
fix_paper
(
args
.
id
)
...
...
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