@@ -38,7 +38,7 @@ def configure_logging():
38
38
)
39
39
LOG .addHandler (GELF )
40
40
gelf_enabled = True
41
- LOG .info ('Initialized logging with GELF enabled: {}' . format ( gelf_enabled ) )
41
+ LOG .info (f 'Initialized logging with GELF enabled: { gelf_enabled } ' )
42
42
43
43
44
44
class EtherscanCollector :
@@ -77,18 +77,18 @@ def get_tokens(self):
77
77
decimals = 18
78
78
if token .get ('decimals' , - 1 ) >= 0 :
79
79
decimals = int (token ['decimals' ])
80
- LOG .debug ('{ } decimals for {}' . format ( decimals , token ['short' ]) )
80
+ LOG .debug (f" { decimals } decimals for { token ['short' ]} " )
81
81
try :
82
82
req = requests .get (self .settings ['url' ], params = request_data ).json ()
83
83
except (
84
84
requests .exceptions .ConnectionError ,
85
85
requests .exceptions .ReadTimeout ,
86
86
) as error :
87
- LOG .exception ('Exception caught: {}' . format ( error ) )
87
+ LOG .exception (f 'Exception caught: { error } ' )
88
88
req = {}
89
89
if req .get ('result' ) and int (req ['result' ]) > 0 :
90
90
self .tokens .update ({
91
- '{ }-{}' . format ( account , token ['short' ]) : {
91
+ f" { account } -{ token ['short' ]} " : {
92
92
'account' : account ,
93
93
'name' : token ['name' ],
94
94
'name_short' : token ['short' ],
@@ -97,7 +97,7 @@ def get_tokens(self):
97
97
}
98
98
})
99
99
100
- LOG .debug ('Tokens: {}' . format ( self .tokens ) )
100
+ LOG .debug (f 'Tokens: { self .tokens } ' )
101
101
102
102
def get_balances (self ):
103
103
""" Gets the current balance for an account """
@@ -108,21 +108,21 @@ def get_balances(self):
108
108
'tag' : 'latest' ,
109
109
'apikey' : self .settings ['api_key' ],
110
110
}
111
- LOG .debug ('Request data: {}' . format ( request_data ) )
111
+ LOG .debug (f 'Request data: { request_data } ' )
112
112
try :
113
113
req = requests .get (self .settings ['url' ], params = request_data ).json ()
114
114
except (
115
115
requests .exceptions .ConnectionError ,
116
116
requests .exceptions .ReadTimeout ,
117
117
) as error :
118
- LOG .exception ('Exception caught: {}' . format ( error ) )
118
+ LOG .exception (f 'Exception caught: { error } ' )
119
119
req = {}
120
120
if req .get ('message' ) == 'OK' and req .get ('result' ):
121
121
for result in req .get ('result' ):
122
122
self .accounts .update ({
123
123
result ['account' ]: float (result ['balance' ])/ (1000000000000000000 )
124
124
})
125
- LOG .debug ('Accounts: {}' . format ( self .accounts ) )
125
+ LOG .debug (f 'Accounts: { self .accounts } ' )
126
126
127
127
def describe (self ):
128
128
""" Just a needed method, so that collect() isn't called at startup """
@@ -166,9 +166,9 @@ def collect(self):
166
166
167
167
if __name__ == '__main__' :
168
168
configure_logging ()
169
- PORT = int (os .environ .get ('PORT' , 9308 ))
170
- LOG .info (" Starting {} {} on port {}" . format ( FILENAME , version , PORT ) )
169
+ port = int (os .environ .get ('PORT' , 9308 ))
170
+ LOG .info (f' Starting { __package__ } { version } on port { port } ' )
171
171
REGISTRY .register (EtherscanCollector ())
172
- start_http_server (PORT )
172
+ start_http_server (port )
173
173
while True :
174
174
time .sleep (1 )
0 commit comments