Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log few more infos about pipe & messages behavior #5

Merged
merged 2 commits into from
Aug 5, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions picard/tagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ def non_executable_items(self):
def __bool__(self):
return bool(self.commands or self.files or self.mbids or self.urls)

def __str__(self):
return "files: %r mbids: %r urls: %r commands: %r" % (self.files, self.mbids, self.urls, self.commands)


class Tagger(QtWidgets.QApplication):

Expand Down Expand Up @@ -360,10 +363,12 @@ def pipe_server(self):
while self.pipe_handler.pipe_running:
messages = [x for x in self.pipe_handler.read_from_pipe() if x not in IGNORED]
if messages:
log.debug("pipe messages: %r", messages)
thread.to_main(self.load_to_picard, messages)

def load_to_picard(self, items):
parsed_items = ParseItemsToLoad(items)
log.debug(str(parsed_items))

for command in parsed_items.commands:
self.handle_command(command)
Expand Down Expand Up @@ -1193,6 +1198,10 @@ def main(localedir=None, autoupdate=True):
for e in picard_args.exec:
to_be_added.append("command://" + " ".join(e))

if to_be_added:
# note: log level isn't defined yet, it defaults to info, log.debug() would not work here
log.info("Sending messages to main instance: %r" % to_be_added)

try:
pipe_handler = pipe.Pipe(app_name=PICARD_APP_NAME, app_version=PICARD_FANCY_VERSION_STR, args=to_be_added)
should_start = pipe_handler.is_pipe_owner and (picard_args.exec is None)
Expand All @@ -1204,6 +1213,7 @@ def main(localedir=None, autoupdate=True):
# pipe has sent its args to existing one, doesn't need to start
if not should_start:
# just a custom exit code to show that picard instance wasn't created
log.info("Exiting...")
zas marked this conversation as resolved.
Show resolved Hide resolved
sys.exit(EXIT_NO_NEW_INSTANCE)
else:
pipe_handler = None
Expand Down