bitbake-dev: Change terminology online/offline to sync/async
Change the terminology from online/offline to sync/async when referring to commands that return a result immediately versus those that produce changes that are emitted as events over time.
This commit is contained in:
parent
f0b1d561c7
commit
c26d6cfda0
|
@ -21,79 +21,79 @@ Provide an interface to interact with the bitbake server through 'commands'
|
||||||
|
|
||||||
"""
|
"""
|
||||||
The bitbake server takes 'commands' from its UI/commandline.
|
The bitbake server takes 'commands' from its UI/commandline.
|
||||||
Commands are either 'online' of 'offline' in nature.
|
Commands are either synchronous or asynchronous.
|
||||||
Offline commands return data to the client in the form of events.
|
Async commands return data to the client in the form of events.
|
||||||
Online commands must only return data through the function return value
|
Sync commands must only return data through the function return value
|
||||||
and must not trigger events, directly or indirectly.
|
and must not trigger events, directly or indirectly.
|
||||||
Commands are queued in a CommandQueue
|
Commands are queued in a CommandQueue
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import bb
|
import bb
|
||||||
|
|
||||||
offline_cmds = {}
|
async_cmds = {}
|
||||||
online_cmds = {}
|
sync_cmds = {}
|
||||||
|
|
||||||
class Command:
|
class Command:
|
||||||
"""
|
"""
|
||||||
A queue of 'offline' commands for bitbake
|
A queue of asynchronous commands for bitbake
|
||||||
"""
|
"""
|
||||||
def __init__(self, cooker):
|
def __init__(self, cooker):
|
||||||
|
|
||||||
self.cooker = cooker
|
self.cooker = cooker
|
||||||
self.cmds_online = CommandsOnline()
|
self.cmds_sync = CommandsSync()
|
||||||
self.cmds_offline = CommandsOffline()
|
self.cmds_async = CommandsAsync()
|
||||||
|
|
||||||
# FIXME Add lock for this
|
# FIXME Add lock for this
|
||||||
self.currentOfflineCommand = None
|
self.currentAsyncCommand = None
|
||||||
|
|
||||||
for attr in CommandsOnline.__dict__:
|
for attr in CommandsSync.__dict__:
|
||||||
command = attr[:].lower()
|
command = attr[:].lower()
|
||||||
method = getattr(CommandsOnline, attr)
|
method = getattr(CommandsSync, attr)
|
||||||
online_cmds[command] = (method)
|
sync_cmds[command] = (method)
|
||||||
|
|
||||||
for attr in CommandsOffline.__dict__:
|
for attr in CommandsAsync.__dict__:
|
||||||
command = attr[:].lower()
|
command = attr[:].lower()
|
||||||
method = getattr(CommandsOffline, attr)
|
method = getattr(CommandsAsync, attr)
|
||||||
offline_cmds[command] = (method)
|
async_cmds[command] = (method)
|
||||||
|
|
||||||
def runCommand(self, commandline):
|
def runCommand(self, commandline):
|
||||||
try:
|
try:
|
||||||
command = commandline.pop(0)
|
command = commandline.pop(0)
|
||||||
if command in CommandsOnline.__dict__:
|
if command in CommandsSync.__dict__:
|
||||||
# Can run online commands straight away
|
# Can run online commands straight away
|
||||||
return getattr(CommandsOnline, command)(self.cmds_online, self, commandline)
|
return getattr(CommandsSync, command)(self.cmds_sync, self, commandline)
|
||||||
if self.currentOfflineCommand is not None:
|
if self.currentAsyncCommand is not None:
|
||||||
return "Busy (%s in progress)" % self.currentOfflineCommand[0]
|
return "Busy (%s in progress)" % self.currentAsyncCommand[0]
|
||||||
if command not in CommandsOffline.__dict__:
|
if command not in CommandsAsync.__dict__:
|
||||||
return "No such command"
|
return "No such command"
|
||||||
self.currentOfflineCommand = (command, commandline)
|
self.currentAsyncCommand = (command, commandline)
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
import traceback
|
import traceback
|
||||||
return traceback.format_exc()
|
return traceback.format_exc()
|
||||||
|
|
||||||
def runOfflineCommand(self):
|
def runAsyncCommand(self):
|
||||||
try:
|
try:
|
||||||
if self.currentOfflineCommand is not None:
|
if self.currentAsyncCommand is not None:
|
||||||
(command, options) = self.currentOfflineCommand
|
(command, options) = self.currentAsyncCommand
|
||||||
getattr(CommandsOffline, command)(self.cmds_offline, self, options)
|
getattr(CommandsAsync, command)(self.cmds_async, self, options)
|
||||||
except:
|
except:
|
||||||
import traceback
|
import traceback
|
||||||
self.finishOfflineCommand(traceback.format_exc())
|
self.finishAsyncCommand(traceback.format_exc())
|
||||||
|
|
||||||
def finishOfflineCommand(self, error = None):
|
def finishAsyncCommand(self, error = None):
|
||||||
if error:
|
if error:
|
||||||
bb.event.fire(bb.command.CookerCommandFailed(self.cooker.configuration.event_data, error))
|
bb.event.fire(bb.command.CookerCommandFailed(self.cooker.configuration.event_data, error))
|
||||||
else:
|
else:
|
||||||
bb.event.fire(bb.command.CookerCommandCompleted(self.cooker.configuration.event_data))
|
bb.event.fire(bb.command.CookerCommandCompleted(self.cooker.configuration.event_data))
|
||||||
self.currentOfflineCommand = None
|
self.currentAsyncCommand = None
|
||||||
|
|
||||||
|
|
||||||
class CommandsOnline:
|
class CommandsSync:
|
||||||
"""
|
"""
|
||||||
A class of online commands
|
A class of synchronous commands
|
||||||
These should run quickly so as not to hurt interactive performance.
|
These should run quickly so as not to hurt interactive performance.
|
||||||
These must not influence any running offline command.
|
These must not influence any running synchronous command.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def stateShutdown(self, command, params):
|
def stateShutdown(self, command, params):
|
||||||
|
@ -125,9 +125,9 @@ class CommandsOnline:
|
||||||
|
|
||||||
return bb.data.getVar(varname, command.cooker.configuration.data, expand)
|
return bb.data.getVar(varname, command.cooker.configuration.data, expand)
|
||||||
|
|
||||||
class CommandsOffline:
|
class CommandsAsync:
|
||||||
"""
|
"""
|
||||||
A class of offline commands
|
A class of asynchronous commands
|
||||||
These functions communicate via generated events.
|
These functions communicate via generated events.
|
||||||
Any function that requires metadata parsing should be here.
|
Any function that requires metadata parsing should be here.
|
||||||
"""
|
"""
|
||||||
|
@ -156,7 +156,7 @@ class CommandsOffline:
|
||||||
pkgs_to_build = params[0]
|
pkgs_to_build = params[0]
|
||||||
|
|
||||||
command.cooker.generateDepTreeEvent(pkgs_to_build)
|
command.cooker.generateDepTreeEvent(pkgs_to_build)
|
||||||
command.finishOfflineCommand()
|
command.finishAsyncCommand()
|
||||||
|
|
||||||
def generateDotGraph(self, command, params):
|
def generateDotGraph(self, command, params):
|
||||||
"""
|
"""
|
||||||
|
@ -165,14 +165,14 @@ class CommandsOffline:
|
||||||
pkgs_to_build = params[0]
|
pkgs_to_build = params[0]
|
||||||
|
|
||||||
command.cooker.generateDotGraphFiles(pkgs_to_build)
|
command.cooker.generateDotGraphFiles(pkgs_to_build)
|
||||||
command.finishOfflineCommand()
|
command.finishAsyncCommand()
|
||||||
|
|
||||||
def showVersions(self, command, params):
|
def showVersions(self, command, params):
|
||||||
"""
|
"""
|
||||||
Show the currently selected versions
|
Show the currently selected versions
|
||||||
"""
|
"""
|
||||||
command.cooker.showVersions()
|
command.cooker.showVersions()
|
||||||
command.finishOfflineCommand()
|
command.finishAsyncCommand()
|
||||||
|
|
||||||
def showEnvironment(self, command, params):
|
def showEnvironment(self, command, params):
|
||||||
"""
|
"""
|
||||||
|
@ -182,14 +182,14 @@ class CommandsOffline:
|
||||||
pkg = params[1]
|
pkg = params[1]
|
||||||
|
|
||||||
command.cooker.showEnvironment(bfile, pkg)
|
command.cooker.showEnvironment(bfile, pkg)
|
||||||
command.finishOfflineCommand()
|
command.finishAsyncCommand()
|
||||||
|
|
||||||
def parseFiles(self, command, params):
|
def parseFiles(self, command, params):
|
||||||
"""
|
"""
|
||||||
Parse the .bb files
|
Parse the .bb files
|
||||||
"""
|
"""
|
||||||
command.cooker.updateCache()
|
command.cooker.updateCache()
|
||||||
command.finishOfflineCommand()
|
command.finishAsyncCommand()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Events
|
# Events
|
||||||
|
|
|
@ -169,12 +169,12 @@ class BBCooker:
|
||||||
|
|
||||||
def runCommands(self, server, data, abort):
|
def runCommands(self, server, data, abort):
|
||||||
"""
|
"""
|
||||||
Run any queued offline command
|
Run any queued asynchronous command
|
||||||
This is done by the idle handler so it runs in true context rather than
|
This is done by the idle handler so it runs in true context rather than
|
||||||
tied to any UI.
|
tied to any UI.
|
||||||
"""
|
"""
|
||||||
if self.cookerIdle and not abort:
|
if self.cookerIdle and not abort:
|
||||||
self.command.runOfflineCommand()
|
self.command.runAsyncCommand()
|
||||||
|
|
||||||
# Always reschedule
|
# Always reschedule
|
||||||
return True
|
return True
|
||||||
|
@ -670,7 +670,7 @@ class BBCooker:
|
||||||
retval = False
|
retval = False
|
||||||
if not retval:
|
if not retval:
|
||||||
self.cookerIdle = True
|
self.cookerIdle = True
|
||||||
self.command.finishOfflineCommand()
|
self.command.finishAsyncCommand()
|
||||||
bb.event.fire(bb.event.BuildCompleted(buildname, targets, self.configuration.event_data, failures))
|
bb.event.fire(bb.event.BuildCompleted(buildname, targets, self.configuration.event_data, failures))
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
|
@ -703,7 +703,7 @@ class BBCooker:
|
||||||
retval = False
|
retval = False
|
||||||
if not retval:
|
if not retval:
|
||||||
self.cookerIdle = True
|
self.cookerIdle = True
|
||||||
self.command.finishOfflineCommand()
|
self.command.finishAsyncCommand()
|
||||||
bb.event.fire(bb.event.BuildCompleted(buildname, targets, self.configuration.event_data, failures))
|
bb.event.fire(bb.event.BuildCompleted(buildname, targets, self.configuration.event_data, failures))
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue