version = self.get_changelog_version()

        common.specialize_template(
            os.path.join(root_dir, '..', 'csharp', 'AssemblyInfo.cs.template'),
            os.path.join(self.tmp_source_tinkerforge_dir, 'AssemblyInfo.cs'), {
                '<<BINDINGS>>': 'Mathematica',
                '<<VERSION>>': '.'.join(version)
            })

        # Make dll
        with common.ChangedDirectory(self.tmp_dir):
            common.execute([
                'mcs', '/optimize+', '/warn:4', '/warnaserror', '/sdk:2',
                '/target:library',
                '/out:' + os.path.join(self.tmp_dir, 'Tinkerforge.dll'),
                os.path.join(self.tmp_source_tinkerforge_dir, '*.cs')
            ])

        # Make zip
        self.create_zip_file(self.tmp_dir)


def generate(root_dir, language):
    common.generate(root_dir, language, MathematicaZipGenerator)


if __name__ == '__main__':
    common.dockerize('mathematica', __file__)

    generate(os.getcwd(), 'en')
Пример #2
0
            if device.get_git_name() + '/' + example.get_name(
            ).dash in blacklist:
                print('  - ' + filename +
                      ' \033[01;35m(blacklisted, skipped)\033[0m')
                continue

            if example.is_incomplete():
                if os.path.exists(
                        filepath) and self.skip_existing_incomplete_example:
                    print('  - ' + filename +
                          ' \033[01;35m(incomplete, skipped)\033[0m')
                    continue
                else:
                    print('  - ' + filename +
                          ' \033[01;31m(incomplete)\033[0m')
            else:
                print('  - ' + filename)

            with open(filepath, 'w') as f:
                f.write(example.get_html_source())


def generate(root_dir, language):
    common.generate(root_dir, language, JavaScriptExamplesGenerator)


if __name__ == '__main__':
    common.dockerize('javascript', __file__)

    generate(os.getcwd(), 'en')
Пример #3
0
    def get_doc_example_regex(self):
        return r'^example_.*\.go$'

    def get_device_class(self):
        return GoDocDevice

    def get_packet_class(self):
        return GoDocPacket

    def generate(self, device):
        with open(device.get_doc_rst_path(), 'w') as f:
            f.write(device.get_go_doc())

    def get_doc_null_value_name(self):
        return 'nil'

    def get_doc_formatted_param(self, element):
        return element.get_go_name()


def generate(root_dir, language):
    common.generate(root_dir, language, GoDocGenerator)


if __name__ == '__main__':
    common.dockerize('go', __file__)

    for language in ['en', 'de']:
        generate(os.getcwd(), language)
Пример #4
0
            if active_bindings == None:
                return 1

    for binding in all_bindings:
        if binding not in active_bindings:
            continue

        print('\033[01;32m>>> running tests for {0} bindings\033[0m'.format(binding))

        try:
            module = importlib.import_module('generators.{0}.test_{0}_bindings'.format(binding))
        except ImportError: # FIXME: Python 3.6 has ModuleNotFoundError, which would be better to use here, but Debian Stretch has only Python 3.5
            print('\033[01;36m### tests missing\033[0m')
        else:
            success = module.test(os.path.join(generators_dir, binding))

            if not isinstance(success, bool):
                print('error: test_{0}_bindings.py returns wrong type from its test() function'.format(binding))

            if not success:
                sys.exit(1)

    print('\033[01;35m>>> done\033[0m')

if __name__ == '__main__':
    def add_arguments(parser):
        parser.add_argument('-b', '--bindings', nargs=1, help='comma separated list of bindings, each prefixed by +/-')

    sys.exit(main(common.dockerize('', __file__, add_arguments=add_arguments)))
