Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
importhal
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
basdorea
importhal
Commits
ad48985b
Commit
ad48985b
authored
1 year ago
by
bastien
Browse files
Options
Downloads
Patches
Plain Diff
add test TEI files to SWORD API + fix some stuff
parent
3709ad9e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hal/create_xml2hal.py
+2
-1
2 additions, 1 deletion
hal/create_xml2hal.py
hal/management/commands/send_test_tei.py
+47
-0
47 additions, 0 deletions
hal/management/commands/send_test_tei.py
with
49 additions
and
1 deletion
hal/create_xml2hal.py
+
2
−
1
View file @
ad48985b
...
@@ -300,7 +300,8 @@ def createXml_sendHal(numero,listauthors, lang_title, title_publi, name_conf, nb
...
@@ -300,7 +300,8 @@ def createXml_sendHal(numero,listauthors, lang_title, title_publi, name_conf, nb
@shared_task
@shared_task
def
sendselect_2hal
(
name_user
,
login_user
,
id_hal_user
,
mail_reponse
,
labo_auth_final
,
listdomains
,
login_depot
,
passwd_depot
,
choice_depot
,
list_publis_to_update
,
csvfile
):
def
sendselect_2hal
(
name_user
,
login_user
,
id_hal_user
,
mail_reponse
,
labo_auth_final
,
listdomains
,
login_depot
,
passwd_depot
,
choice_depot
,
list_publis_to_update
,
csvfile
):
print
(
"
list_publis_to_update
"
)
print
(
list_publis_to_update
)
mail_message
=
"
Bonjour
\n\n
Suite à votre demande sur l
'
appli Haltools, veuillez trouver ci-dessous les résultats de dépôts.
\n\n
"
mail_message
=
"
Bonjour
\n\n
Suite à votre demande sur l
'
appli Haltools, veuillez trouver ci-dessous les résultats de dépôts.
\n\n
"
with
open
(
'
bibtex_csv_files/
'
+
csvfile
+
'
.csv
'
,
'
r
'
,
newline
=
''
,
encoding
=
'
utf-8
'
)
as
csv_file
:
with
open
(
'
bibtex_csv_files/
'
+
csvfile
+
'
.csv
'
,
'
r
'
,
newline
=
''
,
encoding
=
'
utf-8
'
)
as
csv_file
:
csvr
=
csv
.
reader
(
csv_file
,
delimiter
=
'
,
'
)
csvr
=
csv
.
reader
(
csv_file
,
delimiter
=
'
,
'
)
...
...
This diff is collapsed.
Click to expand it.
hal/management/commands/send_test_tei.py
0 → 100644
+
47
−
0
View file @
ad48985b
from
django.core.management.base
import
BaseCommand
,
CommandError
from
haltools.settings
import
BASE_DIR
import
requests
class
Command
(
BaseCommand
):
help
=
"
Test sending file TEI to HAL through Sword API, just fill some variables to test
"
def
handle
(
self
,
*
args
,
**
options
):
print
(
"
begin
"
)
errormsg
=
''
requ_msg
=
''
login_user
=
'
bdoreau
'
id_hal_user
=
'
bastien-doreau
'
login_depot
=
'
bdoreau
'
passwd_depot
=
'
******
'
namefile
=
BASE_DIR
+
"
/xml_files/bdoreauCI1.xml
"
data
=
open
(
namefile
)
# HEADERS request
headers
=
{
'
Packaging
'
:
'
http://purl.org/net/sword-types/AOfr
'
,
'
Content-Type
'
:
'
text/xml
'
,
'
On-Behalf-Of
'
:
'
login|
'
+
login_user
+
'
;idhal|
'
+
id_hal_user
,
}
try
:
response
=
requests
.
post
(
'
https://api-preprod.archives-ouvertes.fr/sword/hal/
'
,
headers
=
headers
,
data
=
data
,
auth
=
(
login_depot
,
passwd_depot
),
timeout
=
60
)
except
requests
.
exceptions
.
RequestException
as
e
:
print
(
"
ERROR REQUEST {0}
"
.
format
(
e
))
requ_msg
+=
"
ERROR REQUEST : {0} --
"
.
format
(
e
)
except
requests
.
exceptions
.
Timeout
as
t
:
print
(
"
ERROR TIMEOUT REQUEST {0}
"
.
format
(
t
))
requ_msg
+=
"
ERROR TIMEOUT : {0} --
"
.
format
(
t
)
print
(
"
response POST : code {0}
"
.
format
(
response
.
status_code
))
print
(
"
response POST : text {0}
"
.
format
(
response
.
text
))
code_http
=
response
.
status_code
if
(
code_http
!=
200
)
and
(
code_http
!=
202
)
:
requ_msg
+=
"
RESPONSE : {0}
"
.
format
(
response
.
text
)
else
:
requ_msg
+=
"
RESPONSE : OK {0}
"
.
format
(
errormsg
)
return
None
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