summaryrefslogtreecommitdiffstats
path: root/bitbake/bin
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2016-05-12 08:30:35 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-06-02 08:24:02 +0100
commit0f2c59367a649de5f57acdccfb4f1fdba9cde730 (patch)
tree7a3558a3e08e690fbb0b5bdc4044316f9ab4bbcb /bitbake/bin
parentef1df516512587ad415f76a9626620992d660e45 (diff)
downloadpoky-0f2c59367a649de5f57acdccfb4f1fdba9cde730.tar.gz
bitbake: bitbake: Convert to python 3
Various misc changes to convert bitbake to python3 which don't warrant separation into separate commits. (Bitbake rev: d0f904d407f57998419bd9c305ce53e5eaa36b24) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/bin')
-rwxr-xr-xbitbake/bin/bitbake5
-rwxr-xr-xbitbake/bin/bitbake-diffsigs4
-rwxr-xr-xbitbake/bin/bitbake-dumpsig4
-rwxr-xr-xbitbake/bin/bitbake-layers5
-rwxr-xr-xbitbake/bin/bitbake-prserv2
-rwxr-xr-xbitbake/bin/bitbake-selftest2
-rwxr-xr-xbitbake/bin/bitbake-worker60
-rwxr-xr-xbitbake/bin/bitdoc2
-rwxr-xr-xbitbake/bin/image-writer8
-rwxr-xr-xbitbake/bin/toaster-eventreplay2
10 files changed, 51 insertions, 43 deletions
diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake
index bba87b082c..9813a08483 100755
--- a/bitbake/bin/bitbake
+++ b/bitbake/bin/bitbake
@@ -1,4 +1,4 @@
1#!/usr/bin/env python 1#!/usr/bin/env python3
2# ex:ts=4:sw=4:sts=4:et 2# ex:ts=4:sw=4:sts=4:et
3# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- 3# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
4# 4#
@@ -35,6 +35,9 @@ except RuntimeError as exc:
35from bb import cookerdata 35from bb import cookerdata
36from bb.main import bitbake_main, BitBakeConfigParameters, BBMainException 36from bb.main import bitbake_main, BitBakeConfigParameters, BBMainException
37 37
38if sys.getfilesystemencoding() != "utf-8":
39 sys.exit("Please use a locale setting which supports utf-8.\nPython can't change the filesystem locale after loading so we need a utf-8 when python starts or things won't work.")
40
38__version__ = "1.31.0" 41__version__ = "1.31.0"
39 42
40if __name__ == "__main__": 43if __name__ == "__main__":
diff --git a/bitbake/bin/bitbake-diffsigs b/bitbake/bin/bitbake-diffsigs
index 67c60dbb00..3b6ef8811c 100755
--- a/bitbake/bin/bitbake-diffsigs
+++ b/bitbake/bin/bitbake-diffsigs
@@ -1,4 +1,4 @@
1#!/usr/bin/env python 1#!/usr/bin/env python3
2 2
3# bitbake-diffsigs 3# bitbake-diffsigs
4# BitBake task signature data comparison utility 4# BitBake task signature data comparison utility
@@ -24,6 +24,7 @@ import warnings
24import fnmatch 24import fnmatch
25import optparse 25import optparse
26import logging 26import logging
27import pickle
27 28
28sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib')) 29sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib'))
29 30
@@ -121,7 +122,6 @@ else:
121 if len(args) == 1: 122 if len(args) == 1:
122 parser.print_help() 123 parser.print_help()
123 else: 124 else:
124 import cPickle
125 try: 125 try:
126 if len(args) == 2: 126 if len(args) == 2:
127 output = bb.siggen.dump_sigfile(sys.argv[1]) 127 output = bb.siggen.dump_sigfile(sys.argv[1])
diff --git a/bitbake/bin/bitbake-dumpsig b/bitbake/bin/bitbake-dumpsig
index ffaed1f457..58ba1cad04 100755
--- a/bitbake/bin/bitbake-dumpsig
+++ b/bitbake/bin/bitbake-dumpsig
@@ -1,4 +1,4 @@
1#!/usr/bin/env python 1#!/usr/bin/env python3
2 2
3# bitbake-dumpsig 3# bitbake-dumpsig
4# BitBake task signature dump utility 4# BitBake task signature dump utility
@@ -23,6 +23,7 @@ import sys
23import warnings 23import warnings
24import optparse 24import optparse
25import logging 25import logging
26import pickle
26 27
27sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib')) 28sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib'))
28 29
@@ -51,7 +52,6 @@ options, args = parser.parse_args(sys.argv)
51if len(args) == 1: 52if len(args) == 1:
52 parser.print_help() 53 parser.print_help()
53else: 54else:
54 import cPickle
55 try: 55 try:
56 output = bb.siggen.dump_sigfile(args[1]) 56 output = bb.siggen.dump_sigfile(args[1])
57 except IOError as e: 57 except IOError as e:
diff --git a/bitbake/bin/bitbake-layers b/bitbake/bin/bitbake-layers
index d8ffa9592a..0c973dfd2f 100755
--- a/bitbake/bin/bitbake-layers
+++ b/bitbake/bin/bitbake-layers
@@ -1,4 +1,4 @@
1#!/usr/bin/env python 1#!/usr/bin/env python3
2 2
3# This script has subcommands which operate against your bitbake layers, either 3# This script has subcommands which operate against your bitbake layers, either
4# displaying useful information, or acting against them. 4# displaying useful information, or acting against them.
@@ -48,7 +48,6 @@ def logger_create(name, output=sys.stderr):
48 logger.setLevel(logging.INFO) 48 logger.setLevel(logging.INFO)
49 return logger 49 return logger
50 50
51
52def logger_setup_color(logger, color='auto'): 51def logger_setup_color(logger, color='auto'):
53 from bb.msg import BBLogFormatter 52 from bb.msg import BBLogFormatter
54 console = logging.StreamHandler(sys.stdout) 53 console = logging.StreamHandler(sys.stdout)
@@ -61,7 +60,6 @@ def logger_setup_color(logger, color='auto'):
61 60
62logger = logger_create('bitbake-layers', sys.stdout) 61logger = logger_create('bitbake-layers', sys.stdout)
63 62
64
65def main(): 63def main():
66 parser = argparse.ArgumentParser( 64 parser = argparse.ArgumentParser(
67 description="BitBake layers utility", 65 description="BitBake layers utility",
@@ -78,6 +76,7 @@ def main():
78 parser.add_argument('-h', '--help', action='help', default=argparse.SUPPRESS, 76 parser.add_argument('-h', '--help', action='help', default=argparse.SUPPRESS,
79 help='show this help message and exit') 77 help='show this help message and exit')
80 subparsers = parser.add_subparsers(title='subcommands', metavar='<subcommand>') 78 subparsers = parser.add_subparsers(title='subcommands', metavar='<subcommand>')
79 subparsers.required = True
81 80
82 if global_args.debug: 81 if global_args.debug:
83 logger.setLevel(logging.DEBUG) 82 logger.setLevel(logging.DEBUG)
diff --git a/bitbake/bin/bitbake-prserv b/bitbake/bin/bitbake-prserv
index 03821446b7..f38d2dd882 100755
--- a/bitbake/bin/bitbake-prserv
+++ b/bitbake/bin/bitbake-prserv
@@ -1,4 +1,4 @@
1#!/usr/bin/env python 1#!/usr/bin/env python3
2import os 2import os
3import sys,logging 3import sys,logging
4import optparse 4import optparse
diff --git a/bitbake/bin/bitbake-selftest b/bitbake/bin/bitbake-selftest
index 462eb1b2b4..1e6f35ef0c 100755
--- a/bitbake/bin/bitbake-selftest
+++ b/bitbake/bin/bitbake-selftest
@@ -1,4 +1,4 @@
1#!/usr/bin/env python 1#!/usr/bin/env python3
2# 2#
3# Copyright (C) 2012 Richard Purdie 3# Copyright (C) 2012 Richard Purdie
4# 4#
diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker
index 6a6b26b64a..5d062a23e9 100755
--- a/bitbake/bin/bitbake-worker
+++ b/bitbake/bin/bitbake-worker
@@ -1,4 +1,4 @@
1#!/usr/bin/env python 1#!/usr/bin/env python3
2 2
3import os 3import os
4import sys 4import sys
@@ -10,8 +10,12 @@ import bb
10import select 10import select
11import errno 11import errno
12import signal 12import signal
13import pickle
13from multiprocessing import Lock 14from multiprocessing import Lock
14 15
16if sys.getfilesystemencoding() != "utf-8":
17 sys.exit("Please use a locale setting which supports utf-8.\nPython can't change the filesystem locale after loading so we need a utf-8 when python starts or things won't work.")
18
15# Users shouldn't be running this code directly 19# Users shouldn't be running this code directly
16if len(sys.argv) != 2 or not sys.argv[1].startswith("decafbad"): 20if len(sys.argv) != 2 or not sys.argv[1].startswith("decafbad"):
17 print("bitbake-worker is meant for internal execution by bitbake itself, please don't use it standalone.") 21 print("bitbake-worker is meant for internal execution by bitbake itself, please don't use it standalone.")
@@ -30,19 +34,16 @@ if sys.argv[1].startswith("decafbadbad"):
30# updates to log files for use with tail 34# updates to log files for use with tail
31try: 35try:
32 if sys.stdout.name == '<stdout>': 36 if sys.stdout.name == '<stdout>':
33 sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0) 37 import fcntl
38 fl = fcntl.fcntl(sys.stdout.fileno(), fcntl.F_GETFL)
39 fl |= os.O_SYNC
40 fcntl.fcntl(sys.stdout.fileno(), fcntl.F_SETFL, fl)
41 #sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
34except: 42except:
35 pass 43 pass
36 44
37logger = logging.getLogger("BitBake") 45logger = logging.getLogger("BitBake")
38 46
39try:
40 import cPickle as pickle
41except ImportError:
42 import pickle
43 bb.msg.note(1, bb.msg.domain.Cache, "Importing cPickle failed. Falling back to a very slow implementation.")
44
45
46worker_pipe = sys.stdout.fileno() 47worker_pipe = sys.stdout.fileno()
47bb.utils.nonblockingfd(worker_pipe) 48bb.utils.nonblockingfd(worker_pipe)
48# Need to guard against multiprocessing being used in child processes 49# Need to guard against multiprocessing being used in child processes
@@ -62,10 +63,10 @@ if 0:
62 consolelog.setFormatter(conlogformat) 63 consolelog.setFormatter(conlogformat)
63 logger.addHandler(consolelog) 64 logger.addHandler(consolelog)
64 65
65worker_queue = "" 66worker_queue = b""
66 67
67def worker_fire(event, d): 68def worker_fire(event, d):
68 data = "<event>" + pickle.dumps(event) + "</event>" 69 data = b"<event>" + pickle.dumps(event) + b"</event>"
69 worker_fire_prepickled(data) 70 worker_fire_prepickled(data)
70 71
71def worker_fire_prepickled(event): 72def worker_fire_prepickled(event):
@@ -91,7 +92,7 @@ def worker_child_fire(event, d):
91 global worker_pipe 92 global worker_pipe
92 global worker_pipe_lock 93 global worker_pipe_lock
93 94
94 data = "<event>" + pickle.dumps(event) + "</event>" 95 data = b"<event>" + pickle.dumps(event) + b"</event>"
95 try: 96 try:
96 worker_pipe_lock.acquire() 97 worker_pipe_lock.acquire()
97 worker_pipe.write(data) 98 worker_pipe.write(data)
@@ -251,7 +252,7 @@ def fork_off_task(cfg, data, workerdata, fn, task, taskname, appends, taskdepdat
251 bb.utils.process_profilelog(profname) 252 bb.utils.process_profilelog(profname)
252 os._exit(ret) 253 os._exit(ret)
253 else: 254 else:
254 for key, value in envbackup.iteritems(): 255 for key, value in iter(envbackup.items()):
255 if value is None: 256 if value is None:
256 del os.environ[key] 257 del os.environ[key]
257 else: 258 else:
@@ -268,22 +269,22 @@ class runQueueWorkerPipe():
268 if pipeout: 269 if pipeout:
269 pipeout.close() 270 pipeout.close()
270 bb.utils.nonblockingfd(self.input) 271 bb.utils.nonblockingfd(self.input)
271 self.queue = "" 272 self.queue = b""
272 273
273 def read(self): 274 def read(self):
274 start = len(self.queue) 275 start = len(self.queue)
275 try: 276 try:
276 self.queue = self.queue + self.input.read(102400) 277 self.queue = self.queue + (self.input.read(102400) or b"")
277 except (OSError, IOError) as e: 278 except (OSError, IOError) as e:
278 if e.errno != errno.EAGAIN: 279 if e.errno != errno.EAGAIN:
279 raise 280 raise
280 281
281 end = len(self.queue) 282 end = len(self.queue)
282 index = self.queue.find("</event>") 283 index = self.queue.find(b"</event>")
283 while index != -1: 284 while index != -1:
284 worker_fire_prepickled(self.queue[:index+8]) 285 worker_fire_prepickled(self.queue[:index+8])
285 self.queue = self.queue[index+8:] 286 self.queue = self.queue[index+8:]
286 index = self.queue.find("</event>") 287 index = self.queue.find(b"</event>")
287 return (end > start) 288 return (end > start)
288 289
289 def close(self): 290 def close(self):
@@ -299,7 +300,7 @@ class BitbakeWorker(object):
299 def __init__(self, din): 300 def __init__(self, din):
300 self.input = din 301 self.input = din
301 bb.utils.nonblockingfd(self.input) 302 bb.utils.nonblockingfd(self.input)
302 self.queue = "" 303 self.queue = b""
303 self.cookercfg = None 304 self.cookercfg = None
304 self.databuilder = None 305 self.databuilder = None
305 self.data = None 306 self.data = None
@@ -336,12 +337,12 @@ class BitbakeWorker(object):
336 except (OSError, IOError): 337 except (OSError, IOError):
337 pass 338 pass
338 if len(self.queue): 339 if len(self.queue):
339 self.handle_item("cookerconfig", self.handle_cookercfg) 340 self.handle_item(b"cookerconfig", self.handle_cookercfg)
340 self.handle_item("workerdata", self.handle_workerdata) 341 self.handle_item(b"workerdata", self.handle_workerdata)
341 self.handle_item("runtask", self.handle_runtask) 342 self.handle_item(b"runtask", self.handle_runtask)
342 self.handle_item("finishnow", self.handle_finishnow) 343 self.handle_item(b"finishnow", self.handle_finishnow)
343 self.handle_item("ping", self.handle_ping) 344 self.handle_item(b"ping", self.handle_ping)
344 self.handle_item("quit", self.handle_quit) 345 self.handle_item(b"quit", self.handle_quit)
345 346
346 for pipe in self.build_pipes: 347 for pipe in self.build_pipes:
347 self.build_pipes[pipe].read() 348 self.build_pipes[pipe].read()
@@ -351,12 +352,12 @@ class BitbakeWorker(object):
351 352
352 353
353 def handle_item(self, item, func): 354 def handle_item(self, item, func):
354 if self.queue.startswith("<" + item + ">"): 355 if self.queue.startswith(b"<" + item + b">"):
355 index = self.queue.find("</" + item + ">") 356 index = self.queue.find(b"</" + item + b">")
356 while index != -1: 357 while index != -1:
357 func(self.queue[(len(item) + 2):index]) 358 func(self.queue[(len(item) + 2):index])
358 self.queue = self.queue[(index + len(item) + 3):] 359 self.queue = self.queue[(index + len(item) + 3):]
359 index = self.queue.find("</" + item + ">") 360 index = self.queue.find(b"</" + item + b">")
360 361
361 def handle_cookercfg(self, data): 362 def handle_cookercfg(self, data):
362 self.cookercfg = pickle.loads(data) 363 self.cookercfg = pickle.loads(data)
@@ -420,12 +421,12 @@ class BitbakeWorker(object):
420 self.build_pipes[pid].close() 421 self.build_pipes[pid].close()
421 del self.build_pipes[pid] 422 del self.build_pipes[pid]
422 423
423 worker_fire_prepickled("<exitcode>" + pickle.dumps((task, status)) + "</exitcode>") 424 worker_fire_prepickled(b"<exitcode>" + pickle.dumps((task, status)) + b"</exitcode>")
424 425
425 def handle_finishnow(self, _): 426 def handle_finishnow(self, _):
426 if self.build_pids: 427 if self.build_pids:
427 logger.info("Sending SIGTERM to remaining %s tasks", len(self.build_pids)) 428 logger.info("Sending SIGTERM to remaining %s tasks", len(self.build_pids))
428 for k, v in self.build_pids.iteritems(): 429 for k, v in iter(self.build_pids.items()):
429 try: 430 try:
430 os.kill(-k, signal.SIGTERM) 431 os.kill(-k, signal.SIGTERM)
431 os.waitpid(-1, 0) 432 os.waitpid(-1, 0)
@@ -435,6 +436,7 @@ class BitbakeWorker(object):
435 self.build_pipes[pipe].read() 436 self.build_pipes[pipe].read()
436 437
437try: 438try:
439 sys.stdin = sys.stdin.detach()
438 worker = BitbakeWorker(sys.stdin) 440 worker = BitbakeWorker(sys.stdin)
439 if not profiling: 441 if not profiling:
440 worker.serve() 442 worker.serve()
diff --git a/bitbake/bin/bitdoc b/bitbake/bin/bitdoc
index defb3dd37a..2744678824 100755
--- a/bitbake/bin/bitdoc
+++ b/bitbake/bin/bitdoc
@@ -1,4 +1,4 @@
1#!/usr/bin/env python 1#!/usr/bin/env python3
2# ex:ts=4:sw=4:sts=4:et 2# ex:ts=4:sw=4:sts=4:et
3# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- 3# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
4# 4#
diff --git a/bitbake/bin/image-writer b/bitbake/bin/image-writer
index e30ab45e31..7ab1d8c979 100755
--- a/bitbake/bin/image-writer
+++ b/bitbake/bin/image-writer
@@ -1,4 +1,4 @@
1#!/usr/bin/env python 1#!/usr/bin/env python3
2 2
3# Copyright (c) 2012 Wind River Systems, Inc. 3# Copyright (c) 2012 Wind River Systems, Inc.
4# 4#
@@ -24,9 +24,13 @@ try:
24except RuntimeError as exc: 24except RuntimeError as exc:
25 sys.exit(str(exc)) 25 sys.exit(str(exc))
26 26
27from gi import pygtkcompat
28
29pygtkcompat.enable()
30pygtkcompat.enable_gtk(version='3.0')
31
27import gtk 32import gtk
28import optparse 33import optparse
29import pygtk
30 34
31from bb.ui.crumbs.hobwidget import HobAltButton, HobButton 35from bb.ui.crumbs.hobwidget import HobAltButton, HobButton
32from bb.ui.crumbs.hig.crumbsmessagedialog import CrumbsMessageDialog 36from bb.ui.crumbs.hig.crumbsmessagedialog import CrumbsMessageDialog
diff --git a/bitbake/bin/toaster-eventreplay b/bitbake/bin/toaster-eventreplay
index 615a7aed15..bdddb908b5 100755
--- a/bitbake/bin/toaster-eventreplay
+++ b/bitbake/bin/toaster-eventreplay
@@ -1,4 +1,4 @@
1#!/usr/bin/env python 1#!/usr/bin/env python3
2# ex:ts=4:sw=4:sts=4:et 2# ex:ts=4:sw=4:sts=4:et
3# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- 3# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
4# 4#