Пример #5
0
            os.path.join(
                self.tmp_dir,
                '{}_mqtt.service'.format(self.get_config_name().under)), {
                    "<<CONFIG_NAME_SPACE>>": self.get_config_name().space,
                    "<<CONFIG_NAME_UNDER>>": self.get_config_name().under
                })

        if self.get_config_name().space == 'Tinkerforge':
            shutil.copy(os.path.join(root_dir, 'changelog.txt'), self.tmp_dir)
            shutil.copy(os.path.join(root_dir, 'readme.txt'), self.tmp_dir)
            shutil.copy(os.path.join(root_dir, '..', 'configs', 'license.txt'),
                        self.tmp_dir)
        else:
            shutil.copy(os.path.join(self.get_config_dir(), 'changelog.txt'),
                        self.tmp_dir)
            shutil.copy(os.path.join(root_dir, 'custom.txt'),
                        os.path.join(self.tmp_dir, 'readme.txt'))

        # Make zip
        self.create_zip_file(self.tmp_dir)


def generate(root_dir, language):
    common.generate(root_dir, language, MQTTZipGenerator)


if __name__ == '__main__':
    common.dockerize('mqtt', __file__)

    generate(os.getcwd(), 'en')
Пример #6
0
    sys.modules['generators'] = generators_module

if 'generators' not in sys.modules:
    create_generators_module()

from generators import common

class PHPTester(common.Tester):
    def __init__(self, root_dir, extra_paths):
        common.Tester.__init__(self, 'php', '.php', root_dir, subdirs=['examples', 'source'], extra_paths=extra_paths)

    def test(self, cookie, path, extra):
        args = ['php',
                '-l',
                path]

        self.execute(cookie, args)

def test(root_dir):
    extra_paths = [os.path.join(root_dir, '../../weather-station/website/php/WeatherStationWebsite.php'),
                   os.path.join(root_dir, '../../weather-station/write_to_lcd/php/WeatherStation.php'),
                   os.path.join(root_dir, '../../hardware-hacking/remote_switch/php/RemoteSwitch.php'),
                   os.path.join(root_dir, '../../hardware-hacking/smoke_detector/php/SmokeDetector.php')]

    return PHPTester(root_dir, extra_paths).run()

if __name__ == '__main__':
    common.dockerize('php', __file__)

    test(os.getcwd())
Пример #7
0
                f.write(example.get_matlab_source())

        # octave
        for example in examples:
            filename = 'octave_example_{0}.m'.format(example.get_name().under)
            filepath = os.path.join(examples_dir, filename)

            if device.get_git_name() + '/' + example.get_name().dash in blacklist:
                print('  - ' + filename + ' \033[01;35m(blacklisted, skipped)\033[0m')
                continue

            if example.is_incomplete():
                if os.path.exists(filepath) and self.skip_existing_incomplete_example:
                    print('  - ' + filename + ' \033[01;35m(incomplete, skipped)\033[0m')
                    continue
                else:
                    print('  - ' + filename + ' \033[01;31m(incomplete)\033[0m')
            else:
                print('  - ' + filename)

            with open(filepath, 'w') as f:
                f.write(example.get_octave_source())

def generate(root_dir, language):
    common.generate(root_dir, language, MATLABExamplesGenerator)

if __name__ == '__main__':
    common.dockerize('matlab', __file__)

    generate(os.getcwd(), 'en')
Пример #8
0
        for example in examples:
            filename = 'Example{0}.vb'.format(example.get_name().camel)
            filepath = os.path.join(examples_dir, filename)

            if example.is_incomplete():
                if os.path.exists(
                        filepath) and self.skip_existing_incomplete_example:
                    common.print_verbose(
                        '    - ' + filename +
                        ' \033[01;35m(incomplete, skipped)\033[0m')
                    continue
                else:
                    common.print_verbose('    - ' + filename +
                                         ' \033[01;31m(incomplete)\033[0m')
            else:
                common.print_verbose('    - ' + filename)

            with open(filepath, 'w') as f:
                f.write(example.get_vbnet_source())


def generate(root_dir, language):
    common.generate(root_dir, language, VBNETExamplesGenerator)


if __name__ == '__main__':
    common.dockerize('vbnet', __file__)

    generate(os.getcwd(), 'en')
