Skip to content

Commit

Permalink
Remove version of pytest from diagnostics.txt
Browse files Browse the repository at this point in the history
# Conflicts:
#	on_modify.py
#	test/docker/Dockerfile
  • Loading branch information
lauft committed Mar 8, 2025
1 parent 234fbd1 commit ccd0ce8
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions on_modify.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
###############################################################################

import json
import logging
import subprocess
import sys

Expand Down Expand Up @@ -72,36 +73,50 @@ def extract_annotation_from(json_obj):

def main(old, new):

start_or_stop = ''
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
fh = logging.FileHandler('hook.log')
fh.setLevel(logging.DEBUG)
logger.addHandler(fh)

# Started task.
logger.debug(f"Calling hook with {old}, {new}")

timew_cmd = None


# Started task.
if 'start' in new and 'start' not in old:
start_or_stop = 'start'
timew_cmd = 'start'

# Stopped task.
elif ('start' not in new or 'end' in new) and 'start' in old:
start_or_stop = 'stop'
timew_cmd = 'stop'

if start_or_stop:
if timew_cmd is not None:
tags = extract_tags_from(new)

subprocess.call(['timew', start_or_stop] + tags + [':yes'])
logger.debug(f"Calling 'timew {timew_cmd} {' '.join(tags)}'")
subprocess.call(['timew', timew_cmd] + tags + [':yes'])

# Modifications to task other than start/stop
elif 'start' in new and 'start' in old:
old_tags = extract_tags_from(old)
new_tags = extract_tags_from(new)

if old_tags != new_tags:
logger.debug(f"Calling 'timew untag @1 {' '.join(old_tags)}'")
subprocess.call(['timew', 'untag', '@1'] + old_tags + [':yes'])
logger.debug(f"Calling 'timew tag @1 {' '.join(new_tags)}'")
subprocess.call(['timew', 'tag', '@1'] + new_tags + [':yes'])

old_annotation = extract_annotation_from(old)
new_annotation = extract_annotation_from(new)

if old_annotation != new_annotation:
logger.debug(f"Calling 'timew annotate @1 {new_annotation}'")
subprocess.call(['timew', 'annotate', '@1', new_annotation])

logger.debug(f"=== ===")


if __name__ == "__main__":
old = json.loads(input_stream.readline().decode("utf-8", errors="replace"))
Expand Down

0 comments on commit ccd0ce8

Please sign in to comment.