Skip to content

Commit

Permalink
Run make lint-fix-unsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
JelteF committed Feb 17, 2025
1 parent 944766b commit ca40d74
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 44 deletions.
7 changes: 0 additions & 7 deletions cfbot_cirrus.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import cfbot_util

import requests
import sys


def query_cirrus(query, variables):
Expand Down Expand Up @@ -91,7 +90,6 @@ def get_tasks_for_build(build_id):


def get_task_results(commit):
result = {}
builds = get_builds_for_commit(
cfbot_config.CIRRUS_USER, cfbot_config.CIRRUS_REPO, commit
)
Expand All @@ -102,8 +100,6 @@ def get_task_results(commit):


def pull_build_results(conn):
builds = None
task_results_for_commit = {}
cursor = conn.cursor()
cursor.execute("""SELECT commitfest_id,
submission_id,
Expand All @@ -114,7 +110,6 @@ def pull_build_results(conn):
keep_polling_branch = False
tasks = get_task_results(commit_id)
if len(tasks) == 0:
keep_polling = True
continue
position = 0
for task in get_task_results(commit_id):
Expand Down Expand Up @@ -155,9 +150,7 @@ def pull_build_results(conn):
# artifacts (without bodies) and task commands (steps)
if not task_still_running:
# fetch the list of artifacts immediately
have_artifacts = False
for name, path, size in get_artifacts_for_task(task_id):
have_artifacts = True
cursor.execute(
"""INSERT INTO artifact (task_id, name, path, size)
VALUES (%s, %s, %s, %s)
Expand Down
2 changes: 1 addition & 1 deletion cfbot_commitfest.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def pull_modified_threads(conn):
url = cfbot_commitfest_rpc.get_thread_url_for_submission(
commitfest_id, submission_id
)
if url == None:
if url is None:
message_id = None
else:
message_id, attachments = (
Expand Down
17 changes: 3 additions & 14 deletions cfbot_commitfest_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,10 @@
# For now these use webscraping, but they could become real API calls.

import cfbot_util
import datetime
import errno
import html

# from html.parser import HTMLParser
import os
import re
import requests
import subprocess
import shutil
import sys
import tarfile
import time
import unicodedata
from urllib.parse import urlparse


class Submission:
Expand Down Expand Up @@ -66,7 +55,7 @@ def get_latest_patches_from_thread_url(thread_url):
# if there is a tarball attachment, there must be only one attachment,
# otherwise give up on this thread (we don't know how to combine patches and
# tarballs)
if selected_message_attachments != None:
if selected_message_attachments is not None:
if any(
x.endswith(".tgz") or x.endswith(".tar.gz") or x.endswith(".tar.bz2")
for x in selected_message_attachments
Expand Down Expand Up @@ -177,9 +166,9 @@ def get_current_commitfest_id():
)
if groups:
commitfest_id = groups.group(1)
state = groups.group(2)
groups.group(2)
result = int(commitfest_id)
if result == None:
if result is None:
raise Exception("Could not determine the current Commitfest ID")
return result

Expand Down
1 change: 0 additions & 1 deletion cfbot_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import re
import requests
import shlex
import shutil
import subprocess
import tempfile
import time
Expand Down
2 changes: 1 addition & 1 deletion cfbot_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
def get_http_session():
"""A session allowing for HTTP connection reuse."""
global global_http_session
if global_http_session == None:
if global_http_session is None:
global_http_session = requests.Session()
return global_http_session

Expand Down
11 changes: 6 additions & 5 deletions cfbot_web.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env python3

import cfbot_commitfest_rpc
import cfbot_config
import cfbot_util
import math
Expand Down Expand Up @@ -299,7 +298,7 @@ def build_page(
expected_runtimes = load_expected_runtimes(conn)
last_status = None
commitfest_id_for_link = commitfest_id
if commitfest_id_for_link == None:
if commitfest_id_for_link is None:
commitfest_id_for_link = ""
with open(path + ".tmp", "w") as f:
f.write(
Expand Down Expand Up @@ -361,16 +360,18 @@ def build_page(
)
for submission in submissions:
# skip if we need to filter by commitfest
if commitfest_id != None and submission.commitfest_id != commitfest_id:
if commitfest_id is not None and submission.commitfest_id != commitfest_id:
continue

# skip if we need to filter by author
if filter_author != None and filter_author not in all_authors(submission):
if filter_author is not None and filter_author not in all_authors(
submission
):
continue

# create a new heading row if this is a new CF status
status = submission.status
if last_status == None or last_status != status:
if last_status is None or last_status != status:
f.write(
""" <tr><td colspan="5"><h2>%s</h2></td></tr>\n"""
% html_escape(status)
Expand Down
4 changes: 0 additions & 4 deletions cfbot_web_highlights.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
#!/usr/bin/env python3

import cfbot_commitfest_rpc
import cfbot_config
import cfbot_util
import cfbot_web
import html
import math
import os
import re
import unicodedata

MODES = (
"all",
Expand Down
8 changes: 1 addition & 7 deletions cfbot_web_statistics.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
#!/usr/bin/env python3

import cfbot_commitfest_rpc
import cfbot_config
import cfbot_util
import math
import os
import re
import unicodedata

from cfbot_commitfest_rpc import Submission


def header(f):
Expand Down Expand Up @@ -98,7 +92,7 @@ def per_day(f, conn):
task = ""
else:
last_task = task
if stddev == None:
if stddev is None:
stddev = 0
f.write(
"""
Expand Down
5 changes: 1 addition & 4 deletions cfbot_work_queue.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
#!/usr/bin/env python3

import cfbot_commitfest
import cfbot_commitfest_rpc
import cfbot_config
import cfbot_util
import cfbot_web_highlights
import math
import os
import re
import scipy.stats
import requests
Expand Down Expand Up @@ -341,7 +338,7 @@ def fetch_task_logs(conn, task_id):
"https://api.cirrus-ci.com/v1/task/%s/logs/%s.log" % (task_id, command),
True,
)
if log_bin == None:
if log_bin is None:
continue
log = binary_to_safe_utf8(log_bin)
cursor.execute(
Expand Down

0 comments on commit ca40d74

Please sign in to comment.