You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kibble.apache.org by mi...@apache.org on 2020/11/27 11:26:36 UTC
[kibble] branch main updated: Remove unused variables (#98)
This is an automated email from the ASF dual-hosted git repository.
michalslowikowski pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/kibble.git
The following commit(s) were added to refs/heads/main by this push:
new 1aa6804 Remove unused variables (#98)
1aa6804 is described below
commit 1aa68040a70397b3aea7b26def912ad67d717b67
Author: Michał Słowikowski <mi...@polidea.com>
AuthorDate: Fri Nov 27 12:26:30 2020 +0100
Remove unused variables (#98)
* removed few unused variables from code
* bugzilla – removed unused variables from code
* git-census – removed unused variable
* buildbot – removed unused variable
* pipermail – removed unused variable
* ponymail – removed unused variable
* discourse – removed unused variable
* github-issues – removed unused variable
* jenkins – removed unused variable
* jira – removed unused variable
* github-stats – removed unused variable
* ponymail – removed unused variable
* git-evolution – removed unused variable
---
kibble/scanners/brokers/kibbleES.py | 1 -
kibble/scanners/kibble-scanner.py | 3 +--
kibble/scanners/scanners/bugzilla.py | 7 ++-----
kibble/scanners/scanners/buildbot.py | 9 +--------
kibble/scanners/scanners/discourse.py | 6 +-----
kibble/scanners/scanners/git-census.py | 1 -
kibble/scanners/scanners/git-evolution.py | 2 --
kibble/scanners/scanners/github-issues.py | 1 -
kibble/scanners/scanners/github-stats.py | 2 --
kibble/scanners/scanners/jenkins.py | 4 +---
kibble/scanners/scanners/jira.py | 7 ++-----
kibble/scanners/scanners/pipermail.py | 3 +--
kibble/scanners/scanners/ponymail-kpe.py | 2 +-
kibble/scanners/scanners/ponymail-tone.py | 2 +-
kibble/scanners/scanners/ponymail.py | 3 +--
kibble/scanners/scanners/travis.py | 14 +++-----------
kibble/scanners/utils/git.py | 1 -
kibble/scanners/utils/kpe.py | 1 -
kibble/scanners/utils/tone.py | 1 -
19 files changed, 15 insertions(+), 55 deletions(-)
diff --git a/kibble/scanners/brokers/kibbleES.py b/kibble/scanners/brokers/kibbleES.py
index c061e30..5792dd8 100644
--- a/kibble/scanners/brokers/kibbleES.py
+++ b/kibble/scanners/brokers/kibbleES.py
@@ -352,7 +352,6 @@ class Broker:
def organisations(self):
""" Return a list of all organisations """
- orgs = []
# Run the search, fetch all orgs, 9999 max. TODO: Scroll???
res = self.DB.search(
diff --git a/kibble/scanners/kibble-scanner.py b/kibble/scanners/kibble-scanner.py
index 52b2954..390a263 100644
--- a/kibble/scanners/kibble-scanner.py
+++ b/kibble/scanners/kibble-scanner.py
@@ -102,7 +102,6 @@ class scanThread(threading.Thread):
global BIG_LOCK, PENDING_OBJECTS
time.sleep(0.5) # Primarily to align printouts.
# While there are objects to snag
- a = 0
while PENDING_OBJECTS:
BIG_LOCK.acquire(blocking=True)
try:
@@ -161,7 +160,7 @@ def main():
for source in org.sources(view=args.view):
tooNew = False
if "steps" in source:
- for key, step in source["steps"].items():
+ for _, step in source["steps"].items():
if "time" in step and step["time"] >= minAge:
tooNew = True
break
diff --git a/kibble/scanners/scanners/bugzilla.py b/kibble/scanners/scanners/bugzilla.py
index b0eb19d..6b55e4f 100644
--- a/kibble/scanners/scanners/bugzilla.py
+++ b/kibble/scanners/scanners/bugzilla.py
@@ -310,7 +310,7 @@ class bzThread(Thread):
self.block.acquire()
try:
rl = self.pendingTickets.pop(0)
- except Exception as err: # list empty, likely
+ except Exception: # list empty, likely
self.block.release()
return
if not rl:
@@ -338,7 +338,6 @@ class bzThread(Thread):
def scan(KibbleBit, source):
- path = source["sourceID"]
url = source["sourceURL"]
source["steps"]["issues"] = {
@@ -358,7 +357,6 @@ def scan(KibbleBit, source):
and len(source["creds"]["username"]) > 0
):
creds = "%s:%s" % (source["creds"]["username"], source["creds"]["password"])
- badOnes = 0
pendingTickets = []
openTickets = []
@@ -367,7 +365,6 @@ def scan(KibbleBit, source):
dom = re.sub(r"/+$", "", dom)
u = "%s/jsonrpc.cgi" % dom
instance = bz.group(3)
- lastTicket = 0
params = {
"product": [instance],
@@ -445,9 +442,9 @@ def scan(KibbleBit, source):
% (len(openTickets), len(pendingTickets) - len(openTickets))
)
- badOnes = 0
block = Lock()
threads = []
+ # TODO: Fix this loop
for i in range(0, 4):
t = bzThread(KibbleBit, source, block, pendingTickets, openTickets, u, dom)
threads.append(t)
diff --git a/kibble/scanners/scanners/buildbot.py b/kibble/scanners/scanners/buildbot.py
index e4f7b2d..72561ff 100644
--- a/kibble/scanners/scanners/buildbot.py
+++ b/kibble/scanners/scanners/buildbot.py
@@ -40,15 +40,12 @@ def accepts(source):
def scanJob(KibbleBit, source, job, creds):
""" Scans a single job for activity """
- NOW = int(datetime.datetime.utcnow().timestamp())
dhash = hashlib.sha224(
("%s-%s-%s" % (source["organisation"], source["sourceID"], job)).encode(
"ascii", errors="replace"
)
).hexdigest()
- found = True
doc = None
- parseIt = False
found = KibbleBit.exists("cijob", dhash)
jobURL = "%s/json/builders/%s/builds/_all" % (source["sourceURL"], job)
@@ -140,7 +137,7 @@ class buildbotThread(threading.Thread):
self.block.acquire()
try:
job = self.jobs.pop(0)
- except Exception as err:
+ except Exception:
self.block.release()
return
if not job:
@@ -178,8 +175,6 @@ def scan(KibbleBit, source):
}
KibbleBit.updateSource(source)
- badOnes = 0
- pendingJobs = []
KibbleBit.pprint("Parsing Buildbot activity at %s" % source["sourceURL"])
source["steps"]["ci"] = {
"time": time.time(),
@@ -216,8 +211,6 @@ def scan(KibbleBit, source):
# Scan queue items
blocked = 0
stuck = 0
- totalqueuetime = 0
- labelQueuedBuilds = {}
queueSize = 0
actualQueueSize = 0
building = 0
diff --git a/kibble/scanners/scanners/discourse.py b/kibble/scanners/scanners/discourse.py
index eeb15de..ee99dde 100644
--- a/kibble/scanners/scanners/discourse.py
+++ b/kibble/scanners/scanners/discourse.py
@@ -41,10 +41,7 @@ def accepts(source):
def scanJob(KibbleBit, source, cat, creds):
""" Scans a single discourse category for activity """
- NOW = int(datetime.datetime.utcnow().timestamp())
-
# Get $discourseURL/c/$catID
-
catURL = os.path.join(source["sourceURL"], "c/%s" % cat["id"])
KibbleBit.pprint("Scanning Discourse category '%s' at %s" % (cat["slug"], catURL))
@@ -249,7 +246,7 @@ class discourseThread(threading.Thread):
self.block.acquire()
try:
job = self.jobs.pop(0)
- except Exception as err:
+ except Exception:
self.block.release()
return
if not job:
@@ -289,7 +286,6 @@ def scan(KibbleBit, source):
}
KibbleBit.updateSource(source)
- badOnes = 0
pendingJobs = []
KibbleBit.pprint("Parsing Discourse activity at %s" % source["sourceURL"])
source["steps"]["forum"] = {
diff --git a/kibble/scanners/scanners/git-census.py b/kibble/scanners/scanners/git-census.py
index 16ac9cc..33a0920 100644
--- a/kibble/scanners/scanners/git-census.py
+++ b/kibble/scanners/scanners/git-census.py
@@ -92,7 +92,6 @@ def scan(KibbleBit, source):
inp = f.read()
f.close()
os.unlink(tmp.name)
- edone = 0
KibbleBit.pprint("Parsing log for %s (%s)..." % (rid, url))
for m in re.finditer(
u":([a-f0-9]+)\|([^\r\n|]+)\|([^\r\n|]+)\|([^\r\n|]+)\|([^\r\n|]+)\|([\d+]+)\r?\n([^:]+?):",
diff --git a/kibble/scanners/scanners/git-evolution.py b/kibble/scanners/scanners/git-evolution.py
index 6c84243..f391e42 100644
--- a/kibble/scanners/scanners/git-evolution.py
+++ b/kibble/scanners/scanners/git-evolution.py
@@ -118,7 +118,6 @@ def find_branch(date, gpath):
return "master"
except:
os.chdir(gpath)
- branch = ""
try:
return (
subprocess.check_output(
@@ -138,7 +137,6 @@ def find_branch(date, gpath):
def scan(KibbleBit, source):
rid = source["sourceID"]
- url = source["sourceURL"]
rootpath = "%s/%s/git" % (
KibbleBit.config["scanner"]["scratchdir"],
source["organisation"],
diff --git a/kibble/scanners/scanners/github-issues.py b/kibble/scanners/scanners/github-issues.py
index c5edc6e..06bbde6 100644
--- a/kibble/scanners/scanners/github-issues.py
+++ b/kibble/scanners/scanners/github-issues.py
@@ -196,7 +196,6 @@ def scan(KibbleBit, source, firstAttempt=True):
doc = make_issue(source, issue, people)
dhash = doc["id"]
- stored_change = None
if KibbleBit.exists("issue", dhash):
es_doc = KibbleBit.get("issue", dhash)
if not status_changed(es_doc, doc):
diff --git a/kibble/scanners/scanners/github-stats.py b/kibble/scanners/scanners/github-stats.py
index 5f993dc..504d151 100644
--- a/kibble/scanners/scanners/github-stats.py
+++ b/kibble/scanners/scanners/github-stats.py
@@ -42,11 +42,9 @@ def getTime(string):
def scan(KibbleBit, source):
# Get some vars, construct a data path for the repo
- path = source["sourceID"]
url = source["sourceURL"]
auth = None
- people = {}
if "creds" in source:
KibbleBit.pprint("Using auth for repo %s" % source["sourceURL"])
creds = source["creds"]
diff --git a/kibble/scanners/scanners/jenkins.py b/kibble/scanners/scanners/jenkins.py
index 0f7db89..f7ec495 100644
--- a/kibble/scanners/scanners/jenkins.py
+++ b/kibble/scanners/scanners/jenkins.py
@@ -50,9 +50,7 @@ def scanJob(KibbleBit, source, job, creds):
"ascii", errors="replace"
)
).hexdigest()
- found = True
doc = None
- parseIt = False
found = KibbleBit.exists("cijob", dhash)
# Get $jenkins/job/$job-name/json...
@@ -156,6 +154,7 @@ class jenkinsThread(threading.Thread):
try:
job = self.jobs.pop(0)
except Exception as err:
+ print(f"An error occurred: {err}")
self.block.release()
return
if not job:
@@ -199,7 +198,6 @@ def scan(KibbleBit, source):
}
KibbleBit.updateSource(source)
- badOnes = 0
pendingJobs = []
KibbleBit.pprint("Parsing Jenkins activity at %s" % source["sourceURL"])
source["steps"]["issues"] = {
diff --git a/kibble/scanners/scanners/jira.py b/kibble/scanners/scanners/jira.py
index f10b3ff..efc22cf 100644
--- a/kibble/scanners/scanners/jira.py
+++ b/kibble/scanners/scanners/jira.py
@@ -130,7 +130,6 @@ def scanTicket(KibbleBit, key, u, source, creds, openTickets):
)
).hexdigest()
found = True
- doc = None
parseIt = False
# the 'domain' var we try to figure out here is used
@@ -179,7 +178,7 @@ def scanTicket(KibbleBit, key, u, source, creds, openTickets):
KibbleBit.pprint("%s does not exist (404'ed)" % key)
return False
except requests.exceptions.ConnectionError as err:
- KibbleBit.pprint("Connection error, skipping this ticket for now!")
+ KibbleBit.pprint(f"Connection error: {err}, skipping this ticket for now!")
return False
st, closer = wasclosed(tjson)
if st and not closer:
@@ -323,6 +322,7 @@ class jiraThread(threading.Thread):
try:
rl = self.pendingTickets.pop(0)
except Exception as err:
+ print(f"An error occured: {err}")
self.block.release()
return
if not rl:
@@ -384,9 +384,6 @@ def scan(KibbleBit, source):
}
KibbleBit.updateSource(source)
- badOnes = 0
- jsa = []
- jsp = []
pendingTickets = []
KibbleBit.pprint("Parsing JIRA activity at %s" % source["sourceURL"])
source["steps"]["issues"] = {
diff --git a/kibble/scanners/scanners/pipermail.py b/kibble/scanners/scanners/pipermail.py
index 59c96ed..e361ad2 100644
--- a/kibble/scanners/scanners/pipermail.py
+++ b/kibble/scanners/scanners/pipermail.py
@@ -49,8 +49,7 @@ def scan(KibbleBit, source):
if pipermail:
KibbleBit.pprint("Scanning Pipermail source %s" % url)
skipped = 0
- jsa = []
- jsp = []
+
source["steps"]["mail"] = {
"time": time.time(),
"status": "Downloading Pipermail statistics",
diff --git a/kibble/scanners/scanners/ponymail-kpe.py b/kibble/scanners/scanners/ponymail-kpe.py
index e2a4129..7e93320 100644
--- a/kibble/scanners/scanners/ponymail-kpe.py
+++ b/kibble/scanners/scanners/ponymail-kpe.py
@@ -101,7 +101,7 @@ def scan(KibbleBit, source):
if rv and "body" in rv:
hits.append([hit["_id"], rv["body"], eml])
except Exception as err:
- KibbleBit.pprint("Server error, skipping this email")
+ KibbleBit.pprint(f"Server error: {err}, skipping this email")
bodies = []
for hit in hits:
diff --git a/kibble/scanners/scanners/ponymail-tone.py b/kibble/scanners/scanners/ponymail-tone.py
index 22076de..e5cc02b 100644
--- a/kibble/scanners/scanners/ponymail-tone.py
+++ b/kibble/scanners/scanners/ponymail-tone.py
@@ -102,7 +102,7 @@ def scan(KibbleBit, source):
if rv and "body" in rv:
hits.append([hit["_id"], rv["body"], eml])
except Exception as err:
- KibbleBit.pprint("Server error, skipping this email")
+ KibbleBit.pprint(f"Server error: {err}, skipping this email")
bodies = []
for hit in hits:
diff --git a/kibble/scanners/scanners/ponymail.py b/kibble/scanners/scanners/ponymail.py
index 1744ea1..78f0a4a 100644
--- a/kibble/scanners/scanners/ponymail.py
+++ b/kibble/scanners/scanners/ponymail.py
@@ -69,7 +69,6 @@ def repliedTo(emails, struct):
def getSender(email):
sender = email["from"]
- name = sender
m = re.match(r"(.+)\s*<(.+)>", email["from"], flags=re.UNICODE)
if m:
name = m.group(1).replace('"', "").strip()
@@ -164,7 +163,7 @@ def scan(KibbleBit, source):
try:
js = jsonapi.get(statsurl, cookie=cookie)
except Exception as err:
- KibbleBit.pprint("Server error, skipping this month")
+ KibbleBit.pprint(f"Server error: {err}, skipping this month")
month -= 1
if month <= 0:
month += 12
diff --git a/kibble/scanners/scanners/travis.py b/kibble/scanners/scanners/travis.py
index 519cb40..d76ca57 100644
--- a/kibble/scanners/scanners/travis.py
+++ b/kibble/scanners/scanners/travis.py
@@ -41,16 +41,12 @@ def accepts(source):
def scanJob(KibbleBit, source, bid, token, TLD):
""" Scans a single job for activity """
- NOW = int(datetime.datetime.utcnow().timestamp())
+ # NOW = int(datetime.datetime.utcnow().timestamp())
dhash = hashlib.sha224(
("%s-%s-%s" % (source["organisation"], source["sourceURL"], bid)).encode(
"ascii", errors="replace"
)
).hexdigest()
- found = True
- doc = None
- parseIt = False
- found = KibbleBit.exists("cijob", dhash)
# Get the job data
pages = 0
@@ -192,7 +188,7 @@ class travisThread(threading.Thread):
self.block.acquire()
try:
job = self.jobs.pop(0)
- except Exception as err:
+ except Exception:
self.block.release()
return
if not job:
@@ -217,7 +213,7 @@ class travisThread(threading.Thread):
badOnes = 0
-def scan(KibbleBit, source):
+def sclan(KibbleBit, source):
# Simple URL check
travis = re.match(r"https?://travis-ci\.(org|com)", source["sourceURL"])
if travis:
@@ -231,7 +227,6 @@ def scan(KibbleBit, source):
}
KibbleBit.updateSource(source)
- badOnes = 0
pendingJobs = []
KibbleBit.pprint("Parsing Travis activity at %s" % source["sourceURL"])
source["steps"]["travis"] = {
@@ -255,9 +250,6 @@ def scan(KibbleBit, source):
KibbleBit.pprint("Travis CI requires a token to work!")
return False
- # Get the job list, paginated
- sURL = source["sourceURL"]
-
# Used for pagination
jobs = 100
offset = 0
diff --git a/kibble/scanners/utils/git.py b/kibble/scanners/utils/git.py
index 5ea7607..c1f3cd7 100644
--- a/kibble/scanners/utils/git.py
+++ b/kibble/scanners/utils/git.py
@@ -32,7 +32,6 @@ def defaultBranch(source, datapath, KibbleBit=None):
wanted_branches = KibbleBit.config["git"].get(
"wanted_branches", wanted_branches
)
- foundBranch = False
# For each wanted branch, in order, look for it in our clone,
# and return the name if found.
diff --git a/kibble/scanners/utils/kpe.py b/kibble/scanners/utils/kpe.py
index c42e8e3..7eae14b 100644
--- a/kibble/scanners/utils/kpe.py
+++ b/kibble/scanners/utils/kpe.py
@@ -77,7 +77,6 @@ def azureKPE(KibbleBit, bodies):
KPEs = []
for body in bodies:
# Crop out quotes
- lines = body.split("\n")
body = trimBody(body)
doc = {"language": "en", "id": str(a), "text": body}
js["documents"].append(doc)
diff --git a/kibble/scanners/utils/tone.py b/kibble/scanners/utils/tone.py
index dab6e73..3571c89 100644
--- a/kibble/scanners/utils/tone.py
+++ b/kibble/scanners/utils/tone.py
@@ -167,7 +167,6 @@ def picoTone(KibbleBit, bodies):
mood = {}
# Sentiment is the overall score, and we use that for the neutrality of a text
- val = (1 + doc["sentiment"]) / 2
mood["negative"] = doc[
"negativity"