mirror of
https://github.com/aljazceru/plugins.git
synced 2025-12-23 16:14:20 +01:00
summary: fix flake8 nits
This commit is contained in:
committed by
Christian Decker
parent
258c0e647a
commit
2034c29214
@@ -4,7 +4,6 @@ from packaging import version
|
|||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from summary_avail import *
|
from summary_avail import *
|
||||||
import pyln.client
|
import pyln.client
|
||||||
from math import floor, log10
|
|
||||||
import requests
|
import requests
|
||||||
import shelve
|
import shelve
|
||||||
import threading
|
import threading
|
||||||
@@ -174,7 +173,6 @@ def summary(plugin, exclude=''):
|
|||||||
# Create simple line graph, 47 chars wide.
|
# Create simple line graph, 47 chars wide.
|
||||||
our_len = int(round(int(c.ours) / biggest * 23))
|
our_len = int(round(int(c.ours) / biggest * 23))
|
||||||
their_len = int(round(int(c.theirs) / biggest * 23))
|
their_len = int(round(int(c.theirs) / biggest * 23))
|
||||||
divided = False
|
|
||||||
|
|
||||||
# We put midpoint in the middle.
|
# We put midpoint in the middle.
|
||||||
mid = draw.mid
|
mid = draw.mid
|
||||||
@@ -235,7 +233,7 @@ def init(options, configuration, plugin):
|
|||||||
plugin.avail_interval = float(options['summary-availability-interval'])
|
plugin.avail_interval = float(options['summary-availability-interval'])
|
||||||
plugin.avail_window = 60 * 60 * int(options['summary-availability-window'])
|
plugin.avail_window = 60 * 60 * int(options['summary-availability-window'])
|
||||||
plugin.persist = shelve.open('summary.dat', writeback=True)
|
plugin.persist = shelve.open('summary.dat', writeback=True)
|
||||||
if not 'peerstate' in plugin.persist:
|
if 'peerstate' not in plugin.persist:
|
||||||
plugin.persist['peerstate'] = {}
|
plugin.persist['peerstate'] = {}
|
||||||
plugin.persist['availcount'] = 0
|
plugin.persist['availcount'] = 0
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
# ensure an rpc peer is added
|
# ensure an rpc peer is added
|
||||||
|
|
||||||
|
|
||||||
def addpeer(p, rpcpeer):
|
def addpeer(p, rpcpeer):
|
||||||
pid = rpcpeer['id']
|
pid = rpcpeer['id']
|
||||||
if not pid in p.persist['peerstate']:
|
if pid not in p.persist['peerstate']:
|
||||||
p.persist['peerstate'][pid] = {
|
p.persist['peerstate'][pid] = {
|
||||||
'connected': rpcpeer['connected'],
|
'connected': rpcpeer['connected'],
|
||||||
'last_seen': datetime.now() if rpcpeer['connected'] else None,
|
'last_seen': datetime.now() if rpcpeer['connected'] else None,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import subprocess
|
|||||||
import unittest
|
import unittest
|
||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
|
import os
|
||||||
|
|
||||||
from pyln.client import Plugin
|
from pyln.client import Plugin
|
||||||
from pyln.testing.fixtures import * # noqa: F401,F403
|
from pyln.testing.fixtures import * # noqa: F401,F403
|
||||||
@@ -64,9 +65,9 @@ def test_summary_avail_101():
|
|||||||
assert(plugin.persist['peerstate']['1']['avail'] == 1.0)
|
assert(plugin.persist['peerstate']['1']['avail'] == 1.0)
|
||||||
assert(plugin.persist['peerstate']['2']['avail'] == 0.0)
|
assert(plugin.persist['peerstate']['2']['avail'] == 0.0)
|
||||||
assert(plugin.persist['peerstate']['3']['avail'] == 1.0)
|
assert(plugin.persist['peerstate']['3']['avail'] == 1.0)
|
||||||
assert(plugin.persist['peerstate']['1']['connected'] == True)
|
assert(plugin.persist['peerstate']['1']['connected'] is True)
|
||||||
assert(plugin.persist['peerstate']['2']['connected'] == False)
|
assert(plugin.persist['peerstate']['2']['connected'] is False)
|
||||||
assert(plugin.persist['peerstate']['3']['connected'] == True)
|
assert(plugin.persist['peerstate']['3']['connected'] is True)
|
||||||
|
|
||||||
|
|
||||||
# tests for 50% downtime
|
# tests for 50% downtime
|
||||||
|
|||||||
Reference in New Issue
Block a user