Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Peder Bergebakken Sundt
geteduroam-scraper
Commits
14ad0507
Commit
14ad0507
authored
Aug 14, 2020
by
Peder Bergebakken Sundt
Browse files
Copy back in some old code
parent
5a23a263
Changes
1
Hide whitespace changes
Inline
Side-by-side
scrape.py
View file @
14ad0507
...
...
@@ -22,6 +22,25 @@ def call(*a, **kw): # decorator builder
return
decorator
def
dump_eap_configs
(
discovery
):
# download in paralell, write in series
with
ThreadPoolExecutor
(
max_workers
=
300
)
as
e
:
futures
=
[]
for
instance
in
discovery
[
"instances"
]:
#print(instance["cat_idp"])
for
profile
in
instance
[
"profiles"
]:
if
profile
.
get
(
"oauth"
)
==
False
:
name
=
profile
[
"id"
]
#print(name)
url
=
profile
[
"eapconfig_endpoint"
]
futures
.
append
((
name
,
e
.
submit
(
requests
.
get
,
url
)))
for
name
,
future
in
futures
:
with
open
(
f
"eap-configs/
{
name
}
.eap-config"
,
"w"
)
as
f
:
f
.
write
(
future
.
result
().
text
)
print
(
"wrote"
,
name
)
def
get_eap_configs
(
discovery
,
profile_handler
):
with
ThreadPoolExecutor
(
max_workers
=
N_WORKERS
)
as
e
:
for
instance
in
discovery
[
"instances"
]:
# feature request: ability to download a partial EAP config for Oauth=True profiles
...
...
@@ -38,9 +57,6 @@ def get_eap_configs(discovery, profile_handler):
resp
=
future
.
result
()
if
not
resp
.
ok
:
return
# todo, print why?
#with open(f"eap-configs/{profile["id"]}.eap-config", "w") as f:
# f.write(eap_config_xml)
eap_config_xml
=
resp
.
text
try
:
profile_handler
(
profile
[
"id"
],
eap_config_xml
,
profile
,
instance
)
...
...
@@ -236,7 +252,6 @@ def run_rad_eap_test(*,
#pprint(DISCOVERY)
#dump_eap_configs(DISCOVERY)
get_eap_configs
(
DISCOVERY
,
parse_profile
)
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment