SciPost Code Repository
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SciPost
Manage
Activity
Members
Labels
Plan
Issues
118
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SciPost
SciPost
Commits
1074d8b1
"preprints/apps.py" did not exist on "4f6ad46a3d97472475afa193d953ef9792721b4b"
Commit
1074d8b1
authored
1 year ago
by
George Katsikas
Browse files
Options
Downloads
Patches
Plain Diff
fix arxiv source fetcher for single files
parent
93c2e300
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scipost_django/production/management/commands/advance_git_repos.py
+36
-22
36 additions, 22 deletions
...jango/production/management/commands/advance_git_repos.py
with
36 additions
and
22 deletions
scipost_django/production/management/commands/advance_git_repos.py
+
36
−
22
View file @
1074d8b1
...
@@ -3,6 +3,7 @@ __license__ = "AGPL v3"
...
@@ -3,6 +3,7 @@ __license__ = "AGPL v3"
from
datetime
import
datetime
from
datetime
import
datetime
from
functools
import
reduce
from
functools
import
reduce
from
io
import
UnsupportedOperation
from
itertools
import
chain
,
cycle
from
itertools
import
chain
,
cycle
from
typing
import
Any
,
Callable
,
Dict
,
List
,
Tuple
from
typing
import
Any
,
Callable
,
Dict
,
List
,
Tuple
from
time
import
sleep
from
time
import
sleep
...
@@ -482,30 +483,43 @@ class Command(BaseCommand):
...
@@ -482,30 +483,43 @@ class Command(BaseCommand):
# Create file creation actions for each file in the source tar
# Create file creation actions for each file in the source tar
actions
=
[]
actions
=
[]
with
tarfile
.
open
(
fileobj
=
source_stream
.
raw
)
as
tar
:
try
:
for
member
in
tar
:
with
tarfile
.
open
(
fileobj
=
source_stream
.
raw
)
as
tar
:
if
not
member
.
isfile
():
for
member
in
tar
:
continue
if
not
member
.
isfile
():
continue
f
=
tar
.
extractfile
(
member
)
try
:
f
=
tar
.
extractfile
(
member
)
bin_content
=
f
.
read
()
try
:
actions
.
append
(
bin_content
=
f
.
read
()
{
actions
.
append
(
"
action
"
:
"
create
"
,
{
"
file_path
"
:
member
.
name
,
"
action
"
:
"
create
"
,
"
encoding
"
:
"
base64
"
,
"
file_path
"
:
member
.
name
,
# Encode the binary content in base64, required by the API
"
encoding
"
:
"
base64
"
,
"
content
"
:
b64encode
(
bin_content
).
decode
(
"
utf-8
"
),
# Encode the binary content in base64, required by the API
}
"
content
"
:
b64encode
(
bin_content
).
decode
(
"
utf-8
"
),
)
}
)
except
:
except
:
self
.
stdout
.
write
(
self
.
stdout
.
write
(
self
.
style
.
ERROR
(
self
.
style
.
ERROR
(
f
"
Could not read
{
member
.
name
}
from the arXiv source files, skipping...
"
f
"
Could not read
{
member
.
name
}
from the arXiv source files, skipping...
"
)
)
)
)
except
UnsupportedOperation
:
# The file is not a tar, but a single file (e.g. a TeX file)
# Refetch the source since the previous one was consumed
source
=
requests
.
get
(
paper
.
pdf_url
.
replace
(
"
pdf
"
,
"
src
"
))
actions
.
append
(
{
"
action
"
:
"
create
"
,
"
file_path
"
:
f
"
main.tex
"
,
"
encoding
"
:
"
base64
"
,
"
content
"
:
b64encode
(
source
.
content
).
decode
(
"
utf-8
"
),
}
)
# Filter out the files that already exist in the repo to avoid conflicts
# Filter out the files that already exist in the repo to avoid conflicts
project
=
self
.
GL
.
projects
.
get
(
repo
.
git_path
)
project
=
self
.
GL
.
projects
.
get
(
repo
.
git_path
)
...
...
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