Skip to content

Commit

Permalink
Run make format
Browse files Browse the repository at this point in the history
  • Loading branch information
JelteF committed Feb 17, 2025
1 parent bed079c commit 944766b
Show file tree
Hide file tree
Showing 11 changed files with 1,740 additions and 1,136 deletions.
120 changes: 63 additions & 57 deletions cfbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,71 +14,77 @@
import logging
import requests


def try_lock():
"""Make sure that only one copy runs."""
fd = open(cfbot_config.LOCK_FILE, "w")
try:
fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
return fd
except IOError as e:
if e.errno != errno.EAGAIN:
raise
else:
return None
"""Make sure that only one copy runs."""
fd = open(cfbot_config.LOCK_FILE, "w")
try:
fcntl.flock(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
return fd
except IOError as e:
if e.errno != errno.EAGAIN:
raise
else:
return None


def run():
with cfbot_util.db() as conn:
with cfbot_util.db() as conn:
# get the current Commitfest ID
try:
commitfest_id = cfbot_commitfest_rpc.get_current_commitfest_id()
except requests.exceptions.ReadTimeout:
logging.error("Failed to get current commitfest ID due to a timeout")
return
except requests.exceptions.ConnectionError:
logging.error(
"Failed to get current commitfest ID due to a connection error"
)
return
except requests.exceptions.HTTPError as e:
logging.error(
"Failed to get current commitfest ID due to an HTTP error: %s", e
)
return

# get the current Commitfest ID
try:
commitfest_id = cfbot_commitfest_rpc.get_current_commitfest_id()
except requests.exceptions.ReadTimeout:
logging.error("Failed to get current commitfest ID due to a timeout")
return
except requests.exceptions.ConnectionError:
logging.error("Failed to get current commitfest ID due to a connection error")
return
except requests.exceptions.HTTPError as e:
logging.error("Failed to get current commitfest ID due to an HTTP error: %s", e)
return
# pull in any build results that we are waiting for
# XXX would need to aggregate the 'keep_polling' flag if we went
# back to supporting multiple providers, or do something smarter,
# but considering the plan to double-down on cirrus and switch to
# webhooks, not bothering for now
cfbot_cirrus.pull_build_results(conn)

# pull in any build results that we are waiting for
# XXX would need to aggregate the 'keep_polling' flag if we went
# back to supporting multiple providers, or do something smarter,
# but considering the plan to double-down on cirrus and switch to
# webhooks, not bothering for now
cfbot_cirrus.pull_build_results(conn)
# exchange data with the Commitfest app
logging.info("pulling submissions for current commitfest")
cfbot_commitfest.pull_submissions(conn, commitfest_id)
logging.info("pulling submissions for next commitfest")
cfbot_commitfest.pull_submissions(conn, commitfest_id + 1)
logging.info("pulling modified threads")
cfbot_commitfest.pull_modified_threads(conn)

# exchange data with the Commitfest app
logging.info("pulling submissions for current commitfest")
cfbot_commitfest.pull_submissions(conn, commitfest_id)
logging.info("pulling submissions for next commitfest")
cfbot_commitfest.pull_submissions(conn, commitfest_id + 1)
logging.info("pulling modified threads")
cfbot_commitfest.pull_modified_threads(conn)
# build one patch, if it is time for that
try:
cfbot_patch.maybe_process_one(conn, commitfest_id)
except requests.exceptions.ReadTimeout:
logging.error("Failed to process cf entry due to a timeout")
return
except requests.exceptions.ConnectionError:
logging.error("Failed to process cf entry due to a connection error")
return
except requests.exceptions.HTTPError as e:
logging.error("Failed to process cf entry due to an HTTP error: %s", e)
return

# build one patch, if it is time for that
try:
cfbot_patch.maybe_process_one(conn, commitfest_id)
except requests.exceptions.ReadTimeout:
logging.error("Failed to process cf entry due to a timeout")
return
except requests.exceptions.ConnectionError:
logging.error("Failed to process cf entry due to a connection error")
return
except requests.exceptions.HTTPError as e:
logging.error("Failed to process cf entry due to an HTTP error: %s", e)
return
# rebuild a new set of web pages
cfbot_web.rebuild(conn, commitfest_id)

# rebuild a new set of web pages
cfbot_web.rebuild(conn, commitfest_id)
# garbage collect old build results
cfbot_util.gc(conn)

# garbage collect old build results
cfbot_util.gc(conn)

if __name__ == "__main__":
# don't run if we're already running
lock_fd = try_lock()
if lock_fd:
run()
lock_fd.close()
# don't run if we're already running
lock_fd = try_lock()
if lock_fd:
run()
lock_fd.close()
Loading

0 comments on commit 944766b

Please sign in to comment.