def __init__(self, be): super(LocalhostBEController, self).__init__(be) from os.path import dirname as DN self.cwd = DN(DN(DN(DN(DN(os.path.realpath(__file__)))))) if self.be.address is None or len(self.be.address) == 0: self.be.address = "build" self.be.save() self.bwd = self.be.address self.dburl = settings.getDATABASE_URL() # transform relative paths to absolute ones if not self.bwd.startswith("/"): self.bwd = os.path.join(self.cwd, self.bwd) self._createBE()
def __init__(self, be): super(LocalhostBEController, self).__init__(be) self.dburl = settings.getDATABASE_URL() self.pokydirname = None self.islayerset = False
def __init__(self, be): super(SSHBEController, self).__init__(be) self.dburl = settings.getDATABASE_URL() self.pokydirname = None self.islayerset = False
def handle_noargs(self,**options): print getDATABASE_URL()
def __init__(self, be): super(LocalhostBEController, self).__init__(be) self.dburl = settings.getDATABASE_URL() self.pokydirname = None
def startBBServer(self): assert self.pokydirname and os.path.exists(self.pokydirname) assert self.islayerset # find our own toasterui listener/bitbake from toaster.bldcontrol.management.commands.loadconf import _reduce_canon_path own_bitbake = _reduce_canon_path( os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../../bin/bitbake")) assert os.path.exists(own_bitbake) and os.path.isfile(own_bitbake) logger.debug("localhostbecontroller: running the listener at %s" % own_bitbake) toaster_ui_log_filepath = os.path.join(self.be.builddir, "toaster_ui.log") # get the file length; we need to detect the _last_ start of the toaster UI, not the first toaster_ui_log_filelength = 0 if os.path.exists(toaster_ui_log_filepath): with open(toaster_ui_log_filepath, "w") as f: f.seek(0, 2) # jump to the end toaster_ui_log_filelength = f.tell() cmd = "bash -c \"source %s/oe-init-build-env %s 2>&1 >toaster_server.log && bitbake --read %s/conf/toaster-pre.conf --postread %s/conf/toaster.conf --server-only -t xmlrpc -B 0.0.0.0:0 2>&1 >>toaster_server.log \"" % ( self.pokydirname, self.be.builddir, self.be.builddir, self.be.builddir) port = "-1" logger.debug("localhostbecontroller: starting builder \n%s\n" % cmd) cmdoutput = self._shellcmd(cmd) with open(self.be.builddir + "/toaster_server.log", "r") as f: for i in f.readlines(): if i.startswith("Bitbake server address"): port = i.split(" ")[-1] logger.debug( "localhostbecontroller: Found bitbake server port %s" % port) cmd = "bash -c \"source %s/oe-init-build-env-memres -1 %s && %s --observe-only -u toasterui --remote-server=0.0.0.0:-1 -t xmlrpc\"" % \ (self.pokydirname, self.be.builddir, own_bitbake) # Use a copy of the current environment and add the DATABASE_URL # for the bitbake observer process. env = os.environ.copy() env['DATABASE_URL'] = settings.getDATABASE_URL() with open(toaster_ui_log_filepath, "a+") as f: p = subprocess.Popen(cmd, cwd=self.be.builddir, shell=True, stdout=f, stderr=f, env=env) def _toaster_ui_started(filepath, filepos=0): if not os.path.exists(filepath): return False with open(filepath, "r") as f: f.seek(filepos) for line in f: if line.startswith("NOTE: ToasterUI waiting for events"): return True return False retries = 0 started = False while not started and retries < 50: started = _toaster_ui_started(toaster_ui_log_filepath, toaster_ui_log_filelength) import time logger.debug( "localhostbecontroller: Waiting bitbake server to start") time.sleep(0.5) retries += 1 if not started: toaster_ui_log = open( os.path.join(self.be.builddir, "toaster_ui.log"), "r").read() toaster_server_log = open( os.path.join(self.be.builddir, "toaster_server.log"), "r").read() raise BuildSetupException( "localhostbecontroller: Bitbake server did not start in 25 seconds, aborting (Error: '%s' '%s')" % (toaster_ui_log, toaster_server_log)) logger.debug("localhostbecontroller: Started bitbake server") while port == "-1": # the port specification is "autodetect"; read the bitbake.lock file with open("%s/bitbake.lock" % self.be.builddir, "r") as f: for line in f.readlines(): if ":" in line: port = line.split(":")[1].strip() logger.debug( "localhostbecontroller: Autodetected bitbake port %s", port) break assert self.be.sourcedir and os.path.exists(self.be.builddir) self.be.bbaddress = "localhost" self.be.bbport = port self.be.bbstate = BuildEnvironment.SERVER_STARTED self.be.save()
def startBBServer(self): assert self.pokydirname and os.path.exists(self.pokydirname) assert self.islayerset # find our own toasterui listener/bitbake from toaster.bldcontrol.management.commands.loadconf import _reduce_canon_path own_bitbake = _reduce_canon_path(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../../../bin/bitbake")) assert os.path.exists(own_bitbake) and os.path.isfile(own_bitbake) logger.debug("localhostbecontroller: running the listener at %s" % own_bitbake) toaster_ui_log_filepath = os.path.join(self.be.builddir, "toaster_ui.log") # get the file length; we need to detect the _last_ start of the toaster UI, not the first toaster_ui_log_filelength = 0 if os.path.exists(toaster_ui_log_filepath): with open(toaster_ui_log_filepath, "w") as f: f.seek(0, 2) # jump to the end toaster_ui_log_filelength = f.tell() cmd = "bash -c \"source %s/oe-init-build-env %s 2>&1 >toaster_server.log && bitbake --read %s/conf/toaster-pre.conf --postread %s/conf/toaster.conf --server-only -t xmlrpc -B 0.0.0.0:0 2>&1 >>toaster_server.log \"" % (self.pokydirname, self.be.builddir, self.be.builddir, self.be.builddir) port = "-1" logger.debug("localhostbecontroller: starting builder \n%s\n" % cmd) cmdoutput = self._shellcmd(cmd) with open(self.be.builddir + "/toaster_server.log", "r") as f: for i in f.readlines(): if i.startswith("Bitbake server address"): port = i.split(" ")[-1] logger.debug("localhostbecontroller: Found bitbake server port %s" % port) cmd = "bash -c \"source %s/oe-init-build-env-memres -1 %s && %s --observe-only -u toasterui --remote-server=0.0.0.0:-1 -t xmlrpc\"" % \ (self.pokydirname, self.be.builddir, own_bitbake) # Use a copy of the current environment and add the DATABASE_URL # for the bitbake observer process. env = os.environ.copy() env['DATABASE_URL'] = settings.getDATABASE_URL() with open(toaster_ui_log_filepath, "a+") as f: p = subprocess.Popen(cmd, cwd = self.be.builddir, shell=True, stdout=f, stderr=f, env=env) def _toaster_ui_started(filepath, filepos = 0): if not os.path.exists(filepath): return False with open(filepath, "r") as f: f.seek(filepos) for line in f: if line.startswith("NOTE: ToasterUI waiting for events"): return True return False retries = 0 started = False while not started and retries < 50: started = _toaster_ui_started(toaster_ui_log_filepath, toaster_ui_log_filelength) import time logger.debug("localhostbecontroller: Waiting bitbake server to start") time.sleep(0.5) retries += 1 if not started: toaster_ui_log = open(os.path.join(self.be.builddir, "toaster_ui.log"), "r").read() toaster_server_log = open(os.path.join(self.be.builddir, "toaster_server.log"), "r").read() raise BuildSetupException("localhostbecontroller: Bitbake server did not start in 25 seconds, aborting (Error: '%s' '%s')" % (toaster_ui_log, toaster_server_log)) logger.debug("localhostbecontroller: Started bitbake server") while port == "-1": # the port specification is "autodetect"; read the bitbake.lock file with open("%s/bitbake.lock" % self.be.builddir, "r") as f: for line in f.readlines(): if ":" in line: port = line.split(":")[1].strip() logger.debug("localhostbecontroller: Autodetected bitbake port %s", port) break assert self.be.sourcedir and os.path.exists(self.be.builddir) self.be.bbaddress = "localhost" self.be.bbport = port self.be.bbstate = BuildEnvironment.SERVER_STARTED self.be.save()