summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/shell.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/shell.py')
-rw-r--r--bitbake/lib/bb/shell.py166
1 files changed, 84 insertions, 82 deletions
diff --git a/bitbake/lib/bb/shell.py b/bitbake/lib/bb/shell.py
index 7abea0f126..f9ca9d5bd3 100644
--- a/bitbake/lib/bb/shell.py
+++ b/bitbake/lib/bb/shell.py
@@ -52,12 +52,14 @@ PROBLEMS:
52# Import and setup global variables 52# Import and setup global variables
53########################################################################## 53##########################################################################
54 54
55from __future__ import print_function
56from functools import reduce
55try: 57try:
56 set 58 set
57except NameError: 59except NameError:
58 from sets import Set as set 60 from sets import Set as set
59import sys, os, readline, socket, httplib, urllib, commands, popen2, copy, shlex, Queue, fnmatch 61import sys, os, readline, socket, httplib, urllib, commands, popen2, shlex, Queue, fnmatch
60from bb import data, parse, build, fatal, cache, taskdata, runqueue, providers as Providers 62from bb import data, parse, build, cache, taskdata, runqueue, providers as Providers
61 63
62__version__ = "0.5.3.1" 64__version__ = "0.5.3.1"
63__credits__ = """BitBake Shell Version %s (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 65__credits__ = """BitBake Shell Version %s (C) 2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
@@ -98,7 +100,7 @@ class BitBakeShellCommands:
98 100
99 def _checkParsed( self ): 101 def _checkParsed( self ):
100 if not parsed: 102 if not parsed:
101 print "SHELL: This command needs to parse bbfiles..." 103 print("SHELL: This command needs to parse bbfiles...")
102 self.parse( None ) 104 self.parse( None )
103 105
104 def _findProvider( self, item ): 106 def _findProvider( self, item ):
@@ -119,28 +121,28 @@ class BitBakeShellCommands:
119 """Register a new name for a command""" 121 """Register a new name for a command"""
120 new, old = params 122 new, old = params
121 if not old in cmds: 123 if not old in cmds:
122 print "ERROR: Command '%s' not known" % old 124 print("ERROR: Command '%s' not known" % old)
123 else: 125 else:
124 cmds[new] = cmds[old] 126 cmds[new] = cmds[old]
125 print "OK" 127 print("OK")
126 alias.usage = "<alias> <command>" 128 alias.usage = "<alias> <command>"
127 129
128 def buffer( self, params ): 130 def buffer( self, params ):
129 """Dump specified output buffer""" 131 """Dump specified output buffer"""
130 index = params[0] 132 index = params[0]
131 print self._shell.myout.buffer( int( index ) ) 133 print(self._shell.myout.buffer( int( index ) ))
132 buffer.usage = "<index>" 134 buffer.usage = "<index>"
133 135
134 def buffers( self, params ): 136 def buffers( self, params ):
135 """Show the available output buffers""" 137 """Show the available output buffers"""
136 commands = self._shell.myout.bufferedCommands() 138 commands = self._shell.myout.bufferedCommands()
137 if not commands: 139 if not commands:
138 print "SHELL: No buffered commands available yet. Start doing something." 140 print("SHELL: No buffered commands available yet. Start doing something.")
139 else: 141 else:
140 print "="*35, "Available Output Buffers", "="*27 142 print("="*35, "Available Output Buffers", "="*27)
141 for index, cmd in enumerate( commands ): 143 for index, cmd in enumerate( commands ):
142 print "| %s %s" % ( str( index ).ljust( 3 ), cmd ) 144 print("| %s %s" % ( str( index ).ljust( 3 ), cmd ))
143 print "="*88 145 print("="*88)
144 146
145 def build( self, params, cmd = "build" ): 147 def build( self, params, cmd = "build" ):
146 """Build a providee""" 148 """Build a providee"""
@@ -149,7 +151,7 @@ class BitBakeShellCommands:
149 self._checkParsed() 151 self._checkParsed()
150 names = globfilter( cooker.status.pkg_pn, globexpr ) 152 names = globfilter( cooker.status.pkg_pn, globexpr )
151 if len( names ) == 0: names = [ globexpr ] 153 if len( names ) == 0: names = [ globexpr ]
152 print "SHELL: Building %s" % ' '.join( names ) 154 print("SHELL: Building %s" % ' '.join( names ))
153 155
154 td = taskdata.TaskData(cooker.configuration.abort) 156 td = taskdata.TaskData(cooker.configuration.abort)
155 localdata = data.createCopy(cooker.configuration.data) 157 localdata = data.createCopy(cooker.configuration.data)
@@ -168,22 +170,22 @@ class BitBakeShellCommands:
168 tasks.append([name, "do_%s" % cmd]) 170 tasks.append([name, "do_%s" % cmd])
169 171
170 td.add_unresolved(localdata, cooker.status) 172 td.add_unresolved(localdata, cooker.status)
171 173
172 rq = runqueue.RunQueue(cooker, localdata, cooker.status, td, tasks) 174 rq = runqueue.RunQueue(cooker, localdata, cooker.status, td, tasks)
173 rq.prepare_runqueue() 175 rq.prepare_runqueue()
174 rq.execute_runqueue() 176 rq.execute_runqueue()
175 177
176 except Providers.NoProvider: 178 except Providers.NoProvider:
177 print "ERROR: No Provider" 179 print("ERROR: No Provider")
178 last_exception = Providers.NoProvider 180 last_exception = Providers.NoProvider
179 181
180 except runqueue.TaskFailure, fnids: 182 except runqueue.TaskFailure as fnids:
181 for fnid in fnids: 183 for fnid in fnids:
182 print "ERROR: '%s' failed" % td.fn_index[fnid] 184 print("ERROR: '%s' failed" % td.fn_index[fnid])
183 last_exception = runqueue.TaskFailure 185 last_exception = runqueue.TaskFailure
184 186
185 except build.EventException, e: 187 except build.EventException as e:
186 print "ERROR: Couldn't build '%s'" % names 188 print("ERROR: Couldn't build '%s'" % names)
187 last_exception = e 189 last_exception = e
188 190
189 191
@@ -216,7 +218,7 @@ class BitBakeShellCommands:
216 if bbfile is not None: 218 if bbfile is not None:
217 os.system( "%s %s" % ( os.environ.get( "EDITOR", "vi" ), bbfile ) ) 219 os.system( "%s %s" % ( os.environ.get( "EDITOR", "vi" ), bbfile ) )
218 else: 220 else:
219 print "ERROR: Nothing provides '%s'" % name 221 print("ERROR: Nothing provides '%s'" % name)
220 edit.usage = "<providee>" 222 edit.usage = "<providee>"
221 223
222 def environment( self, params ): 224 def environment( self, params ):
@@ -239,14 +241,14 @@ class BitBakeShellCommands:
239 global last_exception 241 global last_exception
240 name = params[0] 242 name = params[0]
241 bf = completeFilePath( name ) 243 bf = completeFilePath( name )
242 print "SHELL: Calling '%s' on '%s'" % ( cmd, bf ) 244 print("SHELL: Calling '%s' on '%s'" % ( cmd, bf ))
243 245
244 try: 246 try:
245 cooker.buildFile(bf, cmd) 247 cooker.buildFile(bf, cmd)
246 except parse.ParseError: 248 except parse.ParseError:
247 print "ERROR: Unable to open or parse '%s'" % bf 249 print("ERROR: Unable to open or parse '%s'" % bf)
248 except build.EventException, e: 250 except build.EventException as e:
249 print "ERROR: Couldn't build '%s'" % name 251 print("ERROR: Couldn't build '%s'" % name)
250 last_exception = e 252 last_exception = e
251 253
252 fileBuild.usage = "<bbfile>" 254 fileBuild.usage = "<bbfile>"
@@ -270,62 +272,62 @@ class BitBakeShellCommands:
270 def fileReparse( self, params ): 272 def fileReparse( self, params ):
271 """(re)Parse a bb file""" 273 """(re)Parse a bb file"""
272 bbfile = params[0] 274 bbfile = params[0]
273 print "SHELL: Parsing '%s'" % bbfile 275 print("SHELL: Parsing '%s'" % bbfile)
274 parse.update_mtime( bbfile ) 276 parse.update_mtime( bbfile )
275 cooker.bb_cache.cacheValidUpdate(bbfile) 277 cooker.bb_cache.cacheValidUpdate(bbfile)
276 fromCache = cooker.bb_cache.loadData(bbfile, cooker.configuration.data, cooker.status) 278 fromCache = cooker.bb_cache.loadData(bbfile, cooker.configuration.data, cooker.status)
277 cooker.bb_cache.sync() 279 cooker.bb_cache.sync()
278 if False: #fromCache: 280 if False: #fromCache:
279 print "SHELL: File has not been updated, not reparsing" 281 print("SHELL: File has not been updated, not reparsing")
280 else: 282 else:
281 print "SHELL: Parsed" 283 print("SHELL: Parsed")
282 fileReparse.usage = "<bbfile>" 284 fileReparse.usage = "<bbfile>"
283 285
284 def abort( self, params ): 286 def abort( self, params ):
285 """Toggle abort task execution flag (see bitbake -k)""" 287 """Toggle abort task execution flag (see bitbake -k)"""
286 cooker.configuration.abort = not cooker.configuration.abort 288 cooker.configuration.abort = not cooker.configuration.abort
287 print "SHELL: Abort Flag is now '%s'" % repr( cooker.configuration.abort ) 289 print("SHELL: Abort Flag is now '%s'" % repr( cooker.configuration.abort ))
288 290
289 def force( self, params ): 291 def force( self, params ):
290 """Toggle force task execution flag (see bitbake -f)""" 292 """Toggle force task execution flag (see bitbake -f)"""
291 cooker.configuration.force = not cooker.configuration.force 293 cooker.configuration.force = not cooker.configuration.force
292 print "SHELL: Force Flag is now '%s'" % repr( cooker.configuration.force ) 294 print("SHELL: Force Flag is now '%s'" % repr( cooker.configuration.force ))
293 295
294 def help( self, params ): 296 def help( self, params ):
295 """Show a comprehensive list of commands and their purpose""" 297 """Show a comprehensive list of commands and their purpose"""
296 print "="*30, "Available Commands", "="*30 298 print("="*30, "Available Commands", "="*30)
297 for cmd in sorted(cmds): 299 for cmd in sorted(cmds):
298 function,numparams,usage,helptext = cmds[cmd] 300 function, numparams, usage, helptext = cmds[cmd]
299 print "| %s | %s" % (usage.ljust(30), helptext) 301 print("| %s | %s" % (usage.ljust(30), helptext))
300 print "="*78 302 print("="*78)
301 303
302 def lastError( self, params ): 304 def lastError( self, params ):
303 """Show the reason or log that was produced by the last BitBake event exception""" 305 """Show the reason or log that was produced by the last BitBake event exception"""
304 if last_exception is None: 306 if last_exception is None:
305 print "SHELL: No Errors yet (Phew)..." 307 print("SHELL: No Errors yet (Phew)...")
306 else: 308 else:
307 reason, event = last_exception.args 309 reason, event = last_exception.args
308 print "SHELL: Reason for the last error: '%s'" % reason 310 print("SHELL: Reason for the last error: '%s'" % reason)
309 if ':' in reason: 311 if ':' in reason:
310 msg, filename = reason.split( ':' ) 312 msg, filename = reason.split( ':' )
311 filename = filename.strip() 313 filename = filename.strip()
312 print "SHELL: Dumping log file for last error:" 314 print("SHELL: Dumping log file for last error:")
313 try: 315 try:
314 print open( filename ).read() 316 print(open( filename ).read())
315 except IOError: 317 except IOError:
316 print "ERROR: Couldn't open '%s'" % filename 318 print("ERROR: Couldn't open '%s'" % filename)
317 319
318 def match( self, params ): 320 def match( self, params ):
319 """Dump all files or providers matching a glob expression""" 321 """Dump all files or providers matching a glob expression"""
320 what, globexpr = params 322 what, globexpr = params
321 if what == "files": 323 if what == "files":
322 self._checkParsed() 324 self._checkParsed()
323 for key in globfilter( cooker.status.pkg_fn, globexpr ): print key 325 for key in globfilter( cooker.status.pkg_fn, globexpr ): print(key)
324 elif what == "providers": 326 elif what == "providers":
325 self._checkParsed() 327 self._checkParsed()
326 for key in globfilter( cooker.status.pkg_pn, globexpr ): print key 328 for key in globfilter( cooker.status.pkg_pn, globexpr ): print(key)
327 else: 329 else:
328 print "Usage: match %s" % self.print_.usage 330 print("Usage: match %s" % self.print_.usage)
329 match.usage = "<files|providers> <glob>" 331 match.usage = "<files|providers> <glob>"
330 332
331 def new( self, params ): 333 def new( self, params ):
@@ -335,15 +337,15 @@ class BitBakeShellCommands:
335 fulldirname = "%s/%s" % ( packages, dirname ) 337 fulldirname = "%s/%s" % ( packages, dirname )
336 338
337 if not os.path.exists( fulldirname ): 339 if not os.path.exists( fulldirname ):
338 print "SHELL: Creating '%s'" % fulldirname 340 print("SHELL: Creating '%s'" % fulldirname)
339 os.mkdir( fulldirname ) 341 os.mkdir( fulldirname )
340 if os.path.exists( fulldirname ) and os.path.isdir( fulldirname ): 342 if os.path.exists( fulldirname ) and os.path.isdir( fulldirname ):
341 if os.path.exists( "%s/%s" % ( fulldirname, filename ) ): 343 if os.path.exists( "%s/%s" % ( fulldirname, filename ) ):
342 print "SHELL: ERROR: %s/%s already exists" % ( fulldirname, filename ) 344 print("SHELL: ERROR: %s/%s already exists" % ( fulldirname, filename ))
343 return False 345 return False
344 print "SHELL: Creating '%s/%s'" % ( fulldirname, filename ) 346 print("SHELL: Creating '%s/%s'" % ( fulldirname, filename ))
345 newpackage = open( "%s/%s" % ( fulldirname, filename ), "w" ) 347 newpackage = open( "%s/%s" % ( fulldirname, filename ), "w" )
346 print >>newpackage,"""DESCRIPTION = "" 348 print("""DESCRIPTION = ""
347SECTION = "" 349SECTION = ""
348AUTHOR = "" 350AUTHOR = ""
349HOMEPAGE = "" 351HOMEPAGE = ""
@@ -370,7 +372,7 @@ SRC_URI = ""
370#do_install() { 372#do_install() {
371# 373#
372#} 374#}
373""" 375""", file=newpackage)
374 newpackage.close() 376 newpackage.close()
375 os.system( "%s %s/%s" % ( os.environ.get( "EDITOR" ), fulldirname, filename ) ) 377 os.system( "%s %s/%s" % ( os.environ.get( "EDITOR" ), fulldirname, filename ) )
376 new.usage = "<directory> <filename>" 378 new.usage = "<directory> <filename>"
@@ -390,14 +392,14 @@ SRC_URI = ""
390 def pasteLog( self, params ): 392 def pasteLog( self, params ):
391 """Send the last event exception error log (if there is one) to http://rafb.net/paste""" 393 """Send the last event exception error log (if there is one) to http://rafb.net/paste"""
392 if last_exception is None: 394 if last_exception is None:
393 print "SHELL: No Errors yet (Phew)..." 395 print("SHELL: No Errors yet (Phew)...")
394 else: 396 else:
395 reason, event = last_exception.args 397 reason, event = last_exception.args
396 print "SHELL: Reason for the last error: '%s'" % reason 398 print("SHELL: Reason for the last error: '%s'" % reason)
397 if ':' in reason: 399 if ':' in reason:
398 msg, filename = reason.split( ':' ) 400 msg, filename = reason.split( ':' )
399 filename = filename.strip() 401 filename = filename.strip()
400 print "SHELL: Pasting log file to pastebin..." 402 print("SHELL: Pasting log file to pastebin...")
401 403
402 file = open( filename ).read() 404 file = open( filename ).read()
403 sendToPastebin( "contents of " + filename, file ) 405 sendToPastebin( "contents of " + filename, file )
@@ -419,23 +421,23 @@ SRC_URI = ""
419 cooker.buildDepgraph() 421 cooker.buildDepgraph()
420 global parsed 422 global parsed
421 parsed = True 423 parsed = True
422 print 424 print()
423 425
424 def reparse( self, params ): 426 def reparse( self, params ):
425 """(re)Parse a providee's bb file""" 427 """(re)Parse a providee's bb file"""
426 bbfile = self._findProvider( params[0] ) 428 bbfile = self._findProvider( params[0] )
427 if bbfile is not None: 429 if bbfile is not None:
428 print "SHELL: Found bbfile '%s' for '%s'" % ( bbfile, params[0] ) 430 print("SHELL: Found bbfile '%s' for '%s'" % ( bbfile, params[0] ))
429 self.fileReparse( [ bbfile ] ) 431 self.fileReparse( [ bbfile ] )
430 else: 432 else:
431 print "ERROR: Nothing provides '%s'" % params[0] 433 print("ERROR: Nothing provides '%s'" % params[0])
432 reparse.usage = "<providee>" 434 reparse.usage = "<providee>"
433 435
434 def getvar( self, params ): 436 def getvar( self, params ):
435 """Dump the contents of an outer BitBake environment variable""" 437 """Dump the contents of an outer BitBake environment variable"""
436 var = params[0] 438 var = params[0]
437 value = data.getVar( var, cooker.configuration.data, 1 ) 439 value = data.getVar( var, cooker.configuration.data, 1 )
438 print value 440 print(value)
439 getvar.usage = "<variable>" 441 getvar.usage = "<variable>"
440 442
441 def peek( self, params ): 443 def peek( self, params ):
@@ -445,9 +447,9 @@ SRC_URI = ""
445 if bbfile is not None: 447 if bbfile is not None:
446 the_data = cooker.bb_cache.loadDataFull(bbfile, cooker.configuration.data) 448 the_data = cooker.bb_cache.loadDataFull(bbfile, cooker.configuration.data)
447 value = the_data.getVar( var, 1 ) 449 value = the_data.getVar( var, 1 )
448 print value 450 print(value)
449 else: 451 else:
450 print "ERROR: Nothing provides '%s'" % name 452 print("ERROR: Nothing provides '%s'" % name)
451 peek.usage = "<providee> <variable>" 453 peek.usage = "<providee> <variable>"
452 454
453 def poke( self, params ): 455 def poke( self, params ):
@@ -455,7 +457,7 @@ SRC_URI = ""
455 name, var, value = params 457 name, var, value = params
456 bbfile = self._findProvider( name ) 458 bbfile = self._findProvider( name )
457 if bbfile is not None: 459 if bbfile is not None:
458 print "ERROR: Sorry, this functionality is currently broken" 460 print("ERROR: Sorry, this functionality is currently broken")
459 #d = cooker.pkgdata[bbfile] 461 #d = cooker.pkgdata[bbfile]
460 #data.setVar( var, value, d ) 462 #data.setVar( var, value, d )
461 463
@@ -463,7 +465,7 @@ SRC_URI = ""
463 #cooker.pkgdata.setDirty(bbfile, d) 465 #cooker.pkgdata.setDirty(bbfile, d)
464 #print "OK" 466 #print "OK"
465 else: 467 else:
466 print "ERROR: Nothing provides '%s'" % name 468 print("ERROR: Nothing provides '%s'" % name)
467 poke.usage = "<providee> <variable> <value>" 469 poke.usage = "<providee> <variable> <value>"
468 470
469 def print_( self, params ): 471 def print_( self, params ):
@@ -471,12 +473,12 @@ SRC_URI = ""
471 what = params[0] 473 what = params[0]
472 if what == "files": 474 if what == "files":
473 self._checkParsed() 475 self._checkParsed()
474 for key in cooker.status.pkg_fn: print key 476 for key in cooker.status.pkg_fn: print(key)
475 elif what == "providers": 477 elif what == "providers":
476 self._checkParsed() 478 self._checkParsed()
477 for key in cooker.status.providers: print key 479 for key in cooker.status.providers: print(key)
478 else: 480 else:
479 print "Usage: print %s" % self.print_.usage 481 print("Usage: print %s" % self.print_.usage)
480 print_.usage = "<files|providers>" 482 print_.usage = "<files|providers>"
481 483
482 def python( self, params ): 484 def python( self, params ):
@@ -496,7 +498,7 @@ SRC_URI = ""
496 """Set an outer BitBake environment variable""" 498 """Set an outer BitBake environment variable"""
497 var, value = params 499 var, value = params
498 data.setVar( var, value, cooker.configuration.data ) 500 data.setVar( var, value, cooker.configuration.data )
499 print "OK" 501 print("OK")
500 setVar.usage = "<variable> <value>" 502 setVar.usage = "<variable> <value>"
501 503
502 def rebuild( self, params ): 504 def rebuild( self, params ):
@@ -508,7 +510,7 @@ SRC_URI = ""
508 def shell( self, params ): 510 def shell( self, params ):
509 """Execute a shell command and dump the output""" 511 """Execute a shell command and dump the output"""
510 if params != "": 512 if params != "":
511 print commands.getoutput( " ".join( params ) ) 513 print(commands.getoutput( " ".join( params ) ))
512 shell.usage = "<...>" 514 shell.usage = "<...>"
513 515
514 def stage( self, params ): 516 def stage( self, params ):
@@ -518,17 +520,17 @@ SRC_URI = ""
518 520
519 def status( self, params ): 521 def status( self, params ):
520 """<just for testing>""" 522 """<just for testing>"""
521 print "-" * 78 523 print("-" * 78)
522 print "building list = '%s'" % cooker.building_list 524 print("building list = '%s'" % cooker.building_list)
523 print "build path = '%s'" % cooker.build_path 525 print("build path = '%s'" % cooker.build_path)
524 print "consider_msgs_cache = '%s'" % cooker.consider_msgs_cache 526 print("consider_msgs_cache = '%s'" % cooker.consider_msgs_cache)
525 print "build stats = '%s'" % cooker.stats 527 print("build stats = '%s'" % cooker.stats)
526 if last_exception is not None: print "last_exception = '%s'" % repr( last_exception.args ) 528 if last_exception is not None: print("last_exception = '%s'" % repr( last_exception.args ))
527 print "memory output contents = '%s'" % self._shell.myout._buffer 529 print("memory output contents = '%s'" % self._shell.myout._buffer)
528 530
529 def test( self, params ): 531 def test( self, params ):
530 """<just for testing>""" 532 """<just for testing>"""
531 print "testCommand called with '%s'" % params 533 print("testCommand called with '%s'" % params)
532 534
533 def unpack( self, params ): 535 def unpack( self, params ):
534 """Execute 'unpack' on a providee""" 536 """Execute 'unpack' on a providee"""
@@ -553,12 +555,12 @@ SRC_URI = ""
553 try: 555 try:
554 providers = cooker.status.providers[item] 556 providers = cooker.status.providers[item]
555 except KeyError: 557 except KeyError:
556 print "SHELL: ERROR: Nothing provides", preferred 558 print("SHELL: ERROR: Nothing provides", preferred)
557 else: 559 else:
558 for provider in providers: 560 for provider in providers:
559 if provider == pf: provider = " (***) %s" % provider 561 if provider == pf: provider = " (***) %s" % provider
560 else: provider = " %s" % provider 562 else: provider = " %s" % provider
561 print provider 563 print(provider)
562 which.usage = "<providee>" 564 which.usage = "<providee>"
563 565
564########################################################################## 566##########################################################################
@@ -583,7 +585,7 @@ def sendToPastebin( desc, content ):
583 mydata["nick"] = "%s@%s" % ( os.environ.get( "USER", "unknown" ), socket.gethostname() or "unknown" ) 585 mydata["nick"] = "%s@%s" % ( os.environ.get( "USER", "unknown" ), socket.gethostname() or "unknown" )
584 mydata["text"] = content 586 mydata["text"] = content
585 params = urllib.urlencode( mydata ) 587 params = urllib.urlencode( mydata )
586 headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"} 588 headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
587 589
588 host = "rafb.net" 590 host = "rafb.net"
589 conn = httplib.HTTPConnection( "%s:80" % host ) 591 conn = httplib.HTTPConnection( "%s:80" % host )
@@ -594,9 +596,9 @@ def sendToPastebin( desc, content ):
594 596
595 if response.status == 302: 597 if response.status == 302:
596 location = response.getheader( "location" ) or "unknown" 598 location = response.getheader( "location" ) or "unknown"
597 print "SHELL: Pasted to http://%s%s" % ( host, location ) 599 print("SHELL: Pasted to http://%s%s" % ( host, location ))
598 else: 600 else:
599 print "ERROR: %s %s" % ( response.status, response.reason ) 601 print("ERROR: %s %s" % ( response.status, response.reason ))
600 602
601def completer( text, state ): 603def completer( text, state ):
602 """Return a possible readline completion""" 604 """Return a possible readline completion"""
@@ -643,7 +645,7 @@ def columnize( alist, width = 80 ):
643 return reduce(lambda line, word, width=width: '%s%s%s' % 645 return reduce(lambda line, word, width=width: '%s%s%s' %
644 (line, 646 (line,
645 ' \n'[(len(line[line.rfind('\n')+1:]) 647 ' \n'[(len(line[line.rfind('\n')+1:])
646 + len(word.split('\n',1)[0] 648 + len(word.split('\n', 1)[0]
647 ) >= width)], 649 ) >= width)],
648 word), 650 word),
649 alist 651 alist
@@ -718,7 +720,7 @@ class BitBakeShell:
718 except IOError: 720 except IOError:
719 pass # It doesn't exist yet. 721 pass # It doesn't exist yet.
720 722
721 print __credits__ 723 print(__credits__)
722 724
723 def cleanup( self ): 725 def cleanup( self ):
724 """Write readline history and clean up resources""" 726 """Write readline history and clean up resources"""
@@ -726,7 +728,7 @@ class BitBakeShell:
726 try: 728 try:
727 readline.write_history_file( self.historyfilename ) 729 readline.write_history_file( self.historyfilename )
728 except: 730 except:
729 print "SHELL: Unable to save command history" 731 print("SHELL: Unable to save command history")
730 732
731 def registerCommand( self, command, function, numparams = 0, usage = "", helptext = "" ): 733 def registerCommand( self, command, function, numparams = 0, usage = "", helptext = "" ):
732 """Register a command""" 734 """Register a command"""
@@ -740,11 +742,11 @@ class BitBakeShell:
740 try: 742 try:
741 function, numparams, usage, helptext = cmds[command] 743 function, numparams, usage, helptext = cmds[command]
742 except KeyError: 744 except KeyError:
743 print "SHELL: ERROR: '%s' command is not a valid command." % command 745 print("SHELL: ERROR: '%s' command is not a valid command." % command)
744 self.myout.removeLast() 746 self.myout.removeLast()
745 else: 747 else:
746 if (numparams != -1) and (not len( params ) == numparams): 748 if (numparams != -1) and (not len( params ) == numparams):
747 print "Usage: '%s'" % usage 749 print("Usage: '%s'" % usage)
748 return 750 return
749 751
750 result = function( self.commands, params ) 752 result = function( self.commands, params )
@@ -759,7 +761,7 @@ class BitBakeShell:
759 if not cmdline: 761 if not cmdline:
760 continue 762 continue
761 if "|" in cmdline: 763 if "|" in cmdline:
762 print "ERROR: '|' in startup file is not allowed. Ignoring line" 764 print("ERROR: '|' in startup file is not allowed. Ignoring line")
763 continue 765 continue
764 self.commandQ.put( cmdline.strip() ) 766 self.commandQ.put( cmdline.strip() )
765 767
@@ -801,10 +803,10 @@ class BitBakeShell:
801 sys.stdout.write( pipe.fromchild.read() ) 803 sys.stdout.write( pipe.fromchild.read() )
802 # 804 #
803 except EOFError: 805 except EOFError:
804 print 806 print()
805 return 807 return
806 except KeyboardInterrupt: 808 except KeyboardInterrupt:
807 print 809 print()
808 810
809########################################################################## 811##########################################################################
810# Start function - called from the BitBake command line utility 812# Start function - called from the BitBake command line utility
@@ -819,4 +821,4 @@ def start( aCooker ):
819 bbshell.cleanup() 821 bbshell.cleanup()
820 822
821if __name__ == "__main__": 823if __name__ == "__main__":
822 print "SHELL: Sorry, this program should only be called by BitBake." 824 print("SHELL: Sorry, this program should only be called by BitBake.")