Пример #9
0
                f.write(example.get_rust_source())

            version = subprocess.check_output(["rustfmt", "--version"])

            if not 'nightly' in version.decode('utf-8'):
                print(
                    "Please set your rust toolchain to nightly (e.g. with 'rustup default nightly'), as the example generator currently depends on unstable rustfmt features."
                )
                return

            p = subprocess.Popen(
                ["rustfmt", filename, "--config-path", self.root_dir],
                cwd=examples_dir,
                stdout=subprocess.PIPE)
            out, err = p.communicate()  #block until rustfmt has finished

            if len(out) > 0 or err is not None:
                print("Got the following output from rustfmt:")
                print(out)
                print(err)


def generate(root_dir, language):
    common.generate(root_dir, language, RustExamplesGenerator)


if __name__ == '__main__':
    common.dockerize('rust', __file__)

    generate(os.getcwd(), 'en')
Пример #10
0
        common.execute([
            'wget',
            'https://dist.nuget.org/win-x86-commandline/v5.0.2/nuget.exe'
        ])

    # Make Tinkerforge.nuspec
    common.specialize_template(
        os.path.join(root_dir, 'Tinkerforge.nuspec.template'),
        os.path.join(tmp_dir, 'Tinkerforge.nuspec'),
        {'{{VERSION}}': '.'.join(version)})

    # Make package
    with common.ChangedDirectory(tmp_dir):
        common.execute([
            'mono',
            os.path.join(tmp_dir, 'nuget.exe'), 'pack',
            os.path.join(tmp_dir, 'Tinkerforge.nuspec')
        ])

    shutil.move(
        os.path.join(tmp_dir,
                     'Tinkerforge.{0}.{1}.{2}.nupkg'.format(*version)),
        os.path.join(root_dir,
                     'tinkerforge.{0}.{1}.{2}.nupkg'.format(*version)))


if __name__ == '__main__':
    common.dockerize('csharp', __file__)

    generate(os.getcwd())
Пример #11
0
        h_callback_list = device.get_h_callback_list()
        c_cases = device.get_c_cases()
        c_functions = device.get_c_functions()
        c_callbacks = device.get_c_callbacks()

        h_constants_string = '\n'.join(h_constants)
        h_defines_string = '\n'.join(h_defines)
        h_structs_string = '\n'.join(h_structs)
        h_function_prototypes_string = '\n'.join(h_function_prototypes)
        h_callback_prototypes_string = '\n'.join(h_callback_prototypes)
        h_callback_list_string = '\n'.join(h_callback_list)
        c_cases_string = '\n'.join(c_cases)
        c_functions_string = '\n'.join(c_functions)
        c_callbacks_string = '\n'.join(c_callbacks)
        c_callback_value_include_string = device.get_c_callback_value_include()
        c_callback_value_init_string = device.get_c_callback_value_init()

        with open(os.path.join(folder, 'software', 'src', 'communication.c'), 'w') as c:
            c.write(self.c_file.format(device_name_dash, year, name, email, c_cases_string, c_functions_string, c_callbacks_string, c_callback_value_include_string, c_callback_value_init_string))

        with open(os.path.join(folder, 'software', 'src', 'communication.h'), 'w') as h:
            h.write(self.h_file.format(device_name_dash, year, name, email, h_constants_string, h_defines_string, h_structs_string, h_function_prototypes_string, h_callback_prototypes_string, h_callback_list_string))

def generate(root_dir, language):
    common.generate(root_dir, language, CoMCUStubGenerator)

if __name__ == '__main__':
    common.dockerize('stubs', __file__)

    generate(os.getcwd(), 'en')
Пример #12
0
    def get_doc_rst_filename_part(self):
        return 'TCPIP'

    def get_doc_example_regex(self):
        return None

    def get_device_class(self):
        return TCPIPDocDevice

    def get_packet_class(self):
        return TCPIPDocPacket

    def get_element_class(self):
        return TCPIPDocElement

    def generate(self, device):
        with open(device.get_doc_rst_path(), 'w') as f:
            f.write(device.get_tcpip_doc())


def generate(root_dir, language):
    common.generate(root_dir, language, TCPIPDocGenerator)


if __name__ == '__main__':
    common.dockerize('tcpip', __file__)

    for language in ['en', 'de']:
        generate(os.getcwd(), language)
Пример #13
0

