Changeset b0fa2ae in rtems-tools for rtemstoolkit


Ignore:
Timestamp:
Mar 3, 2016, 5:46:18 AM (4 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.10, master
Children:
a5d243d
Parents:
0e5d89d
git-author:
Chris Johns <chrisj@…> (03/03/16 05:46:18)
git-committer:
Chris Johns <chrisj@…> (03/03/16 05:53:39)
Message:

Update rtems-tool to support Python 2 and 3.

Add solaris and netbsd.

Close #2619.

Location:
rtemstoolkit
Files:
2 added
16 edited

Legend:

Unmodified
Added
Removed
  • rtemstoolkit/__init__.py

    r0e5d89d rb0fa2ae  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    3838       'mailer',
    3939       'options',
    40        'path']
     40       'path',
     41       'version']
     42
     43from . import check
     44from . import config
     45from . import error
     46from . import execute
     47from . import git
     48from . import log
     49from . import macros
     50from . import mailer
     51from . import options
     52from . import path
     53from . import version
  • rtemstoolkit/check.py

    r0e5d89d rb0fa2ae  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    3333#
    3434
     35from __future__ import print_function
     36
    3537import os
    3638
    37 import error
    38 import execute
    39 import log
    40 import options
    41 import path
    42 import version
     39#
     40# Support to handle use in a package and as a unit test.
     41# If there is a better way to let us know.
     42#
     43try:
     44    from . import error
     45    from . import execute
     46    from . import log
     47    from . import options
     48    from . import path
     49    from . import version
     50except (ValueError, SystemError):
     51    import error
     52    import execute
     53    import log
     54    import options
     55    import path
     56    import version
    4357
    4458def _check_none(_opts, macro, value, constraint):
     
    118132    sane = True
    119133
    120     for d in opts.defaults.keys():
     134    for d in list(opts.defaults.keys()):
    121135        try:
    122136            (test, constraint, value) = opts.defaults.get(d)
     
    153167    import sys
    154168    try:
    155         _opts = options.load(args = sys.argv)
     169        _opts = options.command_line(argv = sys.argv)
     170        options.load(_opts)
    156171        log.notice('RTEMS Source Builder - Check, v%s' % (version.str()))
    157172        if host_setup(_opts):
  • rtemstoolkit/config.py

    r0e5d89d rb0fa2ae  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    3737#
    3838
     39from __future__ import print_function
     40
    3941import copy
     42import functools
    4043import os
    4144import re
    4245import sys
    4346
    44 import error
    45 import execute
    46 import log
    47 import options
    48 import path
    49 
    5047try:
    51     import error
    52     import execute
    53     import log
    54     import options
    55     import path
    56 except KeyboardInterrupt:
    57     print('user terminated')
    58     sys.exit(1)
    59 except:
    60     print('error: unknown application load error')
    61     sys.exit(1)
     48    from . import error
     49    from . import execute
     50    from . import log
     51    from . import options
     52    from . import path
     53except (ValueError, SystemError):
     54     import error
     55     import execute
     56     import log
     57     import options
     58     import path
    6259
    6360def _check_bool(value):
     
    9794        self._includes = []
    9895        self.load_depth = 0
     96        self.lc = 0
     97        self.name = 'none'
    9998
    10099    def __del__(self):
     
    105104        def _dict(dd):
    106105            s = ''
    107             ddl = dd.keys()
     106            ddl = list(dd.keys())
    108107            ddl.sort()
    109108            for d in ddl:
     
    439438                    istrue = _check_bool(ifls[0])
    440439                    if istrue == None:
    441                         self._error('invalid if bool value: ' + reduce(add, ls, ''))
     440                        self._error('invalid if bool value: ' + functools.reduce(add, ls, ''))
    442441                        istrue = False
    443442            elif len(ifls) == 2:
     
    445444                    istrue = _check_bool(ifls[1])
    446445                    if istrue == None:
    447                         self._error('invalid if bool value: ' + reduce(add, ls, ''))
     446                        self._error('invalid if bool value: ' + functools.reduce(add, ls, ''))
    448447                        istrue = False
    449448                    else:
     
    461460                        istrue = True
    462461                    else:
    463                         self._error('invalid if bool operator: ' + reduce(add, ls, ''))
     462                        self._error('invalid if bool operator: ' + functools.reduce(add, ls, ''))
    464463            elif len(ifls) == 3:
    465464                if ifls[1] == '==':
     
    494493                        istrue = False
    495494                else:
    496                     self._error('invalid %if operator: ' + reduce(add, ls, ''))
    497             else:
    498                 self._error('malformed if: ' + reduce(add, ls, ''))
     495                    self._error('invalid %if operator: ' + functools.reduce(add, ls, ''))
     496            else:
     497                self._error('malformed if: ' + functools.reduce(add, ls, ''))
    499498            if invert:
    500499                istrue = not istrue
     
    843842        # Run where defaults.mc is located
    844843        #
    845         opts = options.load(sys.argv, defaults = 'defaults.mc')
    846         log.trace('config: count %d' % (len(opts.config_files())))
    847         for config_file in opts.config_files():
    848             s = file(config_file, opts)
    849             print(s)
    850             del s
     844        long_opts = {
     845            # key              macro        handler   param  defs   init
     846            '--file'  :      ('_file',      'path',   True,  None,  False)
     847        }
     848        opts = options.command_line(base_path = '.',
     849                                    argv = sys.argv,
     850                                    long_opts = long_opts)
     851        options.load(opts)
     852        if '_file' not in opts.defaults:
     853            raise error.general('no --file option provided')
     854        s = file(opts.defaults['_file'], opts)
     855        s.load(opts.defaults['_file'])
     856        print(s)
     857        del s
    851858    except error.general as gerr:
    852859        print(gerr)
  • rtemstoolkit/darwin.py

    r0e5d89d rb0fa2ae  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    3636import os
    3737
    38 import execute
     38#
     39# Support to handle use in a package and as a unit test.
     40# If there is a better way to let us know.
     41#
     42try:
     43    from . import execute
     44except (ValueError, SystemError):
     45    import execute
    3946
    4047def load():
  • rtemstoolkit/error.py

    r0e5d89d rb0fa2ae  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    3232# Various errors we can raise.
    3333#
     34
     35from __future__ import print_function
    3436
    3537class error(Exception):
  • rtemstoolkit/execute.py

    r0e5d89d rb0fa2ae  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    3535#
    3636
     37from __future__ import print_function
     38
     39import functools
    3740import os
    3841import re
     
    4245import time
    4346
    44 import error
    45 import log
     47#
     48# Support to handle use in a package and as a unit test.
     49# If there is a better way to let us know.
     50#
     51try:
     52    from . import error
     53    from . import log
     54except (ValueError, SystemError):
     55    import error
     56    import log
    4657
    4758# Trace exceptions
     
    97108    cmd = arg_subst(command, subst)
    98109    def add(x, y): return x + ' ' + str(y)
    99     return reduce(add, cmd, '')
     110    return functools.reduce(add, cmd, '')
    100111
    101112class execute(object):
     
    119130        self.proc = None
    120131
    121     def _capture(self, command, proc, timeout = None):
     132    def capture(self, proc, command = 'pipe', timeout = None):
    122133        """Create 3 threads to read stdout and stderr and send to the output handler
    123134        and call an input handler is provided. Based on the 'communicate' code
     
    129140            if trace_threads:
    130141                print('executte:_writethread: start')
     142            encoding = True
     143            try:
     144                tmp = bytes('temp', sys.stdin.encoding)
     145            except:
     146                encoding = False
    131147            try:
    132148                while True:
    133                     lines = input()
    134                     if type(lines) == str:
     149                    lines = eval(input())
     150                    if type(lines) == str or type(lines) == bytes:
    135151                        try:
     152                            if encoding:
     153                                lines = bytes(lines, sys.stdin.encoding)
    136154                            fh.write(lines)
    137155                        except:
     
    156174            until the file closes."""
    157175            def _output_line(line, exe, prefix, out, count):
    158                 #print 'LINE:%d: %s' % (count, line)
    159                 exe.lock.acquire()
     176                #exe.lock.acquire()
    160177                #exe.outputting = True
    161                 exe.lock.release()
     178                #exe.lock.release()
    162179                if out:
    163180                    out(prefix + line)
     
    176193                    if len(data) == 0:
    177194                        break
    178                     #print '))))) %02x "%s"' % (ord(data), data)
     195                    if type(data) == bytes:
     196                        data = data.decode(sys.stdout.encoding)
    179197                    for c in data:
    180198                        line += c
     
    306324            if type(command) is list:
    307325                def add(x, y): return x + ' ' + str(y)
    308                 s = reduce(add, command, '')[1:]
     326                s = functools.reduce(add, command, '')[1:]
    309327            what = 'spawn'
    310328            if shell:
    311329                what = 'shell'
    312330            log.output(what + ': ' + s)
     331        if self.output is None:
     332            raise error.general('capture needs an output handler')
    313333        if shell and self.shell_exe:
    314334            command = arg_list(command)
     
    343363            if self.output is None:
    344364                raise error.general('capture needs an output handler')
    345             exit_code = self._capture(command, proc, timeout)
     365            exit_code = self.capture(proc, command, timeout)
    346366            if self.verbose:
    347367                log.output('exit: ' + str(exit_code))
     
    396416                            cwd = cwd, env = env,
    397417                            stdin = stdin, stdout = stdout, stderr = stderr,
    398                             itmeout = timeout)
     418                            timeout = timeout)
    399419
    400420    def set_shell(self, execute):
     
    520540            print('piping input into ' + commands['pipe'][0] + ': ' + \
    521541                  commands['pipe'][2])
    522             proc.stdin.write(commands['pipe'][2])
     542            try:
     543                out = bytes(commands['pipe'][2], sys.stdin.encoding)
     544            except:
     545                out = commands['pipe'][2]
     546            proc.stdin.write(out)
    523547            proc.stdin.close()
    524548            e.capture(proc)
    525549            del proc
     550
     551    def capture_output(text):
     552        print(text, end = '')
    526553
    527554    cmd_shell_test = 'if "%OS%" == "Windows_NT" (echo It is WinNT) else echo Is is not WinNT'
     
    550577                    ['subst0', 'subst1', 'subst2']))
    551578
    552     e = execute(error_prefix = 'ERR: ', verbose = True)
     579    e = execute(error_prefix = 'ERR: ', output = capture_output, verbose = True)
    553580    if sys.platform == "win32":
    554581        run_tests(e, commands['windows'], False)
  • rtemstoolkit/freebsd.py

    r0e5d89d rb0fa2ae  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    3737import os
    3838
    39 import check
    40 import execute
     39#
     40# Support to handle use in a package and as a unit test.
     41# If there is a better way to let us know.
     42#
     43try:
     44    from . import check
     45    from . import execute
     46except (ValueError, SystemError):
     47    import check
     48    import execute
    4149
    4250def load():
  • rtemstoolkit/git.py

    r0e5d89d rb0fa2ae  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2015 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    3232import os
    3333
    34 import error
    35 import execute
    36 import log
    37 import options
    38 import path
     34#
     35# Support to handle use in a package and as a unit test.
     36# If there is a better way to let us know.
     37#
     38try:
     39    from . import error
     40    from . import execute
     41    from . import log
     42    from . import path
     43except (ValueError, SystemError):
     44    import error
     45    import execute
     46    import log
     47    import path
    3948
    4049class repo:
    4150    """An object to manage a git repo."""
    4251
    43     def _git_exit_code(self, ec):
     52    def _git_exit_code(self, ec, cmd, output):
    4453        if ec:
     54            log.notice('git: cmd: ' + ' '.join(cmd))
     55            log.notice('git: output: ' + output)
    4556            raise error.general('git command failed (%s): %d' % (self.git, ec))
    4657
     
    5667        log.trace(output)
    5768        if check:
    58             self._git_exit_code(exit_code)
     69            self._git_exit_code(exit_code, cmd, output)
    5970        return exit_code, output
    6071
     
    7788            raise error.general('invalid version string from git: %s' % (output))
    7889        vs = gvs[2].split('.')
    79         if len(vs) != 4:
    80             raise error.general('invalid version number from git: %s' % (gvs[2]))
    81         return (int(vs[0]), int(vs[1]), int(vs[2]), int(vs[3]))
     90        if len(vs) == 4:
     91            return (int(vs[0]), int(vs[1]), int(vs[2]), int(vs[3]))
     92        if len(vs) == 3:
     93            return (int(vs[0]), int(vs[1]), int(vs[2]))
     94        raise error.general('invalid version number from git: %s' % (gvs[2]))
    8295
    8396    def clone(self, url, _path):
     
    208221if __name__ == '__main__':
    209222    import sys
    210     opts = options.load(sys.argv)
     223    import options
     224    long_opts = {
     225       # key              macro        handler   param  defs   init
     226    }
     227    opts = options.command_line(base_path = '.',
     228                                argv = sys.argv,
     229                                long_opts = long_opts)
     230    options.load(opts)
    211231    g = repo('.', opts)
    212     print(g.git_version())
    213     print(g.valid())
    214     print(g.status())
    215     print(g.clean())
    216     print(g.remotes())
    217     print(g.email())
    218     print(g.head())
     232    print('version:', g.git_version())
     233    print('valid:', g.valid())
     234    print('status:', g.status())
     235    print('dirty:', g.dirty())
     236    print('remotes:', g.remotes())
     237    print('email:', g.email())
     238    print('head:', g.head())
  • rtemstoolkit/linux.py

    r0e5d89d rb0fa2ae  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    3636import pprint
    3737import os
     38import platform
    3839
    39 import platform
    40 import execute
    41 import path
     40#
     41# Support to handle use in a package and as a unit test.
     42# If there is a better way to let us know.
     43#
     44try:
     45    from . import execute
     46    from . import path
     47except (ValueError, SystemError):
     48    import execute
     49    import path
    4250
    4351def load():
     
    131139        }
    132140
    133     if variations.has_key(distro):
     141    if distro in variations:
    134142        for v in variations[distro]:
    135143            if path.exists(variations[distro][v][2]):
  • rtemstoolkit/log.py

    r0e5d89d rb0fa2ae  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    3333#
    3434
     35from __future__ import print_function
     36
    3537import os
    3638import sys
    3739import threading
    3840
    39 import error
     41#
     42# Support to handle use in a package and as a unit test.
     43# If there is a better way to let us know.
     44#
     45try:
     46    from . import error
     47except (ValueError, SystemError):
     48    import error
    4049
    4150#
     
    127136                else:
    128137                    try:
    129                         self.fhs.append(file(s, 'w'))
     138                        self.fhs.append(open(s, 'w'))
    130139                    except IOError as ioe:
    131140                         raise error.general("creating log file '" + s + \
  • rtemstoolkit/macros.py

    r0e5d89d rb0fa2ae  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    3333#
    3434
     35from __future__ import print_function
     36
    3537import copy
    3638import inspect
     
    3941import string
    4042
    41 import error
    42 import path
     43#
     44# Support to handle use in a package and as a unit test.
     45# If there is a better way to let us know.
     46#
     47try:
     48    from . import error
     49    from . import path
     50except (ValueError, SystemError):
     51    import error
     52    import path
    4353
    4454#
     
    5565            return self
    5666
    57         def next(self):
     67        def __next__(self):
    5868            if self.index < len(self.keys):
    5969                key = self.keys[self.index]
     
    6474        def iterkeys(self):
    6575            return self.keys
     76
     77    def _unicode_to_str(self, us):
     78        try:
     79            if type(us) == unicode:
     80                return us.encode('ascii', 'replace')
     81        except:
     82            pass
     83        try:
     84            if type(us) == bytes:
     85                return us.encode('ascii', 'replace')
     86        except:
     87            pass
     88        return us
    6689
    6790    def __init__(self, name = None, original = None, rtdir = '.'):
     
    168191        if type(key) is not str:
    169192            raise TypeError('bad key type (want str): %s' % (type(key)))
     193        if type(value) is not tuple:
     194            value = self._unicode_to_str(value)
    170195        if type(value) is str:
    171196            value = ('none', 'none', value)
     
    174199        if len(value) != 3:
    175200            raise TypeError('bad value tuple (len not 3): %d' % (len(value)))
     201        value = (self._unicode_to_str(value[0]),
     202                 self._unicode_to_str(value[1]),
     203                 self._unicode_to_str(value[2]))
    176204        if type(value[0]) is not str:
    177205            raise TypeError('bad value tuple type field: %s' % (type(value[0])))
     
    196224
    197225    def __len__(self):
    198         return len(self.keys())
     226        return len(list(self.keys()))
    199227
    200228    def keys(self):
    201         keys = self.macros['global'].keys()
     229        keys = list(self.macros['global'].keys())
    202230        for rm in self.get_read_maps():
    203231            for mk in self.macros[rm]:
     
    212240        if type(key) is not str:
    213241            raise TypeError('bad key type (want str): %s' % (type(key)))
    214         if self.key_filter(key) not in self.keys():
     242        if self.key_filter(key) not in list(self.keys()):
    215243            return False
    216244        return True
     
    492520    import sys
    493521    print(inspect.getfile(macros))
    494     m = macros(name = 'defaults.mc')
     522    m = macros()
    495523    d = copy.copy(m)
    496524    m['test1'] = 'something'
  • rtemstoolkit/mailer.py

    r0e5d89d rb0fa2ae  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2013-2014 Chris Johns (chrisj@rtems.org)
     3# Copyright 2013-2016 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    3333#
    3434
     35from __future__ import print_function
     36
    3537import os
    3638import smtplib
    3739import socket
    3840
    39 import error
    40 import options
    41 import path
     41#
     42# Support to handle use in a package and as a unit test.
     43# If there is a better way to let us know.
     44#
     45try:
     46    from . import error
     47    from . import options
     48    from . import path
     49except (ValueError, SystemError):
     50    import error
     51    import options
     52    import path
    4253
    4354def append_options(opts):
  • rtemstoolkit/options.py

    r0e5d89d rb0fa2ae  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    3333#
    3434
     35from __future__ import print_function
     36
    3537import copy
    3638import glob
     
    3941import os
    4042import string
    41 
    42 import error
    43 import execute
    44 import git
    45 import log
    46 import macros
    47 import path
    4843import sys
    4944
    50 import version
     45#
     46# Support to handle use in a package and as a unit test.
     47# If there is a better way to let us know.
     48#
     49try:
     50    from . import error
     51    from . import execute
     52    from . import git
     53    from . import log
     54    from . import macros
     55    from . import path
     56    from . import version
     57except (ValueError, SystemError):
     58    import error
     59    import execute
     60    import git
     61    import log
     62    import macros
     63    import path
     64    import version
    5165
    5266basepath = 'tb'
     
    6276    def __init__(self, base_path = None, argv = None, optargs = None,
    6377                 defaults = None, long_opts = None, long_opts_help = None,
    64                  command_path = None, log_default = None):
     78                 command_path = '', log_default = None):
    6579
    6680        if argv is None:
     
    7084
    7185        if long_opts == None:
    72             raise error.general('No options provided')
     86            long_opts = {}
    7387
    7488        basepath = base_path
     
    7791            raise error.general('log default is a list')
    7892        self.log_default = log_default
     93
     94        if defaults is None:
     95            defaults = macros.macros()
    7996
    8097        self.long_opts = {
     
    129146                handler = self._lo_string
    130147            elif long_opts[lo][1] == 'path':
    131                 hanlder = self._lo_path
     148                handler = self._lo_path
    132149            elif long_opts[lo][1] == 'jobs':
    133150                handler = self._lo_jobs
     
    140157            self.long_opts[lo] = (long_opts[lo][0], handler, long_opts[lo][2],
    141158                                   long_opts[lo][3], long_opts[lo][4])
    142             if lo not in long_opts_help:
    143                 raise error.general('no help for option: %s' % (lo))
    144             self.long_opts_help[lo] = long_opts_help[lo]
     159            if long_opts_help is not None:
     160                if lo not in long_opts_help:
     161                    raise error.general('no help for option: %s' % (lo))
     162                self.long_opts_help[lo] = long_opts_help[lo]
    145163
    146164    def __copy__(self):
     
    160178        def _dict(dd):
    161179            s = ''
    162             ddl = dd.keys()
     180            ddl = list(dd.keys())
    163181            ddl.sort()
    164182            for d in ddl:
     
    277295        print('RTEMS Tools Project (c) 2012-2015 Chris Johns')
    278296        print('Options and arguments:')
    279         opts = self.long_opts_help.keys()
     297        opts = list(self.long_opts_help.keys())
    280298        if self.optargs:
    281299            opts += self.optargs.keys()
     
    519537    """
    520538
     539    if not isinstance(opts, command_line):
     540        raise error.general('invalid options type passed to options loader')
     541
    521542    global host_windows
    522543
     
    533554        try:
    534555            if uname[0].startswith('CYGWIN_NT'):
    535                 import windows
     556                try:
     557                    from . import windows
     558                except:
     559                    import windows
    536560                overrides = windows.load()
    537561            elif uname[0] == 'Darwin':
    538                 import darwin
     562                try:
     563                    from . import darwin
     564                except:
     565                    import darwin
    539566                overrides = darwin.load()
    540567            elif uname[0] == 'FreeBSD':
    541                 import freebsd
     568                try:
     569                    from . import freebsd
     570                except:
     571                    import freebsd
    542572                overrides = freebsd.load()
    543573            elif uname[0] == 'NetBSD':
    544                 import netbsd
     574                try:
     575                    from . import netbsd
     576                except:
     577                    import netbsd
    545578                overrides = netbsd.load()
    546579            elif uname[0] == 'Linux':
    547                 import linux
     580                try:
     581                    from . import linux
     582                except:
     583                    import linux
    548584                overrides = linux.load()
     585            elif uname[0] == 'SunOS':
     586                try:
     587                    from . import solaris
     588                except:
     589                    import solaris
     590                overrides = solaris.load()
    549591        except:
    550592            raise error.general('failed to load %s host support' % (uname[0]))
  • rtemstoolkit/path.py

    r0e5d89d rb0fa2ae  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    3535#
    3636
     37from __future__ import print_function
     38
    3739import glob
    3840import os
     
    4042import string
    4143
    42 import error
    43 import log
     44#
     45# Support to handle use in a package and as a unit test.
     46# If there is a better way to let us know.
     47#
     48try:
     49    from . import error
     50    from . import log
     51except (ValueError, SystemError):
     52    import error
     53    import log
    4454
    4555windows = os.name == 'nt'
  • rtemstoolkit/version.py

    r0e5d89d rb0fa2ae  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2015 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    3434#
    3535
     36from __future__ import print_function
     37
    3638import sys
    3739
    38 import error
    39 import path
     40#
     41# Support to handle use in a package and as a unit test.
     42# If there is a better way to let us know.
     43#
     44try:
     45    from . import error
     46    from . import git
     47    from . import path
     48except (ValueError, SystemError):
     49    import error
     50    import git
     51    import path
    4052
    4153#
     
    6880
    6981def _load_git_version():
    70     import git
    7182    global _git
    7283    global _version_str
  • rtemstoolkit/windows.py

    r0e5d89d rb0fa2ae  
    11#
    22# RTEMS Tools Project (http://www.rtems.org/)
    3 # Copyright 2010-2014 Chris Johns (chrisj@rtems.org)
     3# Copyright 2010-2016 Chris Johns (chrisj@rtems.org)
    44# All rights reserved.
    55#
     
    3333#
    3434
    35 import error
    3635import pprint
    3736import os
    3837
    39 import execute
     38#
     39# Support to handle use in a package and as a unit test.
     40# If there is a better way to let us know.
     41#
     42try:
     43    from . import error
     44    from . import execute
     45except (ValueError, SystemError):
     46    import error
     47    import execute
    4048
    4149def load():
Note: See TracChangeset for help on using the changeset viewer.