FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
netdata/.github/scripts/platform-impending-eol.py at master · itmanlee/netdata · GitHub
itmanlee
/
netdata
Public
forked from
netdata/netdata
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
netdata
/
.github
/
scripts
/
platform-impending-eol.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
58 lines (48 loc) · 1.54 KB
Breadcrumbs
netdata
/
.github
/
scripts
/
platform-impending-eol.py
Copy path
File metadata and controls
executable file
·
58 lines (48 loc) · 1.54 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
'''Check if a given distro is going to be EOL soon.
This queries the public API of https://endoflife.date to fetch EOL dates.
‘soon’ is defined by LEAD_DAYS, currently 30 days.'''
import
datetime
import
json
import
sys
import
urllib
.
request
URL_BASE
=
'https://endoflife.date/api'
NOW
=
datetime
.
date
.
today
()
LEAD_DAYS
=
datetime
.
timedelta
(
days
=
30
)
DISTRO
=
sys
.
argv
[
1
]
RELEASE
=
sys
.
argv
[
2
]
EXIT_NOT_IMPENDING
=
0
EXIT_IMPENDING
=
1
EXIT_NO_DATA
=
2
EXIT_FAILURE
=
3
try
:
with
urllib
.
request
.
urlopen
(
f'
{
URL_BASE
}
/
{
DISTRO
}
/
{
RELEASE
}
.json'
)
as
response
:
match
response
.
status
:
case
200
:
data
=
json
.
load
(
response
)
case
_:
print
(
f'Failed to retrieve data for
{
DISTRO
}
{
RELEASE
}
'
+
f'(status:
{
response
.
status
}
).'
,
file
=
sys
.
stderr
)
sys
.
exit
(
EXIT_FAILURE
)
except
urllib
.
error
.
HTTPError
as
e
:
match
e
.
code
:
case
404
:
print
(
f'No data available for
{
DISTRO
}
{
RELEASE
}
.'
,
file
=
sys
.
stderr
)
sys
.
exit
(
EXIT_NO_DATA
)
case
_:
print
(
f'Failed to retrieve data for
{
DISTRO
}
{
RELEASE
}
'
+
f'(status:
{
e
.
code
}
).'
,
file
=
sys
.
stderr
)
sys
.
exit
(
EXIT_FAILURE
)
eol
=
datetime
.
date
.
fromisoformat
(
data
[
'eol'
])
offset
=
abs
(
eol
-
NOW
)
if
offset
<=
LEAD_DAYS
:
print
(
data
[
'eol'
])
sys
.
exit
(
EXIT_IMPENDING
)
else
:
sys
.
exit
(
EXIT_NOT_IMPENDING
)
Back
|
FazBrowse Home
|
New Git URL