def generate(root_dir, language):
    if language != 'en':
        print("Generating {} is not implemented yet.".format(language))
        import shutil

        de_docs = os.path.join(root_dir, 'doc', 'de')
        shutil.rmtree(de_docs, ignore_errors=True)
        shutil.copytree(os.path.join(root_dir, 'doc', 'en'), de_docs)
        for file in os.listdir(de_docs):
            with open(os.path.join(de_docs, file), 'r') as f:
                content = f.read()
            content = content.replace(
                'This is the description of the :ref:`openHAB API bindings <api_bindings_openhab>` for the',
                '.. note::\n Zur Zeit ist nur die englische openHAB-Dokumentation verfügbar.\n\nThis is the description of the :ref:`openHAB API bindings <api_bindings_openhab>` for the'
            )
            with open(os.path.join(de_docs, file), 'w') as f:
                f.write(content)

        return

    common.generate(root_dir, 'en', OpenHABDocGenerator)


if __name__ == '__main__':
    common.dockerize('openhab', __file__)

    for language in ['en', 'de']:
        generate(os.getcwd(), language)
Пример #14
0
    def get_device_class(self):
        return JavaDocDevice

    def get_packet_class(self):
        return JavaDocPacket

    def get_element_class(self):
        return java_common.JavaElement

    def generate(self, device):
        with open(device.get_doc_rst_path(), 'w') as f:
            f.write(device.get_java_doc())

    def is_matlab(self):
        return False

    def is_octave(self):
        return False


def generate(root_dir, language):
    common.generate(root_dir, language, JavaDocGenerator)


if __name__ == '__main__':
    common.dockerize('java', __file__)

    for language in ['en', 'de']:
        generate(os.getcwd(), language)
Пример #15
0
class ShellDocGenerator(shell_common.ShellGeneratorTrait, common.DocGenerator):
    def get_doc_rst_filename_part(self):
        return 'Shell'

    def get_doc_example_regex(self):
        return r'^example-.*\.sh$'

    def get_device_class(self):
        return ShellDocDevice

    def get_packet_class(self):
        return ShellDocPacket

    def get_element_class(self):
        return shell_common.ShellElement

    def generate(self, device):
        with open(device.get_doc_rst_path(), 'w') as f:
            f.write(device.get_shell_doc())


def generate(root_dir, language):
    common.generate(root_dir, language, ShellDocGenerator)


if __name__ == '__main__':
    common.dockerize('shell', __file__)

    for language in ['en', 'de']:
        generate(os.getcwd(), language)
Пример #16
0
    if device_display_name == nil
      device_display_name = "Unknown Device [#{{device_identifier}}]"
    end

    device_display_name
  end
