Prefer logging to print
This commit is contained in:
Родитель
6832081e64
Коммит
63e3b11c58
|
@ -15,8 +15,8 @@ from comma.downstream.monitor import monitor_downstream
|
||||||
from comma.upstream import process_commits
|
from comma.upstream import process_commits
|
||||||
from comma.util import config
|
from comma.util import config
|
||||||
from comma.util.spreadsheet import export_commits, import_commits, update_commits
|
from comma.util.spreadsheet import export_commits, import_commits, update_commits
|
||||||
from comma.util.symbols import print_missing_symbols
|
from comma.util.symbols import get_hyperv_patch_symbols, symbol_checker
|
||||||
from comma.util.tracking import print_tracked_paths
|
from comma.util.tracking import get_tracked_paths
|
||||||
|
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__name__.split(".", 1)[0])
|
LOGGER = logging.getLogger(__name__.split(".", 1)[0])
|
||||||
|
@ -33,17 +33,23 @@ def run(args):
|
||||||
session.add_all(config.default_distros)
|
session.add_all(config.default_distros)
|
||||||
if session.query(MonitoringSubjects).first() is None:
|
if session.query(MonitoringSubjects).first() is None:
|
||||||
session.add_all(config.default_monitoring_subjects)
|
session.add_all(config.default_monitoring_subjects)
|
||||||
|
|
||||||
if args.section:
|
if args.section:
|
||||||
config.sections = args.section
|
config.sections = args.section
|
||||||
|
|
||||||
if args.print_tracked_paths:
|
if args.print_tracked_paths:
|
||||||
print_tracked_paths()
|
for path in get_tracked_paths():
|
||||||
|
print(path)
|
||||||
|
|
||||||
if args.upstream:
|
if args.upstream:
|
||||||
print("Monitoring upstream...")
|
LOGGER.info("Begin monitoring upstream")
|
||||||
LOGGER.info("Starting patch scraping from files...")
|
|
||||||
process_commits(add_to_database=True)
|
process_commits(add_to_database=True)
|
||||||
print("Finishing monitoring upstream!")
|
LOGGER.info("Finishing monitoring upstream")
|
||||||
|
|
||||||
if args.downstream:
|
if args.downstream:
|
||||||
|
LOGGER.info("Begin monitoring downstream")
|
||||||
monitor_downstream()
|
monitor_downstream()
|
||||||
|
LOGGER.info("Finishing monitoring downstream")
|
||||||
|
|
||||||
|
|
||||||
def spreadsheet(args):
|
def spreadsheet(args):
|
||||||
|
@ -96,6 +102,16 @@ def add_kernel(args):
|
||||||
LOGGER.info("Successfully added new revision '%s' for distro '%s'", args.revision, args.name)
|
LOGGER.info("Successfully added new revision '%s' for distro '%s'", args.revision, args.name)
|
||||||
|
|
||||||
|
|
||||||
|
def print_missing_symbols(symbol_file):
|
||||||
|
"""
|
||||||
|
Utility function for printing missing symbols
|
||||||
|
"""
|
||||||
|
|
||||||
|
LOGGER.info("Starting Symbol Checker")
|
||||||
|
get_hyperv_patch_symbols()
|
||||||
|
print(f"Missing symbols:\n{symbol_checker(symbol_file)}")
|
||||||
|
|
||||||
|
|
||||||
def get_cli_options(args: Optional[str] = None) -> argparse.Namespace:
|
def get_cli_options(args: Optional[str] = None) -> argparse.Namespace:
|
||||||
"""
|
"""
|
||||||
Parse CLI options and return a namespace
|
Parse CLI options and return a namespace
|
||||||
|
@ -266,9 +282,7 @@ def main(args: Optional[str] = None) -> None:
|
||||||
config.since = args.since
|
config.since = args.since
|
||||||
config.fetch = not args.no_fetch
|
config.fetch = not args.no_fetch
|
||||||
|
|
||||||
print("Welcome to Commit Analyzer!")
|
|
||||||
args.func(args)
|
args.func(args)
|
||||||
print("Commit Analyzer completed!")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -248,7 +248,6 @@ def monitor_downstream():
|
||||||
Cycle through downstream remotes and search for missing commits
|
Cycle through downstream remotes and search for missing commits
|
||||||
"""
|
"""
|
||||||
|
|
||||||
print("Monitoring downstream...")
|
|
||||||
repo = get_linux_repo()
|
repo = get_linux_repo()
|
||||||
|
|
||||||
# Add repos as a remote if not already added
|
# Add repos as a remote if not already added
|
||||||
|
@ -288,5 +287,3 @@ def monitor_downstream():
|
||||||
remote_ref,
|
remote_ref,
|
||||||
)
|
)
|
||||||
monitor_subject(subject, repo, local_ref)
|
monitor_subject(subject, repo, local_ref)
|
||||||
|
|
||||||
print("Finished monitoring downstream!")
|
|
||||||
|
|
|
@ -97,8 +97,8 @@ def process_commits(
|
||||||
repo = get_linux_repo()
|
repo = get_linux_repo()
|
||||||
|
|
||||||
if commit_ids is None:
|
if commit_ids is None:
|
||||||
# We use `--min-parents=1 --max-parents=1` to avoid both
|
# We use `--min-parents=1 --max-parents=1` to avoid both merges and graft commits.
|
||||||
# merges and graft commits.
|
LOGGER.info("Determining commits from tracked files")
|
||||||
commits = repo.iter_commits(
|
commits = repo.iter_commits(
|
||||||
rev=revision,
|
rev=revision,
|
||||||
paths=get_tracked_paths(),
|
paths=get_tracked_paths(),
|
||||||
|
|
|
@ -85,19 +85,19 @@ def import_commits(in_file: str) -> None:
|
||||||
upstream monitoring logic.
|
upstream monitoring logic.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
print(f"Sorry, importing is not supported at this time! filename: {in_file}")
|
LOGGER.error("Importing is not supported at this time! filename: %s", in_file)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
# TODO (Issue 55): Implement import from database
|
# TODO (Issue 55): Implement import from database
|
||||||
# to the database, and therefore affect untracked paths.
|
# to the database, and therefore affect untracked paths.
|
||||||
# from comma.upstream import process_commits
|
# from comma.upstream import process_commits
|
||||||
# print(f"Importing commits from spreadsheet '{in_file}'...")
|
# LOGGER.info(f"Importing commits from spreadsheet '{in_file}'...")
|
||||||
# workbook, worksheet = get_workbook(in_file)
|
# workbook, worksheet = get_workbook(in_file)
|
||||||
# wb_commits = get_wb_commits(worksheet)
|
# wb_commits = get_wb_commits(worksheet)
|
||||||
# db_commits = get_db_commits()
|
# db_commits = get_db_commits()
|
||||||
# missing_commits = wb_commits - db_commits.keys()
|
# missing_commits = wb_commits - db_commits.keys()
|
||||||
# print(f"Adding {len(missing_commits)} commits to database...")
|
# LOGGER.info(f"Adding {len(missing_commits)} commits to database...")
|
||||||
# process_commits(commit_ids=missing_commits, add_to_database=True)
|
# process_commits(commit_ids=missing_commits, add_to_database=True)
|
||||||
# print("Finished importing!")
|
# LOGGER.info("Finished importing!")
|
||||||
|
|
||||||
|
|
||||||
def include_commit(sha: str, repo: git.Repo, base_commit: git.Commit) -> bool:
|
def include_commit(sha: str, repo: git.Repo, base_commit: git.Commit) -> bool:
|
||||||
|
@ -187,12 +187,12 @@ def export_commits(in_file: str, out_file: str) -> None:
|
||||||
|
|
||||||
# Append each missing commit as a new row to the commits
|
# Append each missing commit as a new row to the commits
|
||||||
# worksheet.
|
# worksheet.
|
||||||
print(f"Exporting {len(missing_commits)} commits to {out_file}...")
|
LOGGER.info("Exporting %d commits to %s", len(missing_commits), out_file)
|
||||||
for commit in missing_commits:
|
for commit in missing_commits:
|
||||||
worksheet.append(create_commit_row(commit, repo, worksheet))
|
worksheet.append(create_commit_row(commit, repo, worksheet))
|
||||||
|
|
||||||
workbook.save(out_file)
|
workbook.save(out_file)
|
||||||
print("Finished exporting!")
|
LOGGER.info("Finished exporting!")
|
||||||
|
|
||||||
|
|
||||||
def get_distros() -> List[str]:
|
def get_distros() -> List[str]:
|
||||||
|
@ -251,7 +251,7 @@ def update_commits(in_file: str, out_file: str) -> None:
|
||||||
try:
|
try:
|
||||||
get_column(worksheet, distro)
|
get_column(worksheet, distro)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
print(f"No column with distro '{distro}', please fix spreadsheet!")
|
LOGGER.ERROR(f"No column with distro '{distro}', please fix spreadsheet!")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
commit_column = get_column(worksheet, "Commit ID").column_letter
|
commit_column = get_column(worksheet, "Commit ID").column_letter
|
||||||
|
@ -275,4 +275,4 @@ def update_commits(in_file: str, out_file: str) -> None:
|
||||||
get_cell(worksheet, distro, commit_cell.row).value = "Unknown"
|
get_cell(worksheet, distro, commit_cell.row).value = "Unknown"
|
||||||
|
|
||||||
workbook.save(out_file)
|
workbook.save(out_file)
|
||||||
print("Finished updating!")
|
LOGGER.info("Finished updating!")
|
||||||
|
|
|
@ -81,7 +81,7 @@ def get_hyperv_patch_symbols():
|
||||||
This function clones upstream and gets upstream commits, hyperV files
|
This function clones upstream and gets upstream commits, hyperV files
|
||||||
"""
|
"""
|
||||||
with DatabaseDriver.get_session() as session:
|
with DatabaseDriver.get_session() as session:
|
||||||
# Only annoying thing with SQLAlchemy is this always returns tuples need to be unwrapped.
|
# SQLAlchemy returns tuples which need to be unwrapped
|
||||||
map_symbols_to_patch(
|
map_symbols_to_patch(
|
||||||
[
|
[
|
||||||
commit[0]
|
commit[0]
|
||||||
|
@ -108,15 +108,3 @@ def symbol_checker(symbol_file):
|
||||||
.all()
|
.all()
|
||||||
if len(set(symbols.split(" ")) - symbols_in_file) > 0
|
if len(set(symbols.split(" ")) - symbols_in_file) > 0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def print_missing_symbols(symbol_file):
|
|
||||||
"""
|
|
||||||
Utility function for printing missing symbols
|
|
||||||
"""
|
|
||||||
|
|
||||||
print("Starting the Symbol Checker...")
|
|
||||||
get_hyperv_patch_symbols()
|
|
||||||
missing_symbols = symbol_checker(symbol_file)
|
|
||||||
print("Missing symbols:")
|
|
||||||
print(*missing_symbols)
|
|
||||||
|
|
|
@ -193,15 +193,6 @@ def get_tracked_paths(sections=config.sections) -> List[str]:
|
||||||
return sorted(paths)
|
return sorted(paths)
|
||||||
|
|
||||||
|
|
||||||
def print_tracked_paths():
|
|
||||||
"""
|
|
||||||
Utility function for printing tracked paths
|
|
||||||
"""
|
|
||||||
|
|
||||||
for path in get_tracked_paths():
|
|
||||||
print(path)
|
|
||||||
|
|
||||||
|
|
||||||
class GitProgressPrinter(git.RemoteProgress):
|
class GitProgressPrinter(git.RemoteProgress):
|
||||||
"""
|
"""
|
||||||
Simple status printer for GitPython
|
Simple status printer for GitPython
|
||||||
|
|
Загрузка…
Ссылка в новой задаче