fix linting issues
This commit is contained in:
parent
c646cf35d6
commit
dc021e474b
@ -5,7 +5,7 @@ import argparse
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import pickle #nosec
|
||||
import pickle # nosec
|
||||
import shutil
|
||||
import sys
|
||||
from collections import defaultdict
|
||||
@ -50,7 +50,7 @@ class AgentCleanup:
|
||||
config["drone_server"] = os.environ.get("DRONE_SERVER")
|
||||
config["drone_token"] = os.environ.get("DRONE_TOKEN")
|
||||
config["log_level"] = os.environ.get("DRONE_LOGLEVEL", "WARNING")
|
||||
config["statefile"] = "/tmp/droneclean.pkl" #nosec
|
||||
config["statefile"] = "/tmp/droneclean.pkl" # nosec
|
||||
config["pending"] = defaultdict(dict, {})
|
||||
|
||||
if os.path.isfile(binary):
|
||||
@ -72,7 +72,7 @@ class AgentCleanup:
|
||||
|
||||
if os.path.isfile(config["statefile"]):
|
||||
with open(config["statefile"], "rb") as json_file:
|
||||
config["pending"] = pickle.load(json_file) #nosec
|
||||
config["pending"] = pickle.load(json_file) # nosec
|
||||
|
||||
return config
|
||||
|
||||
@ -110,16 +110,14 @@ class AgentCleanup:
|
||||
|
||||
self.logger.info("Stopping '{agent}' ({triage}/3) {force}".format(
|
||||
agent=e, triage=control[e] or 3, force=force_msg))
|
||||
#res = run_command(
|
||||
# "drone -s {server} -t {token} --autoscaler {scaler} server destroy {force} {agent}".format(
|
||||
# server=self.config["drone_server"], token=self.config["drone_token"], scaler=scaler, agent=e, force=force
|
||||
#))
|
||||
res = run_command("drone -s {server} -t {token} --autoscaler {scaler} server destroy {force} {agent}".format(
|
||||
server=self.config["drone_server"], token=self.config["drone_token"], scaler=scaler, agent=e, force=force))
|
||||
|
||||
#if res.returncode > 0:
|
||||
# self.log.sysexit_with_message("Command error:\n{}".format(humanize(res.stdout)))
|
||||
if res.returncode > 0:
|
||||
self.log.sysexit_with_message("Command error:\n{}".format(humanize(res.stdout)))
|
||||
|
||||
with open(self.config["statefile"], "wb") as json_file:
|
||||
pickle.dump(control, json_file) #nosec
|
||||
pickle.dump(control, json_file) # nosec
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
@ -134,4 +132,4 @@ class AgentCleanup:
|
||||
if not self.config["drone_bin"]:
|
||||
self.log.sysexit_with_message("Drone binary not found in PATH or not defined by '{}'".format(c.upper()))
|
||||
|
||||
self._clean()
|
||||
self._clean()
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
import os
|
||||
import shlex
|
||||
import subprocess #nosec
|
||||
import subprocess # nosec
|
||||
import sys
|
||||
from distutils.util import strtobool
|
||||
|
||||
@ -19,7 +19,7 @@ def to_bool(string):
|
||||
|
||||
def run_command(command):
|
||||
cmd = [x.strip() for x in shlex.split(command)]
|
||||
p = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) #nosec
|
||||
p = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # nosec
|
||||
return p
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user