end
"""

        entries = []

        for device_identifier, device_display_name in sorted(self.device_display_names):
            entries.append("{0} => '{1}'".format(device_identifier, device_display_name))

        with open(os.path.join(self.get_bindings_dir(), 'device_display_names.rb'), 'w') as f:
            f.write(template.format(header=self.get_header_comment('hash'),
                                    entries=',\n    '.join(entries)))

        self.released_files.append('device_display_names.rb')

        common.BindingsGenerator.finish(self)

def generate(root_dir, language):
    common.generate(root_dir, language, RubyBindingsGenerator)

if __name__ == '__main__':
    common.dockerize('ruby', __file__)

    generate(os.getcwd(), 'en')
Пример #17
0
    def generate(self, device):
        pass

    def finish(self):
        root_dir = self.get_root_dir()
        bindings_dir = self.get_bindings_dir()

        # Copy bindings and readme
        shutil.copy(os.path.join(bindings_dir, 'HighLevelAnalyzer.py'),
                    self.tmp_dir)
        shutil.copy(os.path.join(bindings_dir, 'extension.json'), self.tmp_dir)
        shutil.copy(os.path.join(root_dir, 'changelog.txt'), self.tmp_dir)
        shutil.copy(os.path.join(root_dir, 'readme.txt'), self.tmp_dir)
        shutil.copy(os.path.join(root_dir, 'README.md'), self.tmp_dir)
        shutil.copy(os.path.join(root_dir, '..', 'configs', 'license.txt'),
                    self.tmp_dir)

        # Make zip
        self.create_zip_file(self.tmp_dir)


def generate(root_dir, language):
    common.generate(root_dir, language, SaleaeZipGenerator)


if __name__ == '__main__':
    common.dockerize('saleae', __file__)

    generate(os.getcwd(), 'en')
Пример #18
0
    def check_success(self, exit_code, output):
        if self.compiler == 'scan-build clang' and exit_code == 0 and 'scan-build: No bugs found.\n' not in output:
            return False

        return exit_code == 0

def test(root_dir):
    extra_paths = []

    if not UCExamplesTester(root_dir, 'clang', extra_paths).run():
        return False

    if not UCExamplesTester(root_dir, 'gcc', extra_paths).run():
        return False

    if not UCExamplesTester(root_dir, 'g++', extra_paths).run():
        return False

    if not UCExamplesTester(root_dir, 'mingw32-gcc', extra_paths).run():
        return False

    if not UCExamplesTester(root_dir, 'mingw32-g++', extra_paths).run():
        return False

    return UCExamplesTester(root_dir, 'scan-build clang', extra_paths).run()

if __name__ == '__main__':
    common.dockerize('uc', __file__)

    test(os.getcwd())
Пример #19
0
class TVPLDocGenerator(tvpl_common.TVPLGeneratorTrait, common.DocGenerator):
    def get_doc_rst_filename_part(self):
        return 'TVPL'

    def get_doc_example_regex(self):
        return r'^example_.*\.tvpl$'

    def get_device_class(self):
        return TVPLDocDevice

    def get_packet_class(self):
        return TVPLDocPacket

    def get_element_class(self):
        return tvpl_common.TVPLElement

    def generate(self, device):
        with open(device.get_doc_rst_path(), 'w') as f:
            f.write(device.get_tvpl_doc())


def generate(root_dir, language):
    common.generate(root_dir, language, TVPLDocGenerator)


if __name__ == '__main__':
    common.dockerize('tvpl', __file__)

    for language in ['en', 'de']:
        generate(os.getcwd(), language)
Пример #20
0
        for example in examples:
            filename = 'example_{0}.py'.format(example.get_name().under)
            filepath = os.path.join(examples_dir, filename)

            if example.is_incomplete():
                if os.path.exists(
                        filepath) and self.skip_existing_incomplete_example:
                    common.print_verbose(
                        '    - ' + filename +
                        ' \033[01;35m(incomplete, skipped)\033[0m')
                    continue
                else:
                    common.print_verbose('    - ' + filename +
                                         ' \033[01;31m(incomplete)\033[0m')
            else:
                common.print_verbose('    - ' + filename)

            with open(filepath, 'w') as f:
                f.write(example.get_python_source())


def generate(root_dir, language):
    common.generate(root_dir, language, PythonExamplesGenerator)


if __name__ == '__main__':
    common.dockerize('python', __file__)

    generate(os.getcwd(), 'en')
Пример #21
0
        generators_spec = importlib.util.spec_from_file_location(
            'generators', os.path.join(generators_dir, '__init__.py'))
        generators_module = importlib.util.module_from_spec(generators_spec)

        generators_spec.loader.exec_module(generators_module)

    sys.modules['generators'] = generators_module


if 'generators' not in sys.modules:
    create_generators_module()

from generators import common
from generators.labview import labview_common
from generators.csharp.generate_csharp_bindings import CSharpBindingsGenerator


class LabVIEWBindingsGenerator(labview_common.LabVIEWGeneratorTrait,
                               CSharpBindingsGenerator):
    pass


def generate(root_dir, language):
    common.generate(root_dir, language, LabVIEWBindingsGenerator)


if __name__ == '__main__':
    common.dockerize('labview', __file__)

    generate(os.getcwd(), 'en')
Пример #22
0
    def generates_high_level_callbacks(self):
        return True

class JSONBindingsGenerator(JSONGeneratorTrait, common.BindingsGenerator):
    def get_device_class(self):
        return JSONBindingsDevice

    def get_packet_class(self):
        return JSONBindingsPacket

    def get_element_class(self):
        return JSONBindingsElement

    def generate(self, device):
        filename = '{0}_{1}.json'.format(device.get_category().under, device.get_name().under)

        with open(os.path.join(self.get_bindings_dir(), filename), 'w') as f:
            f.write(device.get_json_source())

        if device.is_released():
            self.released_files.append(filename)

def generate(root_dir, language):
    common.generate(root_dir, language, JSONBindingsGenerator)

if __name__ == '__main__':
    common.dockerize('json', __file__)

    generate(os.getcwd(), 'en')
Пример #23
0
        shutil.copy(os.path.join(root_dir, 'DeviceBase.pas'),               self.tmp_source_dir)
        shutil.copy(os.path.join(root_dir, 'Device.pas'),                   self.tmp_source_dir)
        shutil.copy(os.path.join(root_dir, 'IPConnection.pas'),             self.tmp_source_dir)
        shutil.copy(os.path.join(root_dir, 'LEConverter.pas'),              self.tmp_source_dir)
        shutil.copy(os.path.join(root_dir, 'TimedSemaphore.pas'),           self.tmp_source_dir)
        shutil.copy(os.path.join(root_dir, 'SHAone.pas'),                   self.tmp_source_dir)
        shutil.copy(os.path.join(root_dir, 'BrickDaemon.pas'),              self.tmp_source_dir)
        shutil.copy(os.path.join(root_dir, 'changelog.txt'),                self.tmp_dir)
        shutil.copy(os.path.join(root_dir, 'readme.txt'),                   self.tmp_dir)
        shutil.copy(os.path.join(root_dir, '..', 'configs', 'license.txt'), self.tmp_dir)

        # Make Makefile.fpc
        version = self.get_changelog_version()
        units = sorted([filename.replace('.pas', '') for filename in os.listdir(self.tmp_source_dir)])

        common.specialize_template(os.path.join(root_dir, 'Makefile.fpc.template'),
                                   os.path.join(self.tmp_source_dir, 'Makefile.fpc'),
                                   {'<<UNITS>>': ' '.join(units),
                                    '<<VERSION>>': '.'.join(version)})

        # Make zip
        self.create_zip_file(self.tmp_dir)

def generate(root_dir, language):
    common.generate(root_dir, language, DelphiZipGenerator)

if __name__ == '__main__':
    common.dockerize('delphi', __file__)

    generate(os.getcwd(), 'en')
Пример #24
0
        shutil.copy(os.path.join(root_dir, 'Error.pm'),
                    self.tmp_source_lib_tinkerforge_dir)
        shutil.copy(os.path.join(root_dir, 'changelog.txt'), self.tmp_dir)
        shutil.copy(os.path.join(root_dir, 'readme.txt'), self.tmp_dir)
        shutil.copy(os.path.join(root_dir, '..', 'configs', 'license.txt'),
                    self.tmp_dir)

        # Make Tinkerforge.pm
        version = self.get_changelog_version()

        common.specialize_template(
            os.path.join(root_dir, 'Tinkerforge.pm.template'),
            os.path.join(self.tmp_source_lib_dir, 'Tinkerforge.pm'),
            {'<<VERSION>>': '.'.join(version)})

        # Copy Makefile.PL
        shutil.copy(os.path.join(root_dir, 'Makefile.PL'), self.tmp_source_dir)

        # Make zip
        self.create_zip_file(self.tmp_dir)


def generate(root_dir, language):
    common.generate(root_dir, language, PerlZipGenerator)


if __name__ == '__main__':
    common.dockerize('perl', __file__)

    generate(os.getcwd(), 'en')
Пример #25
0
    def get_device_class(self):
        return ModbusDocDevice

    def get_packet_class(self):
        return ModbusDocPacket

    def get_element_class(self):
        return ModbusDocElement

    def get_doc_null_value_name(self):
        return 'null'

    def get_doc_formatted_param(self, element):
        return element.get_name().headless

    def generate(self, device):
        with open(device.get_doc_rst_path(), 'w') as f:
            f.write(device.get_modbus_doc())


def generate(root_dir, language):
    common.generate(root_dir, language, ModbusDocGenerator)


if __name__ == '__main__':
    common.dockerize('modbus', __file__)

    for language in ['en', 'de']:
        generate(os.getcwd(), language)