9
9
import shutil
10
10
import time
11
11
12
- STATE_DIR = tempfile .TemporaryDirectory ()
13
- BLOCKLIST_DIR = tempfile .TemporaryDirectory ()
12
+ STATE_DIR = tempfile .TemporaryDirectory () # pylint: disable=R1732
13
+ BLOCKLIST_DIR = tempfile .TemporaryDirectory () # pylint: disable=R1732
14
14
BLOCKLIST_PATH = pathlib .Path (BLOCKLIST_DIR .name , "blocklist.json" )
15
15
16
16
COCO_DAEMON = (
@@ -61,11 +61,13 @@ def __del__(self):
61
61
def __enter__ (self ):
62
62
return self
63
63
64
- def __exit__ (self , type , value , traceback ):
64
+ def __exit__ (self , exc_type , value , traceback ):
65
65
self .__del__ ()
66
66
67
- def client (self , command , data = [] , silent = False ):
67
+ def client (self , command , data = None , silent = False ):
68
68
"""Make coco-client script call a coco endpoint."""
69
+ if data is None :
70
+ data = []
69
71
cmd = CLIENT_ARGS + ["-c" , self .configfile .name , command ] + data
70
72
logger .debug (f"calling coco client: { cmd } " )
71
73
try :
@@ -90,24 +92,28 @@ def start_coco(self, config, endpoint_configs, reset):
90
92
CONFIG .update (config )
91
93
92
94
# Write endpoint configs to file
93
- self .endpointdir = tempfile .TemporaryDirectory ()
95
+ self .endpointdir = tempfile .TemporaryDirectory () # pylint: disable=R1732
94
96
CONFIG ["endpoint_dir" ] = self .endpointdir .name
95
97
for name , endpoint_conf in endpoint_configs .items ():
96
98
with open (
97
- os .path .join (self .endpointdir .name , name + ".conf" ), "w"
99
+ os .path .join (self .endpointdir .name , name + ".conf" ),
100
+ "w" ,
101
+ encoding = "utf-8" ,
98
102
) as outfile :
99
103
json .dump (endpoint_conf , outfile )
100
104
101
105
# Write config to file
102
- self .configfile = tempfile .NamedTemporaryFile ("w" )
106
+ self .configfile = tempfile .NamedTemporaryFile ("w" ) # pylint: disable=R1732
103
107
json .dump (CONFIG , self .configfile )
104
108
self .configfile .flush ()
105
109
106
110
args = []
107
111
if reset :
108
112
args .append ("--reset" )
109
113
110
- self .coco = subprocess .Popen ([COCO_DAEMON , "-c" , self .configfile .name , * args ])
114
+ self .coco = subprocess .Popen (
115
+ [COCO_DAEMON , "-c" , self .configfile .name , * args ]
116
+ ) # pylint: disable=R1732
111
117
112
118
def stop_coco (self ):
113
119
"""Stop coco script."""
0 commit comments