Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
in20tools_old
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
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
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
Tobias WEBER
in20tools_old
Commits
bc89b1b7
Commit
bc89b1b7
authored
6 years ago
by
Tobias WEBER
Browse files
Options
Downloads
Patches
Plain Diff
quick and dirty helper tool for instrumental report
parent
1e3b0d28
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tools/report/report.py
+121
-0
121 additions, 0 deletions
tools/report/report.py
with
121 additions
and
0 deletions
tools/report/report.py
0 → 100644
+
121
−
0
View file @
bc89b1b7
#
# compiles proposal details for instrumental report
# @author Tobias Weber <tweber@ill.fr>
# @date feb-19
# @license see 'LICENSE' file
#
#
# constants
#
prop_detail_url
=
"
https://userclub.ill.eu/userclub/proposalSearch/details/%d
"
#
# downloads proposal detail information
#
def
get_prop_details
(
prop_no
,
session_no
):
infos
=
{
\
"
allproposers
"
:
[],
"
alllabs
"
:
[],
"
allcountries
"
:
[],
\
"
allinstruments
"
:
[],
"
allreqdays
"
:
[],
"
allallocdays
"
:
[],
"
allgrades
"
:
[],
"
allschedules
"
:
[],
\
}
#import requests as req
import
requests_html
as
req
#with req.Session() as session:
with
req
.
HTMLSession
()
as
session
:
cookies
=
{
"
JSESSIONID
"
:
session_no
}
headers
=
{
"
User-Agent
"
:
"
n/a
"
}
reply
=
session
.
get
(
prop_detail_url
%
prop_no
,
cookies
=
cookies
,
headers
=
headers
)
if
reply
.
status_code
!=
200
:
return
None
# get main proposer
for
elem
in
reply
.
html
.
xpath
(
"
div[1]/div[3]/div[1]/p/text()
"
,
clean
=
False
):
name
=
elem
.
strip
()
if
(
name
!=
""
):
infos
[
"
mainproposer
"
]
=
name
break
# get local contact
for
elem
in
reply
.
html
.
xpath
(
"
div[1]/div[4]/p/text()
"
,
clean
=
False
):
name
=
elem
.
strip
()
if
(
name
!=
""
):
infos
[
"
localcontact
"
]
=
name
break
# get council
for
elem
in
reply
.
html
.
xpath
(
"
div[1]/div[1]/p/text()
"
,
clean
=
False
):
name
=
elem
.
strip
()
if
(
name
!=
""
):
infos
[
"
council
"
]
=
name
break
# get proposal id
for
elem
in
reply
.
html
.
xpath
(
"
div[1]/div[2]/div[1]/p/text()
"
,
clean
=
False
):
name
=
elem
.
strip
()
if
(
name
!=
""
):
infos
[
"
id
"
]
=
name
break
# get proposal title
for
elem
in
reply
.
html
.
xpath
(
"
div[1]/div[2]/div[2]/p/text()
"
,
clean
=
False
):
name
=
elem
.
strip
()
if
(
name
!=
""
):
infos
[
"
title
"
]
=
name
break
# get sample environments
for
elem
in
reply
.
html
.
xpath
(
"
div[1]/div[5]/p/text()
"
,
clean
=
False
):
name
=
elem
.
strip
()
if
(
name
!=
""
):
infos
[
"
env
"
]
=
name
break
# get all proposers and affiliations
for
elem
in
reply
.
html
.
xpath
(
"
div[1]/div[3]/div[3]/table/tbody/*
"
,
clean
=
False
):
row
=
elem
.
xpath
(
"
tr/td/text()
"
)
infos
[
"
allproposers
"
].
append
(
row
[
0
].
strip
())
infos
[
"
alllabs
"
].
append
(
row
[
1
].
strip
())
infos
[
"
allcountries
"
].
append
(
row
[
2
].
strip
())
# get all requested instruments
for
elem
in
reply
.
html
.
xpath
(
"
div[1]/div[6]/table/tbody/*
"
,
clean
=
False
):
row
=
elem
.
xpath
(
"
tr/td/text()
"
)
infos
[
"
allinstruments
"
].
append
(
row
[
0
].
strip
())
infos
[
"
allreqdays
"
].
append
(
row
[
1
].
strip
())
infos
[
"
allallocdays
"
].
append
(
row
[
2
].
strip
())
infos
[
"
allgrades
"
].
append
(
row
[
3
].
strip
())
infos
[
"
allschedules
"
].
append
(
row
[
4
].
strip
())
return
infos
return
None
# -----------------------------------------------------------------------------
import
sys
if
len
(
sys
.
argv
)
<
2
:
print
(
"
Please specify a session id.
"
)
exit
(
-
1
)
session_no
=
sys
.
argv
[
1
]
#prop_no = 79781
prop_no
=
79659
infos
=
get_prop_details
(
prop_no
,
session_no
)
print
(
infos
)
# -----------------------------------------------------------------------------
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