summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/tinfoil.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/tinfoil.py')
-rw-r--r--bitbake/lib/bb/tinfoil.py32
1 files changed, 24 insertions, 8 deletions
diff --git a/bitbake/lib/bb/tinfoil.py b/bitbake/lib/bb/tinfoil.py
index 763c329810..dcd3910cc4 100644
--- a/bitbake/lib/bb/tinfoil.py
+++ b/bitbake/lib/bb/tinfoil.py
@@ -10,6 +10,7 @@
10import logging 10import logging
11import os 11import os
12import sys 12import sys
13import time
13import atexit 14import atexit
14import re 15import re
15from collections import OrderedDict, defaultdict 16from collections import OrderedDict, defaultdict
@@ -52,6 +53,10 @@ class TinfoilDataStoreConnectorVarHistory:
52 def remoteCommand(self, cmd, *args, **kwargs): 53 def remoteCommand(self, cmd, *args, **kwargs):
53 return self.tinfoil.run_command('dataStoreConnectorVarHistCmd', self.dsindex, cmd, args, kwargs) 54 return self.tinfoil.run_command('dataStoreConnectorVarHistCmd', self.dsindex, cmd, args, kwargs)
54 55
56 def emit(self, var, oval, val, o, d):
57 ret = self.tinfoil.run_command('dataStoreConnectorVarHistCmdEmit', self.dsindex, var, oval, val, d.dsindex)
58 o.write(ret)
59
55 def __getattr__(self, name): 60 def __getattr__(self, name):
56 if not hasattr(bb.data_smart.VariableHistory, name): 61 if not hasattr(bb.data_smart.VariableHistory, name):
57 raise AttributeError("VariableHistory has no such method %s" % name) 62 raise AttributeError("VariableHistory has no such method %s" % name)
@@ -320,11 +325,11 @@ class Tinfoil:
320 self.recipes_parsed = False 325 self.recipes_parsed = False
321 self.quiet = 0 326 self.quiet = 0
322 self.oldhandlers = self.logger.handlers[:] 327 self.oldhandlers = self.logger.handlers[:]
328 self.localhandlers = []
323 if setup_logging: 329 if setup_logging:
324 # This is the *client-side* logger, nothing to do with 330 # This is the *client-side* logger, nothing to do with
325 # logging messages from the server 331 # logging messages from the server
326 bb.msg.logger_create('BitBake', output) 332 bb.msg.logger_create('BitBake', output)
327 self.localhandlers = []
328 for handler in self.logger.handlers: 333 for handler in self.logger.handlers:
329 if handler not in self.oldhandlers: 334 if handler not in self.oldhandlers:
330 self.localhandlers.append(handler) 335 self.localhandlers.append(handler)
@@ -440,11 +445,17 @@ class Tinfoil:
440 to initialise Tinfoil and use it with config_only=True first and 445 to initialise Tinfoil and use it with config_only=True first and
441 then conditionally call this function to parse recipes later. 446 then conditionally call this function to parse recipes later.
442 """ 447 """
443 config_params = TinfoilConfigParameters(config_only=False) 448 config_params = TinfoilConfigParameters(config_only=False, quiet=self.quiet)
444 self.run_actions(config_params) 449 self.run_actions(config_params)
445 self.recipes_parsed = True 450 self.recipes_parsed = True
446 451
447 def run_command(self, command, *params): 452 def modified_files(self):
453 """
454 Notify the server it needs to revalidate it's caches since the client has modified files
455 """
456 self.run_command("revalidateCaches")
457
458 def run_command(self, command, *params, handle_events=True):
448 """ 459 """
449 Run a command on the server (as implemented in bb.command). 460 Run a command on the server (as implemented in bb.command).
450 Note that there are two types of command - synchronous and 461 Note that there are two types of command - synchronous and
@@ -464,7 +475,7 @@ class Tinfoil:
464 try: 475 try:
465 result = self.server_connection.connection.runCommand(commandline) 476 result = self.server_connection.connection.runCommand(commandline)
466 finally: 477 finally:
467 while True: 478 while handle_events:
468 event = self.wait_event() 479 event = self.wait_event()
469 if not event: 480 if not event:
470 break 481 break
@@ -489,7 +500,7 @@ class Tinfoil:
489 Wait for an event from the server for the specified time. 500 Wait for an event from the server for the specified time.
490 A timeout of 0 means don't wait if there are no events in the queue. 501 A timeout of 0 means don't wait if there are no events in the queue.
491 Returns the next event in the queue or None if the timeout was 502 Returns the next event in the queue or None if the timeout was
492 reached. Note that in order to recieve any events you will 503 reached. Note that in order to receive any events you will
493 first need to set the internal event mask using set_event_mask() 504 first need to set the internal event mask using set_event_mask()
494 (otherwise whatever event mask the UI set up will be in effect). 505 (otherwise whatever event mask the UI set up will be in effect).
495 """ 506 """
@@ -725,6 +736,7 @@ class Tinfoil:
725 736
726 ret = self.run_command('buildTargets', targets, task) 737 ret = self.run_command('buildTargets', targets, task)
727 if handle_events: 738 if handle_events:
739 lastevent = time.time()
728 result = False 740 result = False
729 # Borrowed from knotty, instead somewhat hackily we use the helper 741 # Borrowed from knotty, instead somewhat hackily we use the helper
730 # as the object to store "shutdown" on 742 # as the object to store "shutdown" on
@@ -737,6 +749,7 @@ class Tinfoil:
737 try: 749 try:
738 event = self.wait_event(0.25) 750 event = self.wait_event(0.25)
739 if event: 751 if event:
752 lastevent = time.time()
740 if event_callback and event_callback(event): 753 if event_callback and event_callback(event):
741 continue 754 continue
742 if helper.eventHandler(event): 755 if helper.eventHandler(event):
@@ -757,7 +770,7 @@ class Tinfoil:
757 if parseprogress: 770 if parseprogress:
758 parseprogress.update(event.progress) 771 parseprogress.update(event.progress)
759 else: 772 else:
760 bb.warn("Got ProcessProgress event for someting that never started?") 773 bb.warn("Got ProcessProgress event for something that never started?")
761 continue 774 continue
762 if isinstance(event, bb.event.ProcessFinished): 775 if isinstance(event, bb.event.ProcessFinished):
763 if self.quiet > 1: 776 if self.quiet > 1:
@@ -769,7 +782,7 @@ class Tinfoil:
769 if isinstance(event, bb.command.CommandCompleted): 782 if isinstance(event, bb.command.CommandCompleted):
770 result = True 783 result = True
771 break 784 break
772 if isinstance(event, bb.command.CommandFailed): 785 if isinstance(event, (bb.command.CommandFailed, bb.command.CommandExit)):
773 self.logger.error(str(event)) 786 self.logger.error(str(event))
774 result = False 787 result = False
775 break 788 break
@@ -781,10 +794,13 @@ class Tinfoil:
781 self.logger.error(str(event)) 794 self.logger.error(str(event))
782 result = False 795 result = False
783 break 796 break
784
785 elif helper.shutdown > 1: 797 elif helper.shutdown > 1:
786 break 798 break
787 termfilter.updateFooter() 799 termfilter.updateFooter()
800 if time.time() > (lastevent + (3*60)):
801 if not self.run_command('ping', handle_events=False):
802 print("\nUnable to ping server and no events, closing down...\n")
803 return False
788 except KeyboardInterrupt: 804 except KeyboardInterrupt:
789 termfilter.clearFooter() 805 termfilter.clearFooter()
790 if helper.shutdown == 1: 806 if helper.shutdown == 1: