def anydiff(a, b, flags): # Display differences between any two objects print 'diff', flags, a, b if path.isdir(a) and path.isdir(b): w = dirdiff(a, b, flags) else: w = filediff(a, b, flags) addstatmenu(w, [a, b]) w.original_close = w.close w.close = close_dirwin return w
def gdiff_ab(w, m, item): # Call SGI's gdiff utility x = getselection(w) if x: a, b = path.cat(w.a, x), path.cat(w.b, x) if path.isdir(a) or path.isdir(b): stdwin.fleep() # This is for files only else: diffcmd = 'gdiff' diffcmd = diffcmd + mkarg(a) + mkarg(b) + ' &' print diffcmd sts = posix.system(diffcmd) if sts: print 'Exit status', sts
def open(name): print 'opening', name, '...' if path.isdir(name): w = dirwin.open(name) else: w = filewin.open(name) return w
def get_file(url, local, opts, config): if local is None: raise error.general("source/patch path invalid") if not path.isdir(path.dirname(local)) and not opts.download_disabled(): log.notice("Creating source directory: %s" % (os.path.relpath(path.host(path.dirname(local))))) log.output("making dir: %s" % (path.host(path.dirname(local)))) if not opts.dry_run(): path.mkdir(path.dirname(local)) if not path.exists(local) and opts.download_disabled(): raise error.general("source not found: %s" % (path.host(local))) # # Check if a URL has been provided on the command line. # url_bases = opts.urls() urls = [] if url_bases is not None: for base in url_bases: if base[-1:] != "/": base += "/" url_path = urlparse.urlsplit(url)[2] slash = url_path.rfind("/") if slash < 0: url_file = url_path else: url_file = url_path[slash + 1 :] urls.append(urlparse.urljoin(base, url_file)) urls += url.split() log.trace("_url: %s -> %s" % (",".join(urls), local)) for url in urls: for dl in downloaders: if url.startswith(dl): if downloaders[dl](url, local, config, opts): return if not opts.dry_run(): raise error.general("downloading %s: all paths have failed, giving up" % (url))
def openlistwindow(dirname): list = posix.listdir(dirname) list.sort() i = 0 while i < len(list): if list[i] == '.' or list[i] == '..': del list[i] else: i = i+1 for i in range(len(list)): name = list[i] if path.isdir(path.join(dirname, name)): list[i] = list[i] + '/' width = maxwidth(list) width = width + stdwin.textwidth(' ') # XXX X11 stdwin bug workaround height = len(list) * stdwin.lineheight() stdwin.setdefwinsize(width, min(height, 500)) w = stdwin.open(dirname) stdwin.setdefwinsize(0, 0) w.setdocsize(width, height) w.drawproc = drawlistwindow w.mouse = mouselistwindow w.close = closelistwindow w.dirname = dirname w.list = list w.selected = -1 return w
def open(name): print "opening", name, "..." if path.isdir(name): w = dirwin.open(name) else: w = filewin.open(name) return w
def path_check(opts, silent=False): if 'PATH' in os.environ: paths = os.environ['PATH'].split(os.pathsep) for p in paths: try: if len(p.strip()) == 0: if not silent: log.notice( 'error: environment PATH contains an empty path') return False elif not options.host_windows and (p.strip() == '.' or p.strip() == '..'): if not silent: log.notice('error: environment PATH invalid path: %s' % (p)) return False elif not path.exists(p): if not silent and opts.warn_all(): log.notice('warning: environment PATH not found: %s' % (p)) elif not path.isdir(p): if not silent and opts.warn_all(): log.notice( 'warning: environment PATH not a directory: %s' % (p)) except Exception as e: if not silent: log.notice( 'warning: environment PATH suspicious path: %s' % (e)) return True
def _check_dir(_opts, macro, value, constraint, silent = False): if constraint != 'none' and not path.isdir(value): if constraint == 'required': if not silent: log.notice('error: dir: not found: (%s) %s' % (macro, value)) return False if not silent and _opts.warn_all(): log.notice('warning: dir: not found: (%s) %s' % (macro, value)) return True
def _check_dir(_opts, macro, value, constraint, silent=False): if constraint != 'none' and not path.isdir(value): if constraint == 'required': if not silent: log.notice('error: dir: not found: (%s) %s' % (macro, value)) return False if not silent and _opts.warn_all(): log.notice('warning: dir: not found: (%s) %s' % (macro, value)) return True
def get_file(url, local, opts, config): if local is None: raise error.general('source/patch path invalid') if not path.isdir(path.dirname(local)) and not opts.download_disabled(): log.notice('Creating source directory: %s' % \ (os.path.relpath(path.host(path.dirname(local))))) log.output('making dir: %s' % (path.host(path.dirname(local)))) if _do_download(opts): path.mkdir(path.dirname(local)) if not path.exists(local) and opts.download_disabled(): raise error.general('source not found: %s' % (path.host(local))) # # Check if a URL has been provided on the command line. If the package is # release push to the start the RTEMS URL. # url_bases = opts.urls() if version.released(): rtems_release_url = config.macros.expand('%{rtems_release_url}/%{rsb_version}/sources') log.trace('release url: %s' % (rtems_release_url)) # # If the URL being fetched is under the release path do not add the # sources release path because it is already there. # if not url.startswith(rtems_release_url): if url_bases is None: url_bases = [rtems_release_url] else: url_bases.append(rtems_release_url) urls = [] if url_bases is not None: # # Split up the URL we are being asked to download. # url_path = urlparse.urlsplit(url)[2] slash = url_path.rfind('/') if slash < 0: url_file = url_path else: url_file = url_path[slash + 1:] log.trace('url_file: %s' %(url_file)) for base in url_bases: if base[-1:] != '/': base += '/' next_url = urlparse.urljoin(base, url_file) log.trace('url: %s' %(next_url)) urls.append(next_url) urls += url.split() log.trace('_url: %s -> %s' % (','.join(urls), local)) for url in urls: for dl in downloaders: if url.startswith(dl): if downloaders[dl](url, local, config, opts): return if _do_download(opts): raise error.general('downloading %s: all paths have failed, giving up' % (url))
def rm_b(w, m, item): x = getselection(w) if x: if x[-1:] = '/': x = x[:-1] x = path.cat(w.b, x) if path.isdir(x): if askyesno('Recursively remove B directory ' + x, 1): runcmd('rm -rf' + mkarg(x)) else: runcmd('rm -f' + mkarg(x)) update(w)
def skipfile(file): if file in badnames or \ badprefix(file) or badsuffix(file) or \ path.islink(file) or path.isdir(file): return 1 # Skip huge files -- probably binaries. try: st = posix.stat(file) except posix.error: return 1 # Doesn't exist -- skip it return st[stat.ST_SIZE] >= MAXSIZE
def zipUpDir(self, myzip, tdir, localname): currentdir = tdir if localname != "": currentdir = os.path.join(currentdir,localname) list = path.listdir(currentdir) for file in list: afilename = file localfilePath = os.path.join(localname, afilename) realfilePath = os.path.join(currentdir,file) if path.isfile(realfilePath): myzip.write(pathof(realfilePath), pathof(localfilePath), zipfile.ZIP_DEFLATED) elif path.isdir(realfilePath): self.zipUpDir(myzip, tdir, localfilePath)
def zipUpDir(self, myzip, tdir, localname): currentdir = tdir if localname != "": currentdir = os.path.join(currentdir, localname) list = path.listdir(currentdir) for file in list: afilename = file localfilePath = os.path.join(localname, afilename) realfilePath = os.path.join(currentdir, file) if path.isfile(realfilePath): myzip.write(pathof(realfilePath), pathof(localfilePath), zipfile.ZIP_DEFLATED) elif path.isdir(realfilePath): self.zipUpDir(myzip, tdir, localfilePath)
def diffdata(a, b, flags): # Compute directory differences. # a_only = [('A only:', header_action), ('', header_action)] b_only = [('B only:', header_action), ('', header_action)] ab_diff = [('A <> B:', header_action), ('', header_action)] ab_same = [('A == B:', header_action), ('', header_action)] data = [a_only, b_only, ab_diff, ab_same] # a_list = dircache.listdir(a)[:] b_list = dircache.listdir(b)[:] dircache.annotate(a, a_list) dircache.annotate(b, b_list) a_list.sort() b_list.sort() # for x in a_list: if x in ['./', '../']: pass elif x not in b_list: a_only.append(x, a_only_action) else: ax = path.cat(a, x) bx = path.cat(b, x) if path.isdir(ax) and path.isdir(bx): if flags = '-r': same = dircmp(ax, bx) else: same = 0 else: try: same = cmp.cmp(ax, bx) except posix.error: same = 0 if same: ab_same.append(x, ab_same_action) else: ab_diff.append(x, ab_diff_action)
def cp_ba(w, m, item): x = getselection(w) if x: if x[-1:] = '/': x = x[:-1] ax = path.cat(w.a, x) bx = path.cat(w.b, x) if path.isdir(bx): if path.exists(ax): m = 'Can\'t copy directory to existing target' stdwin.message(m) return runcmd('cp -r' + mkarg(bx) + mkarg(w.a)) else: runcmd('cp' + mk2arg(w.b, x) + mkarg(ax)) update(w)
def copy_book_contents_to(self, destdir): destdir = utf8_str(destdir) if destdir is None or not path.isdir(destdir): raise WrapperException('destination directory does not exist') for id in self.id_to_filepath.keys(): rpath = self.id_to_filepath[id] in_manifest = id in self.id_to_mime.keys() if in_manifest: data = self.readfile(id) else: data = self.readotherfile(id) filepath = os.path.join(destdir,rpath) base = os.path.dirname(filepath) if not path.exists(base): os.makedirs(pathof(base)) with open(pathof(filepath),'wb') as fp: fp.write(data)
def _cvs_downloader(url, local, config, opts): rlp = os.path.relpath(path.host(local)) us = url.split('?') module = None tag = None date = None src_prefix = None for a in us[1:]: _as = a.split('=') if _as[0] == 'module': if len(_as) != 2: raise error.general('invalid cvs module: %s' % (a)) module = _as[1] elif _as[0] == 'src-prefix': if len(_as) != 2: raise error.general('invalid cvs src-prefix: %s' % (a)) src_prefix = _as[1] elif _as[0] == 'tag': if len(_as) != 2: raise error.general('invalid cvs tag: %s' % (a)) tag = _as[1] elif _as[0] == 'date': if len(_as) != 2: raise error.general('invalid cvs date: %s' % (a)) date = _as[1] repo = cvs.repo(local, opts, config.macros, src_prefix) if not repo.valid(): if not path.isdir(local): log.notice('Creating source directory: %s' % \ (os.path.relpath(path.host(local)))) if _do_download(opts): path.mkdir(local) log.notice('cvs: checkout: %s -> %s' % (us[0], rlp)) if _do_download(opts): repo.checkout(':%s' % (us[0][6:]), module, tag, date) for a in us[1:]: _as = a.split('=') if _as[0] == 'update': log.notice('cvs: update: %s' % (us[0])) if _do_download(opts): repo.update() elif _as[0] == 'reset': log.notice('cvs: reset: %s' % (us[0])) if _do_download(opts): repo.reset() return True
def copy_book_contents_to(self, destdir): destdir = utf8_str(destdir) if destdir is None or not path.isdir(destdir): raise WrapperException('destination directory does not exist') for id in self.id_to_filepath.keys(): rpath = self.id_to_filepath[id] in_manifest = id in self.id_to_mime.keys() if in_manifest: data = self.readfile(id) else: data = self.readotherfile(id) filepath = os.path.join(destdir, rpath) base = os.path.dirname(filepath) if not path.exists(base): os.makedirs(pathof(base)) with open(pathof(filepath), 'wb') as fp: fp.write(data)
def _cvs_downloader(url, local, config, opts): rlp = os.path.relpath(path.host(local)) us = url.split("?") module = None tag = None date = None src_prefix = None for a in us[1:]: _as = a.split("=") if _as[0] == "module": if len(_as) != 2: raise error.general("invalid cvs module: %s" % (a)) module = _as[1] elif _as[0] == "src-prefix": if len(_as) != 2: raise error.general("invalid cvs src-prefix: %s" % (a)) src_prefix = _as[1] elif _as[0] == "tag": if len(_as) != 2: raise error.general("invalid cvs tag: %s" % (a)) tag = _as[1] elif _as[0] == "date": if len(_as) != 2: raise error.general("invalid cvs date: %s" % (a)) date = _as[1] repo = cvs.repo(local, opts, config.macros, src_prefix) if not repo.valid(): if not path.isdir(local): log.notice("Creating source directory: %s" % (os.path.relpath(path.host(local)))) if not opts.dry_run(): path.mkdir(local) log.notice("cvs: checkout: %s -> %s" % (us[0], rlp)) if not opts.dry_run(): repo.checkout(":%s" % (us[0][6:]), module, tag, date) for a in us[1:]: _as = a.split("=") if _as[0] == "update": log.notice("cvs: update: %s" % (us[0])) if not opts.dry_run(): repo.update() elif _as[0] == "reset": log.notice("cvs: reset: %s" % (us[0])) if not opts.dry_run(): repo.reset() return True
def main(): sys.stdout = sys.stderr progname = path.basename(sys.argv[0]) args = sys.argv[1:] if not args: print 'usage:', progname, 'path ...' sys.exit(2) status = 0 for name in args: if not path.islink(name): print progname + ':', name + ':', 'not a symlink' status = 1 else: if path.isdir(name): mkrealdir(name) else: mkrealfile(name) sys.exit(status)
def main(): sys.stdout = sys.stderr progname = path.basename(sys.argv[0]) args = sys.argv[1:] if not args: print 'usage:', progname, 'path ...' sys.exit(2) status = 0 for name in args: if not path.islink(name): print progname+':', name+':', 'not a symlink' status = 1 else: if path.isdir(name): mkrealdir(name) else: mkrealfile(name) sys.exit(status)
def path_check(opts, silent = False): if 'PATH' in os.environ: paths = os.environ['PATH'].split(os.pathsep) for p in paths: if len(p.strip()) == 0: if not silent: log.notice('error: environment PATH contains an empty path') return False elif p.strip() == '.' or p.strip() == '..': if not silent: log.notice('error: environment PATH invalid path: %s' % (p)) return False elif not path.exists(p): if not silent and opts.warn_all(): log.notice('warning: environment PATH not found: %s' % (p)) elif not path.isdir(p): if not silent and opts.warn_all(): log.notice('warning: environment PATH not a directory: %s' % (p)) return True
def copytree(src, dst): names = posix.listdir(src) posix.mkdir(dst, 0777) dot_dotdot = '.', '..' for name in names: if name not in dot_dotdot: srcname = path.cat(src, name) dstname = path.cat(dst, name) #print 'Copying', srcname, 'to', dstname try: #if path.islink(srcname): # linkto = posix.readlink(srcname) # posix.symlink(linkto, dstname) #elif path.isdir(srcname): if path.isdir(srcname): copytree(srcname, dstname) else: copy2(srcname, dstname) # XXX What about devices, sockets etc.? except posix.error, why: print 'Could not copy', srcname, 'to', dstname, print '(', why[1], ')'
def get_file(url, local, opts, config): if local is None: raise error.general('source/patch path invalid') if not path.isdir(path.dirname(local)) and not opts.download_disabled(): log.notice('Creating source directory: %s' % \ (os.path.relpath(path.host(path.dirname(local))))) log.output('making dir: %s' % (path.host(path.dirname(local)))) if _do_download(opts): path.mkdir(path.dirname(local)) if not path.exists(local) and opts.download_disabled(): raise error.general('source not found: %s' % (path.host(local))) # # Check if a URL has been provided on the command line. # url_bases = opts.urls() urls = [] if url_bases is not None: for base in url_bases: if base[-1:] != '/': base += '/' url_path = urlparse.urlsplit(url)[2] slash = url_path.rfind('/') if slash < 0: url_file = url_path else: url_file = url_path[slash + 1:] urls.append(urlparse.urljoin(base, url_file)) urls += url.split() log.trace('_url: %s -> %s' % (','.join(urls), local)) for url in urls: for dl in downloaders: if url.startswith(dl): if downloaders[dl](url, local, config, opts): return if _do_download(opts): raise error.general( 'downloading %s: all paths have failed, giving up' % (url))
def load(): # Default to the native Windows Python. uname = 'win32' if 'PROCESSOR_ARCHITECTURE' in os.environ: if os.environ['PROCESSOR_ARCHITECTURE'] == 'AMD64': hosttype = 'x86_64' machsize = '64' else: hosttype = 'i686' machsize = '32' else: hosttype = 'x86_64' machsize = '32' uname = 'mingw32' machine = 'w%s' % (machsize) # Set the C/C++ compilers we want to use. cc = '%s-%s-%s-gcc' % (hosttype, machine, uname) cxx = '%s-%s-%s-g++' % (hosttype, machine, uname) # See if this is actually MSYS2/Cygwin Python if os.name == 'posix': _uname = os.uname() if _uname[0].startswith('MINGW'): pass elif _uname[0].startswith('CYGWIN'): hosttype = _uname[4] uname = 'cygwin' machine = 'pc' cc = 'gcc' cxx = 'g++' else: raise error.general('invalid POSIX python for Windows') host_triple = '%s-%s-%s' % (hosttype, machine, uname) build_triple = '%s-%s-%s' % (hosttype, machine, uname) if 'NUMBER_OF_PROCESSORS' in os.environ: ncpus = os.environ['NUMBER_OF_PROCESSORS'] else: ncpus = '1' if 'MSYSTEM' in os.environ: os.environ.pop('NUMBER_OF_PROCESSORS') version = uname[2] defines = { '_ncpus': ('none', 'none', ncpus), '_os': ('none', 'none', 'win32'), '_windows_os': ('none', 'none', uname), '_build': ('triplet', 'required', build_triple), '_build_vendor': ('none', 'none', 'microsoft'), '_build_os': ('none', 'none', 'win32'), '_build_os_version': ('none', 'none', version), '_build_cpu': ('none', 'none', hosttype), '_build_alias': ('none', 'none', '%{nil}'), '_build_arch': ('none', 'none', hosttype), '_host': ('triplet', 'required', host_triple), '_host_vendor': ('none', 'none', 'microsoft'), '_host_os': ('none', 'none', 'win32'), '_host_cpu': ('none', 'none', hosttype), '_host_alias': ('none', 'none', '%{nil}'), '_host_arch': ('none', 'none', hosttype), '_usr': ('dir', 'optional', '/opt/local'), '_var': ('dir', 'optional', '/opt/local/var'), '__bash': ('exe', 'required', 'bash'), '__bzip2': ('exe', 'required', 'bzip2'), '__bison': ('exe', 'required', 'bison'), '__cat': ('exe', 'required', 'cat'), '__cc': ('exe', 'required', cc), '__chgrp': ('exe', 'required', 'chgrp'), '__chmod': ('exe', 'required', 'chmod'), '__chown': ('exe', 'required', 'chown'), '__cp': ('exe', 'required', 'cp'), '__cvs': ('exe', 'optional', 'cvs'), '__cxx': ('exe', 'required', cxx), '__flex': ('exe', 'required', 'flex'), '__git': ('exe', 'required', 'git'), '__grep': ('exe', 'required', 'grep'), '__gzip': ('exe', 'required', 'gzip'), '__id': ('exe', 'required', 'id'), '__install': ('exe', 'required', 'install'), '__install_info': ('exe', 'required', 'install-info'), '__ld': ('exe', 'required', 'ld'), '__ldconfig': ('exe', 'none', ''), '__makeinfo': ('exe', 'required', 'makeinfo'), '__mkdir': ('exe', 'required', 'mkdir'), '__mv': ('exe', 'required', 'mv'), '__nm': ('exe', 'required', 'nm'), '__nm': ('exe', 'required', 'nm'), '__objcopy': ('exe', 'required', 'objcopy'), '__objdump': ('exe', 'required', 'objdump'), '__patch': ('exe', 'required', 'patch'), '__patch_bin': ('exe', 'required', 'patch'), '__rm': ('exe', 'required', 'rm'), '__sed': ('exe', 'required', 'sed'), '__sh': ('exe', 'required', 'sh'), '__tar': ('exe', 'required', 'bsdtar'), '__touch': ('exe', 'required', 'touch'), '__unzip': ('exe', 'required', 'unzip'), '__xz': ('exe', 'required', 'xz'), '_buildshell': ('exe', 'required', '%{__sh}'), '___setup_shell': ('exe', 'required', '%{__sh}') } # # Locate a suitable python to use with GDB. Python Windows is more # complicated than most hosts. There are 7 possible pythons on Windows and # we can use only 4 which are split on machine size. The types are: # # 1. Python27 - python.org, cannot use cause built with MSVC. # 2. Python35 - python.org, cannot use cause built with MSVC. # 3. MSYS/Python - MSYS2, cannot use cause it is a MSYS executable. # 4. W64/Python2 - Ok if machsize is 64 # 5. W64/Python3 - gdb-7.9 needs python2. # 6. W64/Python2 - Ok if machsize is 32 # 7. W64/Python3 - gdb-7.9 needs python2. # # Find a suitable python2 and python3. # for p in os.environ['PATH'].split(os.pathsep): sh = os.path.join(p, 'sh.exe') if os.path.exists(sh) and os.path.isfile(sh): break sh = None if sh is None: raise error.general('cannot find a shell (sh.exe) in the PATH') # # Search the MSYS2 install tree for a suitable python. # if sys.platform == 'msys': e = execute.capture_execution() exit_code, proc, output = e.shell("sh -c mount") if exit_code != 0: raise error.general('cannot get MSYS mount points') install_point = None for l in output.split('\n'): if ' on / ' in l: install_point = l.split()[0] break if install_point is None: raise error.general('cannot locate MSYS root mount point') if install_point[1] != ':': raise error.general('invalid MSYS root mount point: %s' % install_point) install_point = path.shell(install_point) mingw = path.join(install_point, 'mingw%s' % (machsize)) if not path.exists(mingw) or not path.isdir(mingw): raise error.general('cannot find MinGW install: %s' % (path.host(mingw))) for version in ['2', '3']: python = 'python%s' % (version) exe = path.join(mingw, 'bin', '%s.exe' % (python)) if not path.exists(exe) or not path.isdir(exe): defines['gdb_python%s' % (version)] = exe header = path.join(mingw, python) return defines
def _file_downloader(url, local, config, opts): if path.exists(local): return True return path.isdir(url)
import path import fnmatch def glob(pathname): if not has_magic(pathname): return [pathname] dirname, basename = path.split(pathname) if dirname[-1:] = '/' and dirname <> '/': dirname = dirname[:-1] if has_magic(dirname): list = glob(dirname) else: list = [dirname] if not has_magic(basename): result = [] for dirname in list: if basename or path.isdir(dirname): name = path.cat(dirname, basename) if path.exists(name): result.append(name) else: result = [] for dirname in list: sublist = glob1(dirname, basename) for name in sublist: result.append(path.cat(dirname, name)) return result def glob1(dirname, pattern): if not dirname: dirname = '.' try: names = posix.listdir(dirname)
def ab_same_action(w, string, sel, detail): ax = path.cat(w.a, string) if path.isdir(ax): ab_diff_action(w, string, sel, detail) else: a_only_action(w, string, sel, detail)
def get_file(url, local, opts, config): if local is None: raise error.general('source/patch path invalid') if not path.isdir(path.dirname(local)) and not opts.download_disabled(): log.notice('Creating source directory: %s' % \ (os.path.relpath(path.host(path.dirname(local))))) log.output('making dir: %s' % (path.host(path.dirname(local)))) if _do_download(opts): path.mkdir(path.dirname(local)) if not path.exists(local) and opts.download_disabled(): raise error.general('source not found: %s' % (path.host(local))) # # Check if a URL has been provided on the command line. If the package is # released push to the start the RTEMS URL unless overrided by the command # line option --with-release-url. The variant --without-release-url can # override the released check. # url_bases = opts.urls() try: rtems_release_url_value = config.macros.expand('%{rtems_release_url}/%{rsb_version}/sources') except: rtems_release_url_value = None log.output('RTEMS release URL could not be expanded') rtems_release_url = None if version.released() and rtems_release_url_value: rtems_release_url = rtems_release_url_value with_rel_url = opts.with_arg('release-url') if with_rel_url[1] == 'not-found': if config.defined('without_release_url'): with_rel_url = ('without_release-url', 'yes') if with_rel_url[0] == 'with_release-url': if with_rel_url[1] == 'yes': if rtems_release_url_value is None: raise error.general('no valid release URL') rtems_release_url = rtems_release_url_value elif with_rel_url[1] == 'no': pass else: rtems_release_url = with_rel_url[1] elif with_rel_url[0] == 'without_release-url' and with_rel_url[1] == 'yes': rtems_release_url = None if rtems_release_url is not None: log.trace('release url: %s' % (rtems_release_url)) # # If the URL being fetched is under the release path do not add the # sources release path because it is already there. # if not url.startswith(rtems_release_url): if url_bases is None: url_bases = [rtems_release_url] else: url_bases.append(rtems_release_url) urls = [] if url_bases is not None: # # Split up the URL we are being asked to download. # url_path = urllib_parse.urlsplit(url)[2] slash = url_path.rfind('/') if slash < 0: url_file = url_path else: url_file = url_path[slash + 1:] log.trace('url_file: %s' %(url_file)) for base in url_bases: if base[-1:] != '/': base += '/' next_url = urllib_parse.urljoin(base, url_file) log.trace('url: %s' %(next_url)) urls.append(next_url) urls += url.split() log.trace('_url: %s -> %s' % (','.join(urls), local)) for url in urls: for dl in downloaders: if url.startswith(dl): if downloaders[dl](url, local, config, opts): return if _do_download(opts): raise error.general('downloading %s: all paths have failed, giving up' % (url))
# List windows -- to display list of files and subdirectories def openlistwindow(dirname): list = posix.listdir(dirname) list.sort() i = 0 while i < len(list): if list[i] = '.' or list[i] = '..': del list[i] else: i = i+1 for i in range(len(list)): name = list[i] if path.isdir(path.cat(dirname, name)): list[i] = list[i] + '/' width = maxwidth(list) width = width + stdwin.textwidth(' ') # XXX X11 stdwin bug workaround height = len(list) * stdwin.lineheight() stdwin.setdefwinsize(width, min(height, 500)) w = stdwin.open(dirname) stdwin.setdefwinsize(0, 0) w.setdocsize(width, height) w.drawproc = drawlistwindow w.mouse = mouselistwindow w.close = closelistwindow w.dirname = dirname w.list = list w.selected = -1 return w
def annotate(head, list): # Add '/' suffixes to directories for i in range(len(list)): if path.isdir(path.cat(head, list[i])): list[i] = list[i] + "/"
def annotate(head, list): # Add '/' suffixes to directories for i in range(len(list)): if path.isdir(path.cat(head, list[i])): list[i] = list[i] + '/'