Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
network
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
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
infra
ansible-shared
network
Commits
785b6d72
Commit
785b6d72
authored
7 years ago
by
Robin Sonnabend
Browse files
Options
Downloads
Patches
Plain Diff
Fix arrow direction, remove duplicate switch-switch lines
parent
a7dcb35b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
mrtg/files/makeweather.py
+8
-12
8 additions, 12 deletions
mrtg/files/makeweather.py
with
8 additions
and
12 deletions
mrtg/files/makeweather.py
+
8
−
12
View file @
785b6d72
...
@@ -94,11 +94,15 @@ def get_total_speed(links):
...
@@ -94,11 +94,15 @@ def get_total_speed(links):
return
sum
(
link
.
get_speed
()
for
link
in
links
if
link
.
get_speed
()
is
not
None
)
return
sum
(
link
.
get_speed
()
for
link
in
links
if
link
.
get_speed
()
is
not
None
)
def
group_links
(
links
):
def
group_links
(
links
):
def
_make_name
(
link
):
def
_make_name
(
link
,
invert
=
False
):
return
"
{} {}
"
.
format
(
link
.
node_from
,
link
.
node_to
)
name_from
,
name_to
=
link
.
node_from
,
link
.
node_to
if
invert
:
name_from
,
name_to
=
name_to
,
name_from
return
"
{} {}
"
.
format
(
name_from
,
name_to
)
groups
=
{}
groups
=
{}
for
link
in
links
:
for
link
in
links
:
name
=
_make_name
(
link
)
name
=
_make_name
(
link
)
if
_make_name
(
link
,
invert
=
True
)
not
in
groups
:
groups
[
name
]
=
groups
.
get
(
name
,
[])
+
[
link
]
groups
[
name
]
=
groups
.
get
(
name
,
[])
+
[
link
]
result
=
[]
result
=
[]
for
group
in
groups
.
values
():
for
group
in
groups
.
values
():
...
@@ -252,7 +256,7 @@ class ConfigWriter:
...
@@ -252,7 +256,7 @@ class ConfigWriter:
def
write_links
(
self
,
links
):
def
write_links
(
self
,
links
):
self
.
write
(
"
LINK {}
"
.
format
(
"
,
"
.
join
(
link
.
name
for
link
in
links
)))
self
.
write
(
"
LINK {}
"
.
format
(
"
,
"
.
join
(
link
.
name
for
link
in
links
)))
self
.
write
(
"
NODES {} {}
"
.
format
(
links
[
0
].
node_
from
,
links
[
0
].
node_
to
),
1
)
self
.
write
(
"
NODES {} {}
"
.
format
(
links
[
0
].
node_
to
,
links
[
0
].
node_
from
),
1
)
self
.
write
(
"
TARGET {}
"
.
format
(
"
"
.
join
(
self
.
write
(
"
TARGET {}
"
.
format
(
"
"
.
join
(
os
.
path
.
join
(
self
.
source_path
,
link
.
name
+
"
.html
"
)
os
.
path
.
join
(
self
.
source_path
,
link
.
name
+
"
.html
"
)
for
link
in
links
)),
1
)
for
link
in
links
)),
1
)
...
@@ -261,14 +265,6 @@ class ConfigWriter:
...
@@ -261,14 +265,6 @@ class ConfigWriter:
self
.
write
(
"
WIDTH {}
"
.
format
(
6
if
total_speed
==
2
else
(
8
if
total_speed
==
20
else
4
)),
1
)
self
.
write
(
"
WIDTH {}
"
.
format
(
6
if
total_speed
==
2
else
(
8
if
total_speed
==
20
else
4
)),
1
)
self
.
write
()
self
.
write
()
def
write_link
(
self
,
link
):
self
.
write
(
"
LINK {}
"
.
format
(
link
.
name
))
self
.
write
(
"
NODES {} {}
"
.
format
(
link
.
node_from
,
link
.
node_to
),
1
)
# TODO: bandwidth
self
.
write
(
"
TARGET {}
"
.
format
(
os
.
path
.
join
(
self
.
source_path
,
link
.
name
+
"
.html
"
)),
1
)
self
.
write
()
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
import
argparse
import
argparse
...
...
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