X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=tools%2Finstall-decoders;h=8445da561df4beb55f6056f445f4ad2773dec546;hb=e959f49ac718b45d83304f626559de29403ac52f;hp=8134539d35946597eaeace5862b37c7e796ce477;hpb=03d6d746b742fb21ca22086ba6b72943a845ecc9;p=libsigrokdecode.git diff --git a/tools/install-decoders b/tools/install-decoders index 8134539..8445da5 100755 --- a/tools/install-decoders +++ b/tools/install-decoders @@ -1,22 +1,22 @@ #!/usr/bin/env python3 -# -# This file is part of the libsigrokdecode project. -# -# Copyright (C) 2012 Bert Vermeulen -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# +## +## This file is part of the libsigrokdecode project. +## +## Copyright (C) 2013 Bert Vermeulen +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, see . +## import os import sys @@ -24,7 +24,7 @@ from shutil import copy from getopt import getopt -def install(srcdir, dstdir): +def install(srcdir, dstdir, s): worklist = [] for pd in os.listdir(srcdir): pd_dir = srcdir + '/' + pd @@ -39,9 +39,10 @@ def install(srcdir, dstdir): install_list.extend(config_get_extra_install(pd_file)) elif f[-3:] == '.py': install_list.append(f) - worklist.append((pd, pd_dir, install_list)) + if install_list: + worklist.append((pd, pd_dir, install_list)) - print("Installing %d protocol decoders:" % len(worklist)) + print("Installing %d %s:" % (len(worklist), s)) col = 0 for pd, pd_dir, install_list in worklist: msg = pd + ' ' @@ -50,13 +51,16 @@ def install(srcdir, dstdir): col = 0 print(msg, end='') col += len(msg) - pd_dst = dstdir + '/' + pd + pd_dst = os.path.join(dstdir, pd) try: os.mkdir(pd_dst) - except FileExistsError: - pass + except OSError as e: + if e.errno != os.errno.EEXIST: + raise + else: + pass for f in install_list: - copy(pd_dir + '/' + f, pd_dst) + copy(os.path.join(pd_dir, f), pd_dst) print() @@ -104,6 +108,7 @@ except Exception as e: if len(args) != 0 or dst is None: usage() -install(src, dst) +install(src, dst, 'protocol decoders') +install(src + '/common', dst + '/common', 'common modules')