diff options
Diffstat (limited to 'bitbake/lib/bb/utils.py')
| -rw-r--r-- | bitbake/lib/bb/utils.py | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 7446be875d..02668b16c4 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
| @@ -72,9 +72,9 @@ def vercmp_part(a, b): | |||
| 72 | if ca == None and cb == None: | 72 | if ca == None and cb == None: |
| 73 | return 0 | 73 | return 0 |
| 74 | 74 | ||
| 75 | if type(ca) is types.StringType: | 75 | if isinstance(ca, types.StringType): |
| 76 | sa = ca in separators | 76 | sa = ca in separators |
| 77 | if type(cb) is types.StringType: | 77 | if isinstance(cb, types.StringType): |
| 78 | sb = cb in separators | 78 | sb = cb in separators |
| 79 | if sa and not sb: | 79 | if sa and not sb: |
| 80 | return -1 | 80 | return -1 |
| @@ -306,7 +306,7 @@ def better_compile(text, file, realfile, mode = "exec"): | |||
| 306 | """ | 306 | """ |
| 307 | try: | 307 | try: |
| 308 | return compile(text, file, mode) | 308 | return compile(text, file, mode) |
| 309 | except Exception, e: | 309 | except Exception as e: |
| 310 | # split the text into lines again | 310 | # split the text into lines again |
| 311 | body = text.split('\n') | 311 | body = text.split('\n') |
| 312 | bb.msg.error(bb.msg.domain.Util, "Error in compiling python function in: ", realfile) | 312 | bb.msg.error(bb.msg.domain.Util, "Error in compiling python function in: ", realfile) |
| @@ -385,7 +385,7 @@ def lockfile(name): | |||
| 385 | return lf | 385 | return lf |
| 386 | # File no longer exists or changed, retry | 386 | # File no longer exists or changed, retry |
| 387 | lf.close | 387 | lf.close |
| 388 | except Exception, e: | 388 | except Exception as e: |
| 389 | continue | 389 | continue |
| 390 | 390 | ||
| 391 | def unlockfile(lf): | 391 | def unlockfile(lf): |
| @@ -546,7 +546,7 @@ def mkdirhier(dir): | |||
| 546 | try: | 546 | try: |
| 547 | os.makedirs(dir) | 547 | os.makedirs(dir) |
| 548 | bb.msg.debug(2, bb.msg.domain.Util, "created " + dir) | 548 | bb.msg.debug(2, bb.msg.domain.Util, "created " + dir) |
| 549 | except OSError, e: | 549 | except OSError as e: |
| 550 | if e.errno != errno.EEXIST: | 550 | if e.errno != errno.EEXIST: |
| 551 | raise e | 551 | raise e |
| 552 | 552 | ||
| @@ -561,7 +561,7 @@ def movefile(src, dest, newmtime = None, sstat = None): | |||
| 561 | try: | 561 | try: |
| 562 | if not sstat: | 562 | if not sstat: |
| 563 | sstat = os.lstat(src) | 563 | sstat = os.lstat(src) |
| 564 | except Exception, e: | 564 | except Exception as e: |
| 565 | print("movefile: Stating source file failed...", e) | 565 | print("movefile: Stating source file failed...", e) |
| 566 | return None | 566 | return None |
| 567 | 567 | ||
| @@ -577,7 +577,7 @@ def movefile(src, dest, newmtime = None, sstat = None): | |||
| 577 | try: | 577 | try: |
| 578 | os.unlink(dest) | 578 | os.unlink(dest) |
| 579 | destexists = 0 | 579 | destexists = 0 |
| 580 | except Exception, e: | 580 | except Exception as e: |
| 581 | pass | 581 | pass |
| 582 | 582 | ||
| 583 | if stat.S_ISLNK(sstat[stat.ST_MODE]): | 583 | if stat.S_ISLNK(sstat[stat.ST_MODE]): |
| @@ -589,7 +589,7 @@ def movefile(src, dest, newmtime = None, sstat = None): | |||
| 589 | #os.lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID]) | 589 | #os.lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID]) |
| 590 | os.unlink(src) | 590 | os.unlink(src) |
| 591 | return os.lstat(dest) | 591 | return os.lstat(dest) |
| 592 | except Exception, e: | 592 | except Exception as e: |
| 593 | print("movefile: failed to properly create symlink:", dest, "->", target, e) | 593 | print("movefile: failed to properly create symlink:", dest, "->", target, e) |
| 594 | return None | 594 | return None |
| 595 | 595 | ||
| @@ -598,7 +598,7 @@ def movefile(src, dest, newmtime = None, sstat = None): | |||
| 598 | try: | 598 | try: |
| 599 | os.rename(src, dest) | 599 | os.rename(src, dest) |
| 600 | renamefailed = 0 | 600 | renamefailed = 0 |
| 601 | except Exception, e: | 601 | except Exception as e: |
| 602 | if e[0] != errno.EXDEV: | 602 | if e[0] != errno.EXDEV: |
| 603 | # Some random error. | 603 | # Some random error. |
| 604 | print("movefile: Failed to move", src, "to", dest, e) | 604 | print("movefile: Failed to move", src, "to", dest, e) |
| @@ -612,7 +612,7 @@ def movefile(src, dest, newmtime = None, sstat = None): | |||
| 612 | shutil.copyfile(src, dest + "#new") | 612 | shutil.copyfile(src, dest + "#new") |
| 613 | os.rename(dest + "#new", dest) | 613 | os.rename(dest + "#new", dest) |
| 614 | didcopy = 1 | 614 | didcopy = 1 |
| 615 | except Exception, e: | 615 | except Exception as e: |
| 616 | print('movefile: copy', src, '->', dest, 'failed.', e) | 616 | print('movefile: copy', src, '->', dest, 'failed.', e) |
| 617 | return None | 617 | return None |
| 618 | else: | 618 | else: |
| @@ -626,7 +626,7 @@ def movefile(src, dest, newmtime = None, sstat = None): | |||
| 626 | os.lchown(dest, sstat[stat.ST_UID], sstat[stat.ST_GID]) | 626 | os.lchown(dest, sstat[stat.ST_UID], sstat[stat.ST_GID]) |
| 627 | os.chmod(dest, stat.S_IMODE(sstat[stat.ST_MODE])) # Sticky is reset on chown | 627 | os.chmod(dest, stat.S_IMODE(sstat[stat.ST_MODE])) # Sticky is reset on chown |
| 628 | os.unlink(src) | 628 | os.unlink(src) |
| 629 | except Exception, e: | 629 | except Exception as e: |
| 630 | print("movefile: Failed to chown/chmod/unlink", dest, e) | 630 | print("movefile: Failed to chown/chmod/unlink", dest, e) |
| 631 | return None | 631 | return None |
| 632 | 632 | ||
| @@ -647,7 +647,7 @@ def copyfile(src, dest, newmtime = None, sstat = None): | |||
| 647 | try: | 647 | try: |
| 648 | if not sstat: | 648 | if not sstat: |
| 649 | sstat = os.lstat(src) | 649 | sstat = os.lstat(src) |
| 650 | except Exception, e: | 650 | except Exception as e: |
| 651 | print("copyfile: Stating source file failed...", e) | 651 | print("copyfile: Stating source file failed...", e) |
| 652 | return False | 652 | return False |
| 653 | 653 | ||
| @@ -663,7 +663,7 @@ def copyfile(src, dest, newmtime = None, sstat = None): | |||
| 663 | try: | 663 | try: |
| 664 | os.unlink(dest) | 664 | os.unlink(dest) |
| 665 | destexists = 0 | 665 | destexists = 0 |
| 666 | except Exception, e: | 666 | except Exception as e: |
| 667 | pass | 667 | pass |
| 668 | 668 | ||
| 669 | if stat.S_ISLNK(sstat[stat.ST_MODE]): | 669 | if stat.S_ISLNK(sstat[stat.ST_MODE]): |
| @@ -674,7 +674,7 @@ def copyfile(src, dest, newmtime = None, sstat = None): | |||
| 674 | os.symlink(target, dest) | 674 | os.symlink(target, dest) |
| 675 | #os.lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID]) | 675 | #os.lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID]) |
| 676 | return os.lstat(dest) | 676 | return os.lstat(dest) |
| 677 | except Exception, e: | 677 | except Exception as e: |
| 678 | print("copyfile: failed to properly create symlink:", dest, "->", target, e) | 678 | print("copyfile: failed to properly create symlink:", dest, "->", target, e) |
| 679 | return False | 679 | return False |
| 680 | 680 | ||
| @@ -682,7 +682,7 @@ def copyfile(src, dest, newmtime = None, sstat = None): | |||
| 682 | try: # For safety copy then move it over. | 682 | try: # For safety copy then move it over. |
| 683 | shutil.copyfile(src, dest + "#new") | 683 | shutil.copyfile(src, dest + "#new") |
| 684 | os.rename(dest + "#new", dest) | 684 | os.rename(dest + "#new", dest) |
| 685 | except Exception, e: | 685 | except Exception as e: |
| 686 | print('copyfile: copy', src, '->', dest, 'failed.', e) | 686 | print('copyfile: copy', src, '->', dest, 'failed.', e) |
| 687 | return False | 687 | return False |
| 688 | else: | 688 | else: |
| @@ -694,7 +694,7 @@ def copyfile(src, dest, newmtime = None, sstat = None): | |||
| 694 | try: | 694 | try: |
| 695 | os.lchown(dest, sstat[stat.ST_UID], sstat[stat.ST_GID]) | 695 | os.lchown(dest, sstat[stat.ST_UID], sstat[stat.ST_GID]) |
| 696 | os.chmod(dest, stat.S_IMODE(sstat[stat.ST_MODE])) # Sticky is reset on chown | 696 | os.chmod(dest, stat.S_IMODE(sstat[stat.ST_MODE])) # Sticky is reset on chown |
| 697 | except Exception, e: | 697 | except Exception as e: |
| 698 | print("copyfile: Failed to chown/chmod/unlink", dest, e) | 698 | print("copyfile: Failed to chown/chmod/unlink", dest, e) |
| 699 | return False | 699 | return False |
| 700 | 700 | ||
