def finish(self): root_dir = self.get_bindings_root_directory() # Copy IP Connection examples for example in common.find_examples(root_dir, '^Example.*\.pas$'): shutil.copy(example[1], self.tmp_examples_dir) # Copy bindings and readme for filename in released_files: shutil.copy(os.path.join(root_dir, 'bindings', filename), self.tmp_source_dir) shutil.copy(os.path.join(root_dir, 'Base58.pas'), self.tmp_source_dir) shutil.copy(os.path.join(root_dir, 'BlockingQueue.pas'), self.tmp_source_dir) 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 = common.get_changelog_version(root_dir) 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 version = common.get_changelog_version(root_dir) common.make_zip(self.get_bindings_name(), self.tmp_dir, root_dir, version)
def generate(root_dir): tmp_dir = os.path.join(root_dir, 'maven_package') tmp_src_main_java_dir = os.path.join(tmp_dir, 'src', 'main', 'java') tmp_unzipped_dir = os.path.join(tmp_dir, 'unzipped') # Make directories common.recreate_dir(tmp_dir) os.makedirs(tmp_src_main_java_dir) # Unzip version = common.get_changelog_version(root_dir) common.execute(['/usr/bin/unzip', '-q', os.path.join(root_dir, 'tinkerforge_java_bindings_{0}_{1}_{2}.zip'.format(*version)), '-d', tmp_unzipped_dir]) # Copy source shutil.copytree(os.path.join(tmp_unzipped_dir, 'source', 'com'), os.path.join(tmp_src_main_java_dir, 'com')) # Make pom.xml common.specialize_template(os.path.join(root_dir, 'pom.xml.template'), os.path.join(tmp_dir, 'pom.xml'), {'{{VERSION}}': '.'.join(version)}) # Make package with common.ChangedDirectory(tmp_dir): common.execute(['/usr/bin/mvn', 'clean', 'verify'])
def finish(self): root = self.get_bindings_root_directory() # Copy IPConnection examples examples = common.find_examples(root, '^Example.*\.pas$') for example in examples: shutil.copy(example[1], '/tmp/generator/examples') # Copy bindings and readme for filename in released_files: shutil.copy(os.path.join(root, 'bindings', filename), '/tmp/generator/source') shutil.copy(os.path.join(root, 'Base58.pas'), '/tmp/generator/source') shutil.copy(os.path.join(root, 'BlockingQueue.pas'), '/tmp/generator/source') shutil.copy(os.path.join(root, 'DeviceBase.pas'), '/tmp/generator/source') shutil.copy(os.path.join(root, 'Device.pas'), '/tmp/generator/source') shutil.copy(os.path.join(root, 'IPConnection.pas'), '/tmp/generator/source') shutil.copy(os.path.join(root, 'LEConverter.pas'), '/tmp/generator/source') shutil.copy(os.path.join(root, 'TimedSemaphore.pas'), '/tmp/generator/source') shutil.copy(os.path.join(root, 'SHA1.pas'), '/tmp/generator/source') shutil.copy(os.path.join(root, 'BrickDaemon.pas'), '/tmp/generator/source') shutil.copy(os.path.join(root, 'changelog.txt'), '/tmp/generator/') shutil.copy(os.path.join(root, 'readme.txt'), '/tmp/generator/') # Make zip version = common.get_changelog_version(root) common.make_zip(self.get_bindings_name(), '/tmp/generator', root, version)
def generate(path): common.path_binding = path path_list = path.split('/') path_list[-1] = 'configs' path_config = '/'.join(path_list) sys.path.append(path_config) configs = os.listdir(path_config) # Make temporary generator directory if os.path.exists('/tmp/generator'): shutil.rmtree('/tmp/generator/') os.makedirs('/tmp/generator/bindings') os.chdir('/tmp/generator/bindings') # Copy examples common.import_and_make(configs, path, make_files) # Copy bindings and readme for filename in glob.glob(path + '/bindings/*.[ch]'): shutil.copy(filename, '/tmp/generator/bindings') shutil.copy(path + '/ip_connection.c', '/tmp/generator/bindings') shutil.copy(path + '/ip_connection.h', '/tmp/generator/bindings') shutil.copy(path + '/changelog.txt', '/tmp/generator/') shutil.copy(path + '/readme.txt', '/tmp/generator/') # Make zip version = common.get_changelog_version(path) common.make_zip('c', '/tmp/generator', path, version)
def get_python_import(self): include = """# -*- coding: utf-8 -*- {0}{1} try: from collections import namedtuple except ImportError: try: from .ip_connection import namedtuple except ValueError: from ip_connection import namedtuple try: from .ip_connection import Device, IPConnection, Error except ValueError: from ip_connection import Device, IPConnection, Error """ date = datetime.datetime.now().strftime("%Y-%m-%d") version = common.get_changelog_version( self.get_generator().get_bindings_root_directory()) released = '' if not self.is_released(): released = '\n#### __DEVICE_IS_NOT_RELEASED__ ####\n' return include.format(common.gen_text_hash.format(date, *version), released)
def finish(self): root = self.get_bindings_root_directory() # Copy IPConnection examples examples = common.find_examples(root, '^example_.*\.c$') for example in examples: shutil.copy(example[1], '/tmp/generator/examples') # Copy bindings and readme for filename in released_files: shutil.copy(os.path.join(root, 'bindings', filename), '/tmp/generator/source') shutil.copy(os.path.join(root, 'ip_connection.c'), '/tmp/generator/source') shutil.copy(os.path.join(root, 'ip_connection.h'), '/tmp/generator/source') shutil.copy(os.path.join(root, 'Makefile'), '/tmp/generator/source') shutil.copy(os.path.join(root, 'changelog.txt'), '/tmp/generator') shutil.copy(os.path.join(root, 'readme.txt'), '/tmp/generator') # Make zip version = common.get_changelog_version(root) common.make_zip(self.get_bindings_name(), '/tmp/generator', root, version)
def finish(self): root_dir = self.get_bindings_root_directory() # Copy IP Connection examples for example in common.find_examples(root_dir, '^Example.*\.pas$'): shutil.copy(example[1], self.tmp_examples_dir) # Copy bindings and readme for filename in released_files: shutil.copy(os.path.join(root_dir, 'bindings', filename), self.tmp_source_dir) shutil.copy(os.path.join(root_dir, 'Base58.pas'), self.tmp_source_dir) shutil.copy(os.path.join(root_dir, 'BlockingQueue.pas'), self.tmp_source_dir) 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, 'SHA1.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) # Make zip version = common.get_changelog_version(root_dir) common.make_zip(self.get_bindings_name(), self.tmp_dir, root_dir, version)
def get_java_import(self): if self.get_generator().is_octave(): include = """{0} package com.tinkerforge; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.concurrent.CopyOnWriteArrayList; import java.util.Arrays; import java.util.List; import org.octave.OctaveReference; """ else: include = """{0} package com.tinkerforge; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.concurrent.CopyOnWriteArrayList; import java.util.Arrays; import java.util.List; """ date = datetime.datetime.now().strftime("%Y-%m-%d") version = common.get_changelog_version( self.get_generator().get_bindings_root_directory()) return include.format(common.gen_text_star.format(date, *version))
def get_python_import(self): include = """# -*- coding: utf-8 -*- {0}{1} try: from collections import namedtuple except ImportError: try: from .ip_connection import namedtuple except ValueError: from ip_connection import namedtuple try: from .ip_connection import Device, IPConnection, Error except ValueError: from ip_connection import Device, IPConnection, Error """ date = datetime.datetime.now().strftime("%Y-%m-%d") version = common.get_changelog_version(self.get_generator().get_bindings_root_directory()) released = '' if not self.is_released(): released = '\n#### __DEVICE_IS_NOT_RELEASED__ ####\n' return include.format(common.gen_text_hash.format(date, *version), released)
def finish(self): root_dir = self.get_bindings_root_directory() # Copy IP Connection examples for example in common.find_examples(root_dir, '^Example.*\.vb$'): shutil.copy(example[1], self.tmp_examples_dir) # Copy bindings and readme for filename in released_files: shutil.copy(os.path.join(root_dir, 'bindings', filename), self.tmp_source_tinkerforge_dir) shutil.copy(os.path.join(root_dir, '..', 'csharp', 'IPConnection.cs'), self.tmp_source_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 AssemblyInfo.cs version = common.get_changelog_version(root_dir) common.specialize_template(os.path.join(root_dir, '..', 'csharp', 'AssemblyInfo.cs.template'), os.path.join(self.tmp_source_tinkerforge_dir, 'AssemblyInfo.cs'), {'<<BINDINGS>>': 'Visual Basic .NET', '<<VERSION>>': '.'.join(version)}) # Make dll with common.ChangedDirectory(self.tmp_dir): common.execute(['/usr/bin/gmcs', '/optimize', '/target:library', '/out:' + os.path.join(self.tmp_dir, 'Tinkerforge.dll'), '/doc:' + os.path.join(self.tmp_dir, 'Tinkerforge.xml'), os.path.join(self.tmp_source_tinkerforge_dir, '*.cs')]) # Make zip self.create_zip_file(self.tmp_dir)
def finish(self): root_dir = self.get_bindings_root_directory() # Copy IP Connection examples for example in common.find_examples(root_dir, '^example_.*\.pl$'): shutil.copy(example[1], self.tmp_examples_dir) # Copy bindings and readme for filename in released_files: shutil.copy(os.path.join(root_dir, 'bindings', filename), self.tmp_source_lib_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'IPConnection.pm'), self.tmp_source_lib_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'Device.pm'), self.tmp_source_lib_tinkerforge_dir) 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 = common.get_changelog_version(root_dir) 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 common.make_zip(self.get_bindings_name(), self.tmp_dir, root_dir, version)
def generate(path): # Make temporary generator directory if os.path.exists('/tmp/generator'): shutil.rmtree('/tmp/generator/') os.makedirs('/tmp/generator/bindings') os.chdir('/tmp/generator/bindings') # Copy examples common.generate(path, 'en', make_files, None, False) shutil.copy(common.path_binding.replace('/generators/delphi', '/doc/en/source/Software/Example.pas'), '/tmp/generator/examples/ExampleEnumerate.pas') # Copy bindings and readme for filename in glob.glob(path + '/bindings/*.pas'): shutil.copy(filename, '/tmp/generator/bindings') shutil.copy(path + '/Base58.pas', '/tmp/generator/bindings') shutil.copy(path + '/BlockingQueue.pas', '/tmp/generator/bindings') shutil.copy(path + '/Device.pas', '/tmp/generator/bindings') shutil.copy(path + '/IPConnection.pas', '/tmp/generator/bindings') shutil.copy(path + '/LEConverter.pas', '/tmp/generator/bindings') shutil.copy(path + '/TimedSemaphore.pas', '/tmp/generator/bindings') shutil.copy(path + '/changelog.txt', '/tmp/generator/') shutil.copy(path + '/readme.txt', '/tmp/generator/') # Make zip version = common.get_changelog_version(path) common.make_zip('delphi', '/tmp/generator', path, version)
def get_java_import(self): if self.get_generator().is_octave(): include = """{0} package com.tinkerforge; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.concurrent.CopyOnWriteArrayList; import java.util.Arrays; import java.util.List; import org.octave.OctaveReference; """ else: include = """{0} package com.tinkerforge; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.concurrent.CopyOnWriteArrayList; import java.util.Arrays; import java.util.List; """ date = datetime.datetime.now().strftime("%Y-%m-%d") version = common.get_changelog_version(self.get_generator().get_bindings_root_directory()) return include.format(common.gen_text_star.format(date, *version))
def make_files(com_new, directory): global device device = common.Device(com_new) file_name = '{0}_{1}'.format(device.get_category().lower(), device.get_underscore_name()) version = common.get_changelog_version(directory) directory += '/bindings' c = file('{0}/{1}.c'.format(directory, file_name), "w") c.write(make_include_c(version)) c.write(make_typedefs()) c.write(make_structs()) c.write(make_callback_wrapper_funcs()) c.write(make_create_func()) c.write(make_destroy_func()) c.write(make_response_expected_funcs()) c.write(make_register_callback_func()) c.write(make_method_funcs()) h = file('{0}/{1}.h'.format(directory, file_name), "w") h.write(make_include_h(version)) h.write(make_function_id_defines()) h.write(make_callback_defines()) h.write(make_constants()) h.write(make_device_identifier_define()) h.write(make_create_declaration()) h.write(make_destroy_declaration()) h.write(make_response_expected_declarations()) h.write(make_register_callback_declaration()) h.write(make_method_declarations()) h.write(make_end_h())
def generate(path): common.path_binding = path path_list = path.split('/') path_list[-1] = 'configs' path_config = '/'.join(path_list) sys.path.append(path_config) configs = os.listdir(path_config) # Make temporary generator directory if os.path.exists('/tmp/generator'): shutil.rmtree('/tmp/generator/') os.makedirs('/tmp/generator/bindings') os.chdir('/tmp/generator/bindings') # Copy examples common.import_and_make(configs, path, make_files) # Copy bindings and readme for filename in glob.glob(path + '/bindings/*.pas'): shutil.copy(filename, '/tmp/generator/bindings') shutil.copy(path + '/Base58.pas', '/tmp/generator/bindings') shutil.copy(path + '/BlockingQueue.pas', '/tmp/generator/bindings') shutil.copy(path + '/Device.pas', '/tmp/generator/bindings') shutil.copy(path + '/IPConnection.pas', '/tmp/generator/bindings') shutil.copy(path + '/LEConverter.pas', '/tmp/generator/bindings') shutil.copy(path + '/TimedSemaphore.pas', '/tmp/generator/bindings') shutil.copy(path + '/changelog.txt', '/tmp/generator/') shutil.copy(path + '/readme.txt', '/tmp/generator/') # Make zip version = common.get_changelog_version(path) common.make_zip('delphi', '/tmp/generator', path, version)
def finish(self): root_dir = self.get_bindings_root_directory() # Copy IP Connection examples for example in common.find_examples(root_dir, '^example_.*\.c$'): shutil.copy(example[1], self.tmp_examples_dir) # Copy bindings and readme for filename in released_files: shutil.copy(os.path.join(root_dir, 'bindings', filename), self.tmp_source_dir) shutil.copy(os.path.join(root_dir, 'ip_connection.c'), self.tmp_source_dir) shutil.copy(os.path.join(root_dir, 'ip_connection.h'), self.tmp_source_dir) shutil.copy(os.path.join(root_dir, 'Makefile'), 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 zip version = common.get_changelog_version(root_dir) common.make_zip(self.get_bindings_name(), self.tmp_dir, root_dir, version)
def finish(self): root_dir = self.get_bindings_root_directory() # Copy IP Connection examples for example in common.find_examples(root_dir, '^example_.*\.py$'): shutil.copy(example[1], self.tmp_examples_dir) # Copy bindings and readme for filename in released_files: shutil.copy(os.path.join(root_dir, 'bindings', filename), self.tmp_source_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'ip_connection.py'), self.tmp_source_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) # Make __init__.py file(os.path.join(self.tmp_source_tinkerforge_dir, '__init__.py'), 'wb').write(' ') # Make setup.py version = common.get_changelog_version(root_dir) common.specialize_template(os.path.join(root_dir, 'setup.py.template'), os.path.join(self.tmp_source_dir, 'setup.py'), {'<<VERSION>>': '.'.join(version)}) # Make zip common.make_zip(self.get_bindings_name(), self.tmp_dir, root_dir, version)
def generate(bindings_root_directory): tmp_dir = os.path.join(bindings_root_directory, 'maven_package') tmp_src_main_java_dir = os.path.join(tmp_dir, 'src', 'main', 'java') tmp_unzipped_dir = os.path.join(tmp_dir, 'unzipped') # Make directories common.recreate_directory(tmp_dir) os.makedirs(tmp_src_main_java_dir) # Unzip version = common.get_changelog_version(bindings_root_directory) common.execute(['/usr/bin/unzip', '-q', os.path.join(bindings_root_directory, 'tinkerforge_java_bindings_{0}_{1}_{2}.zip'.format(*version)), '-d', tmp_unzipped_dir]) # Copy source shutil.copytree(os.path.join(tmp_unzipped_dir, 'source', 'com'), os.path.join(tmp_src_main_java_dir, 'com')) # Make pom.xml common.specialize_template(os.path.join(bindings_root_directory, 'pom.xml.template'), os.path.join(tmp_dir, 'pom.xml'), {'{{VERSION}}': '.'.join(version)}) # Make package with common.ChangedDirectory(tmp_dir): common.execute(['/usr/bin/mvn', 'clean', 'verify'])
def get_c_include_h(self): include = """{0} #ifndef {1}_{2}_H #define {1}_{2}_H #include "ip_connection.h" #ifdef __cplusplus extern "C" {{ #endif /** * \defgroup {4}{3} {6} */ /** * \ingroup {4}{3} * * {5} */ typedef Device {3}; """ date = datetime.datetime.now().strftime("%Y-%m-%d") version = common.get_changelog_version(self.get_generator().get_bindings_root_directory()) upper_type = self.get_upper_case_category() upper_name = self.get_upper_case_name() return include.format(common.gen_text_star.format(date, *version), upper_type, upper_name, self.get_camel_case_name(), self.get_camel_case_category(), self.get_description(), self.get_long_display_name())
def finish(self): root = self.get_bindings_root_directory() # Copy IPConnection examples examples = common.find_examples(root, '^Example.*\.pas$') for example in examples: shutil.copy(example[1], '/tmp/generator/examples') # Copy bindings and readme for filename in released_files: shutil.copy(os.path.join(root, 'bindings', filename), '/tmp/generator/bindings') shutil.copy(os.path.join(root, 'Base58.pas'), '/tmp/generator/bindings') shutil.copy(os.path.join(root, 'BlockingQueue.pas'), '/tmp/generator/bindings') shutil.copy(os.path.join(root, 'DeviceBase.pas'), '/tmp/generator/bindings') shutil.copy(os.path.join(root, 'Device.pas'), '/tmp/generator/bindings') shutil.copy(os.path.join(root, 'IPConnection.pas'), '/tmp/generator/bindings') shutil.copy(os.path.join(root, 'LEConverter.pas'), '/tmp/generator/bindings') shutil.copy(os.path.join(root, 'TimedSemaphore.pas'), '/tmp/generator/bindings') shutil.copy(os.path.join(root, 'changelog.txt'), '/tmp/generator/') shutil.copy(os.path.join(root, 'readme.txt'), '/tmp/generator/') # Make zip version = common.get_changelog_version(root) common.make_zip(self.get_bindings_name(), '/tmp/generator', root, version)
def generate(path): global file_path file_path = path path_list = path.split('/') path_list[-1] = 'configs' path_config = '/'.join(path_list) sys.path.append(path_config) configs = os.listdir(path_config) # Make temporary generator directory if os.path.exists('/tmp/generator'): shutil.rmtree('/tmp/generator/') os.makedirs('/tmp/generator/bindings') os.chdir('/tmp/generator/bindings') for config in configs: if config.endswith('_config.py'): module = __import__(config[:-3]) print(" * {0}".format(config[:-10])) make_files(module.com, path) # Copy bindings and readme for filename in glob.glob(path + '/bindings/*.[ch]'): shutil.copy(filename, '/tmp/generator/bindings') shutil.copy(path + '/ip_connection.c', '/tmp/generator/bindings') shutil.copy(path + '/ip_connection.h', '/tmp/generator/bindings') shutil.copy(path + '/changelog.txt', '/tmp/generator/') shutil.copy(path + '/readme.txt', '/tmp/generator/') # Make zip version = common.get_changelog_version(path) common.make_zip('c', '/tmp/generator', path, version)
def finish(self): root_dir = self.get_bindings_root_directory() # Copy IP Connection examples for example in common.find_examples(root_dir, '^Example.*\.pas$'): shutil.copy(example[1], self.tmp_examples_dir) # Copy bindings and readme for filename in released_files: shutil.copy(os.path.join(root_dir, 'bindings', filename), self.tmp_source_dir) shutil.copy(os.path.join(root_dir, 'Base58.pas'), self.tmp_source_dir) shutil.copy(os.path.join(root_dir, 'BlockingQueue.pas'), self.tmp_source_dir) 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 = common.get_changelog_version(root_dir) 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 finish(self): root_dir = self.get_bindings_root_directory() # Copy IP Connection examples for example in common.find_examples(root_dir, '^Example.*\.java$'): shutil.copy(example[1], self.tmp_examples_dir) # Copy bindings and readme for filename in released_files + ['DeviceFactory.java']: shutil.copy(os.path.join(root_dir, 'bindings', filename), self.tmp_source_com_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'BrickDaemon.java'), self.tmp_source_com_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'Device.java'), self.tmp_source_com_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'DeviceBase.java'), self.tmp_source_com_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'DeviceListener.java'), self.tmp_source_com_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'IPConnection.java'), self.tmp_source_com_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'IPConnectionBase.java'), self.tmp_source_com_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'TinkerforgeException.java'), self.tmp_source_com_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'TimeoutException.java'), self.tmp_source_com_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'AlreadyConnectedException.java'), self.tmp_source_com_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'NotConnectedException.java'), self.tmp_source_com_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'CryptoException.java'), self.tmp_source_com_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'TinkerforgeListener.java'), self.tmp_source_com_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 manifest version = common.get_changelog_version(root_dir) with open(os.path.join(self.tmp_dir, 'manifest.txt'), 'wb') as f: f.write('Bindings-Version: {0}.{1}.{2}\n'.format(*version)) # Compile source with common.ChangedDirectory(self.tmp_dir): common.execute('/usr/bin/javac ' + '-Xlint ' + '-source 1.5 ' + '-target 1.5 ' + os.path.join(self.tmp_source_com_tinkerforge_dir, '*.java'), shell=True) # Make jar with common.ChangedDirectory(self.tmp_source_dir): common.execute(['/usr/bin/jar', 'cfm', os.path.join(self.tmp_dir, 'Tinkerforge.jar'), os.path.join(self.tmp_dir, 'manifest.txt'), 'com']) # Remove manifest os.remove(os.path.join(self.tmp_dir, 'manifest.txt')) # Remove classes for f in os.listdir(self.tmp_source_com_tinkerforge_dir): if f.endswith('.class'): os.remove(os.path.join(self.tmp_source_com_tinkerforge_dir, f)) # Make zip self.create_zip_file(self.tmp_dir)
def generate(root): version = common.get_changelog_version(root) maven_dir = os.path.join(root, 'maven-tmp') java_dir = os.path.join(maven_dir, 'src', 'main', 'java') unzipped_dir = os.path.join(maven_dir, 'unzipped') common.recreate_directory(maven_dir) os.makedirs(java_dir) shutil.copy('tinkerforge_java_bindings_{0}_{1}_{2}.zip'.format(*version), maven_dir) args = ['/usr/bin/unzip', '-q', 'tinkerforge_java_bindings_{0}_{1}_{2}.zip'.format(*version), '-d', unzipped_dir] if subprocess.call(args) != 0: raise Exception("Command '{0}' failed".format(' '.join(args))) shutil.copytree(os.path.join(unzipped_dir, 'source', 'com'), os.path.join(java_dir, 'com')) common.replace_in_file('pom.xml.template', os.path.join(maven_dir, 'pom.xml'), '{{VERSION}}', '.'.join(version)) with common.ChangedDirectory(maven_dir): args = ['/usr/bin/mvn', 'clean', 'verify'] if subprocess.call(args) != 0: raise Exception("Command '{0}' failed".format(' '.join(args)))
def finish(self): root_dir = self.get_bindings_root_directory() # Copy IP Connection examples for example in common.find_examples(root_dir, '^example_.*\.py$'): shutil.copy(example[1], self.tmp_examples_dir) # Copy bindings and readme for filename in released_files: shutil.copy(os.path.join(root_dir, 'bindings', filename), self.tmp_source_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'ip_connection.py'), self.tmp_source_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 __init__.py file(os.path.join(self.tmp_source_tinkerforge_dir, '__init__.py'), 'wb').write(' ') # Make setup.py version = common.get_changelog_version(root_dir) common.specialize_template( os.path.join(root_dir, 'setup.py.template'), os.path.join(self.tmp_source_dir, 'setup.py'), {'<<VERSION>>': '.'.join(version)}) # Make zip common.make_zip(self.get_bindings_name(), self.tmp_dir, root_dir, version)
def finish(self): root_dir = self.get_bindings_root_directory() # Copy IP Connection examples for example in common.find_examples(root_dir, '^example_.*\.rb$'): shutil.copy(example[1], self.tmp_examples_dir) # Copy bindings and readme for filename in released_files: shutil.copy(os.path.join(root_dir, 'bindings', filename), self.tmp_source_lib_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'ip_connection.rb'), 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 version.rb version = common.get_changelog_version(root_dir) file(os.path.join(self.tmp_source_lib_tinkerforge_dir, 'version.rb'), 'wb').write(""" module Tinkerforge VERSION = '{0}.{1}.{2}' end """.format(*version)) # Make tinkerforge.rb file(os.path.join(self.tmp_source_lib_dir, 'tinkerforge.rb'), 'wb').write(""" require 'tinkerforge/version' module Tinkerforge end """) # Make tinkerforge.gemspec tmp_gemspec = os.path.join(self.tmp_source_dir, 'tinkerforge.gemspec') common.specialize_template(os.path.join(root_dir, 'tinkerforge.gemspec.template'), tmp_gemspec, {'<<VERSION>>': '.'.join(version)}) # Make gem with common.ChangedDirectory(self.tmp_source_dir): args = ['/usr/bin/gem', 'build', 'tinkerforge.gemspec'] if subprocess.call(args) != 0: raise Exception("Command '{0}' failed".format(' '.join(args))) # Remove build stuff tmp_gem = os.path.join(self.tmp_source_dir, 'tinkerforge-{0}.{1}.{2}.gem'.format(*version)) os.remove(tmp_gemspec) shutil.copy(tmp_gem, root_dir) shutil.move(tmp_gem, os.path.join(self.tmp_dir, 'tinkerforge.gem')) shutil.move(os.path.join(self.tmp_source_lib_dir, 'tinkerforge.rb'), self.tmp_source_dir) shutil.move(self.tmp_source_lib_tinkerforge_dir, os.path.join(self.tmp_source_dir, 'tinkerforge')) shutil.rmtree(self.tmp_source_lib_dir) # Make zip common.make_zip(self.get_bindings_name(), self.tmp_dir, root_dir, version)
def generate(path): # Make temporary generator directory if os.path.exists('/tmp/generator'): shutil.rmtree('/tmp/generator/') os.makedirs('/tmp/generator/egg/source/tinkerforge') os.chdir('/tmp/generator') # Copy examples common.generate(path, 'en', make_files, None, False) shutil.copy(common.path_binding.replace('/generators/python', '/doc/en/source/Software/example.py'), '/tmp/generator/egg/examples/example_enumerate.py') # Copy bindings and readme for filename in glob.glob(path + '/bindings/*.py'): shutil.copy(filename, '/tmp/generator/egg/source/tinkerforge') shutil.copy(path + '/ip_connection.py', '/tmp/generator/egg/source/tinkerforge') shutil.copy(path + '/changelog.txt', '/tmp/generator/egg') shutil.copy(path + '/readme.txt', '/tmp/generator/egg') # Write setup.py version = common.get_changelog_version(path) file('/tmp/generator/egg/source/setup.py', 'wb').write(""" #!/usr/bin/env python from setuptools import setup setup(name='tinkerforge', version='{0}.{1}.{2}', description='TCP/IP based library for Bricks and Bricklets', author='Tinkerforge GmbH', author_email='*****@*****.**', url='http://www.tinkerforge.com', packages=['tinkerforge']) """.format(*version)) # Make egg os.chdir('/tmp/generator/egg/source') args = ['/usr/bin/python', 'setup.py', 'bdist_egg'] if subprocess.call(args) != 0: raise Exception("Command '{0}' failed".format(' '.join(args))) # Remove build stuff shutil.rmtree('/tmp/generator/egg/source/build') shutil.rmtree('/tmp/generator/egg/source/tinkerforge.egg-info') shutil.copy('/tmp/generator/egg/source/dist/' + os.listdir('/tmp/generator/egg/source/dist')[0], '/tmp/generator/egg/tinkerforge.egg') shutil.rmtree('/tmp/generator/egg/source/dist') # Make __init__.py f = open('/tmp/generator/egg/source/tinkerforge/__init__.py', 'w') f.write(' ') f.close() # Make zip common.make_zip('python', '/tmp/generator/egg', path, version)
def finish(self): root_dir = self.get_bindings_root_directory() # Copy IP Connection examples for example in common.find_examples(root_dir, '^Example.*\.cs$'): shutil.copy(example[1], self.tmp_examples_dir) # Copy bindings and readme for filename in released_files: shutil.copy(os.path.join(root_dir, 'bindings', filename), self.tmp_source_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'IPConnection.cs'), self.tmp_source_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'project.json'), self.tmp_source_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'project.lock.json'), self.tmp_source_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'TinkerforgeUWP.rd.xml'), self.tmp_source_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 AssemblyInfo.cs version = common.get_changelog_version(root_dir) common.specialize_template(os.path.join(root_dir, 'AssemblyInfo.cs.template'), os.path.join(self.tmp_source_tinkerforge_dir, 'AssemblyInfo.cs'), {'<<BINDINGS>>': 'C#', '<<VERSION>>': '.'.join(version)}) # Make Tinkerforge(UWP).csproj project_items = [] for filename in ['AssemblyInfo.cs', 'IPConnection.cs'] + released_files: project_items.append('<Compile Include="{0}" />'.format(filename)) common.specialize_template(os.path.join(root_dir, 'Tinkerforge.csproj.template'), os.path.join(self.tmp_source_tinkerforge_dir, 'Tinkerforge.csproj'), {'{{TOOLS_VERSION}}': '2.0', '{{ITEMS}}': '\n '.join(project_items)}) common.specialize_template(os.path.join(root_dir, 'TinkerforgeUWP.csproj.template'), os.path.join(self.tmp_source_tinkerforge_dir, 'TinkerforgeUWP.csproj'), {'{{ITEMS}}': '\n '.join(project_items)}) # Make dll with common.ChangedDirectory(self.tmp_source_tinkerforge_dir): common.execute(['xbuild', '/p:Configuration=Release', os.path.join(self.tmp_source_tinkerforge_dir, 'Tinkerforge.csproj')]) release_dir = os.path.join(self.tmp_source_tinkerforge_dir, 'bin', 'Release') shutil.copy(os.path.join(release_dir, 'Tinkerforge.dll'), self.tmp_dir) shutil.copy(os.path.join(release_dir, 'Tinkerforge.dll.mdb'), self.tmp_dir) shutil.copy(os.path.join(release_dir, 'Tinkerforge.xml'), self.tmp_dir) shutil.rmtree(os.path.join(self.tmp_source_tinkerforge_dir, 'bin')) shutil.rmtree(os.path.join(self.tmp_source_tinkerforge_dir, 'obj')) # Make zip self.create_zip_file(self.tmp_dir)
def get_javascript_require(self): date = datetime.datetime.now().strftime("%Y-%m-%d") version = common.get_changelog_version(self.get_generator().get_bindings_root_directory()) return """{0} var Device = require('./Device');\n {1}.DEVICE_IDENTIFIER = {2};\n""".format(common.gen_text_star.format(date, *version), self.get_javascript_class_name(), self.get_device_identifier())
def generate(path): global file_path file_path = path path_list = path.split('/') path_list[-1] = 'configs' path_config = '/'.join(path_list) sys.path.append(path_config) configs = os.listdir(path_config) # Make temporary generator directory if os.path.exists('/tmp/generator'): shutil.rmtree('/tmp/generator/') os.makedirs('/tmp/generator/dll/source/Tinkerforge') os.chdir('/tmp/generator') # Make bindings for config in configs: if config.endswith('_config.py'): module = __import__(config[:-3]) print(" * {0}".format(config[:-10])) make_files(module.com, path) # Copy bindings and readme for filename in glob.glob(path + '/bindings/*.cs'): shutil.copy(filename, '/tmp/generator/dll/source/Tinkerforge') shutil.copy(path + '/IPConnection.cs', '/tmp/generator/dll/source/Tinkerforge') shutil.copy(path + '/changelog.txt', '/tmp/generator/dll') shutil.copy(path + '/Readme.txt', '/tmp/generator/dll') # Write AssemblyInfo version = common.get_changelog_version(path) file('/tmp/generator/dll/source/Tinkerforge/AssemblyInfo.cs', 'wb').write(""" using System.Reflection; using System.Runtime.CompilerServices; [assembly: AssemblyTitle("C# API Bindings")] [assembly: AssemblyDescription("C# API Bindings for Tinkerforge Bricks and Bricklets")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Tinkerforge GmbH")] [assembly: AssemblyProduct("C# API Bindings")] [assembly: AssemblyCopyright("Tinkerforge GmbH 2011-2012")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: AssemblyVersion("{0}.{1}.{2}.0")] """.format(*version)) # Make dll args = ['/usr/bin/gmcs', '/optimize', '/target:library', '/out:/tmp/generator/dll/Tinkerforge.dll', '/doc:/tmp/generator/dll/Tinkerforge.xml', '/tmp/generator/dll/source/Tinkerforge/*.cs'] subprocess.call(args) # Make zip common.make_zip('csharp', '/tmp/generator/dll', path, version)
def generate(bindings_root_directory): tmp_dir = os.path.join(bindings_root_directory, 'cpan_package') tmp_unzipped_dir = os.path.join(tmp_dir, 'unzipped') tmp_unzipped_source_dir = os.path.join(tmp_unzipped_dir, 'source') tmp_unzipped_source_lib_dir = os.path.join(tmp_unzipped_source_dir, 'lib') tmp_cpan_dir = os.path.join(tmp_dir, 'cpan') tmp_cpan_lib_dir = os.path.join(tmp_cpan_dir, 'lib') # Make directories common.recreate_directory(tmp_dir) # Unzip version = common.get_changelog_version(bindings_root_directory) common.execute(['/usr/bin/unzip', '-q', os.path.join(bindings_root_directory, 'tinkerforge_perl_bindings_{0}_{1}_{2}.zip'.format(*version)), '-d', tmp_unzipped_dir]) # Make CPAN package structure modules = ['Tinkerforge', 'Tinkerforge::IPConnection', 'Tinkerforge::Device', 'Tinkerforge::Error'] for filename in released_files: modules.append('Tinkerforge::' + filename.replace('.pm', '')) common.execute(['module-starter', '--dir=' + tmp_cpan_dir, '--module=' + ','.join(modules), '--distro=Tinkerforge', '--author="Ishraq Ibne Ashraf"', '[email protected]']) # Make README common.specialize_template(os.path.join(bindings_root_directory, 'README.template'), os.path.join(tmp_cpan_dir, 'README'), {'<<VERSION>>': '.'.join(version)}) # Make Changes shutil.copy(os.path.join(tmp_unzipped_dir, 'changelog.txt'), os.path.join(tmp_cpan_dir, 'Changes')) # Copy Makefile.PL shutil.copy(os.path.join(tmp_unzipped_source_dir, 'Makefile.PL'), tmp_cpan_dir) # Copy source shutil.rmtree(tmp_cpan_lib_dir) shutil.copytree(os.path.join(tmp_unzipped_source_lib_dir), os.path.join(tmp_cpan_lib_dir)) # Make package with common.ChangedDirectory(tmp_cpan_dir): common.execute(['/usr/bin/perl', 'Makefile.PL']) common.execute(['make', 'dist']) shutil.copy(os.path.join(tmp_cpan_dir, 'Tinkerforge-{0}.{1}.{2}.tar.gz'.format(*version)), bindings_root_directory)
def finish(self): root = self.get_bindings_root_directory() # Copy IPConnection examples examples = common.find_examples(root, '^Example .*\.vi$') dest = os.path.join('/tmp/generator/dll/examples') dest_10 = os.path.join('/tmp/generator/dll/examples', '10.0') if not os.path.exists(dest): os.makedirs(dest) if not os.path.exists(dest_10): os.makedirs(dest_10) for example in examples: shutil.copy(example[1], dest) parts = os.path.split(example[1]) shutil.copy(os.path.join(parts[0], '10.0', parts[1]), dest_10) # Copy bindings and readme for filename in released_files: shutil.copy(os.path.join(root, 'bindings', filename), '/tmp/generator/dll/source/Tinkerforge') shutil.copy(os.path.join(root, '..', 'csharp', 'IPConnection.cs'), '/tmp/generator/dll/source/Tinkerforge') shutil.copy(os.path.join(root, 'changelog.txt'), '/tmp/generator/dll') shutil.copy(os.path.join(root, 'readme.txt'), '/tmp/generator/dll') # Write AssemblyInfo version = common.get_changelog_version(root) file('/tmp/generator/dll/source/Tinkerforge/AssemblyInfo.cs', 'wb').write(""" using System.Reflection; using System.Runtime.CompilerServices; [assembly: AssemblyTitle("LabVIEW API Bindings")] [assembly: AssemblyDescription("LabVIEW API Bindings for Tinkerforge Bricks and Bricklets")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Tinkerforge GmbH")] [assembly: AssemblyProduct("LabVIEW API Bindings")] [assembly: AssemblyCopyright("Tinkerforge GmbH 2011-2014")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: AssemblyVersion("{0}.{1}.{2}.0")] """.format(*version)) # Make dll with common.ChangedDirectory('/tmp/generator'): args = ['/usr/bin/gmcs', '/optimize', '/target:library', '/out:/tmp/generator/dll/Tinkerforge.dll', '/tmp/generator/dll/source/Tinkerforge/*.cs'] if subprocess.call(args) != 0: raise Exception("Command '{0}' failed".format(' '.join(args))) # Make zip common.make_zip(self.get_bindings_name(), '/tmp/generator/dll', root, version)
def get_javascript_require(self): date = datetime.datetime.now().strftime("%Y-%m-%d") version = common.get_changelog_version( self.get_generator().get_bindings_root_directory()) return """{0} var Device = require('./Device');\n {1}.DEVICE_IDENTIFIER = {2};\n""".format( common.gen_text_star.format(date, *version), self.get_javascript_class_name(), self.get_device_identifier())
def finish(self): root = self.get_bindings_root_directory() # Copy IPConnection examples examples = common.find_examples(root, '^Example.*\.java$') for example in examples: shutil.copy(example[1], '/tmp/generator/jar/examples') # Copy bindings and readme for filename in released_files: shutil.copy(os.path.join(root, 'bindings', filename), '/tmp/generator/jar/source/com/tinkerforge') shutil.copy(os.path.join(root, 'BrickDaemon.java'), '/tmp/generator/jar/source/com/tinkerforge') shutil.copy(os.path.join(root, 'Device.java'), '/tmp/generator/jar/source/com/tinkerforge') shutil.copy(os.path.join(root, 'DeviceBase.java'), '/tmp/generator/jar/source/com/tinkerforge') shutil.copy(os.path.join(root, 'DeviceListener.java'), '/tmp/generator/jar/source/com/tinkerforge') shutil.copy(os.path.join(root, 'IPConnection.java'), '/tmp/generator/jar/source/com/tinkerforge') shutil.copy(os.path.join(root, 'IPConnectionBase.java'), '/tmp/generator/jar/source/com/tinkerforge') shutil.copy(os.path.join(root, 'TinkerforgeException.java'), '/tmp/generator/jar/source/com/tinkerforge') shutil.copy(os.path.join(root, 'TimeoutException.java'), '/tmp/generator/jar/source/com/tinkerforge') shutil.copy(os.path.join(root, 'AlreadyConnectedException.java'), '/tmp/generator/jar/source/com/tinkerforge') shutil.copy(os.path.join(root, 'NotConnectedException.java'), '/tmp/generator/jar/source/com/tinkerforge') shutil.copy(os.path.join(root, 'CryptoException.java'), '/tmp/generator/jar/source/com/tinkerforge') shutil.copy(os.path.join(root, 'TinkerforgeListener.java'), '/tmp/generator/jar/source/com/tinkerforge') shutil.copy(os.path.join(root, 'changelog.txt'), '/tmp/generator/jar') shutil.copy(os.path.join(root, 'readme.txt'), '/tmp/generator/jar') # Make Manifest version = common.get_changelog_version(root) file('/tmp/generator/manifest.txt', 'wb').write('Bindings-Version: {0}.{1}.{2}\n'.format(*version)) # Make jar with common.ChangedDirectory('/tmp/generator'): args = ['/usr/bin/javac ' + '-Xlint ' + '-source 1.5 ' + '-target 1.5 ' + '/tmp/generator/jar/source/com/tinkerforge/*.java'] if subprocess.call(args, shell=True) != 0: raise Exception("Command '{0}' failed".format(' '.join(args))) with common.ChangedDirectory('/tmp/generator/jar/source'): args = ['/usr/bin/jar ' + 'cfm ' + '/tmp/generator/jar/Tinkerforge.jar ' + '/tmp/generator/manifest.txt ' + 'com'] if subprocess.call(args, shell=True) != 0: raise Exception("Command '{0}' failed".format(' '.join(args))) # Remove class for f in os.listdir('/tmp/generator/jar/source/com/tinkerforge/'): if f.endswith('.class'): os.remove('/tmp/generator/jar/source/com/tinkerforge/' + f) # Make zip common.make_zip(self.get_bindings_name(), '/tmp/generator/jar', root, version)
def finish(self): root_dir = self.get_bindings_root_directory() # Prepare toolbox XML file content file_content_xml_toolbox_brick = '' file_content_xml_toolbox_bricklet = '' for device in sorted(self.dict_brick_file_content_xml_toolbox_part): file_content_xml_toolbox_brick = file_content_xml_toolbox_brick + self.dict_brick_file_content_xml_toolbox_part[device] for device in sorted(self.dict_bricklet_file_content_xml_toolbox_part): file_content_xml_toolbox_bricklet = file_content_xml_toolbox_bricklet + self.dict_bricklet_file_content_xml_toolbox_part[device] # Write block definition file with open(os.path.join(self.path_dir_tmp_blocks, 'tinkerforge.js'), 'w') as fh_blocks: fh_blocks.write(self.file_content_append_block + self.file_content_block) # Write JavaScript generator file with open(os.path.join(self.path_dir_tmp_generators_javascript, 'tinkerforge.js'), 'w') as fh_generator_javascript: fh_generator_javascript.write(self.file_content_append_generator_javascript + self.file_content_generator_javascript) # Write Python generator file with open(os.path.join(self.path_dir_tmp_generators_python, 'tinkerforge.js'), 'w') as fh_generator_python: fh_generator_python.write(self.file_content_append_generator_python + self.file_content_generator_python) # Write toolbox XML file with open(os.path.join(root_dir, root_dir, 'tinkerforge', 'xml', self.file_name_xml_toolbox_part_merge_with), 'r') as fh_xml_toolbox_merge_with: file_content_xml_toolbox = '<xml id="toolboxTVPL">' + \ '<category name="Tinkerforge">' + \ '<category name="Bricks">' + \ file_content_xml_toolbox_brick + \ '</category>' + \ '<category name="Bricklets">' + \ file_content_xml_toolbox_bricklet + \ '</category>' + \ '</category>' + \ fh_xml_toolbox_merge_with.read() with open(os.path.join(self.path_dir_tmp_tinkerforge, 'xml', 'toolbox.xml'), 'w') as fh_xml_toolbox: fh_xml_toolbox.write('<!--\n' + common.gen_text_hash.format(self.date, *self.version) + \ '-->\n' + file_content_xml_toolbox.replace('\n', '')) # Compile with closure library previous_working_directory = os.getcwd() os.chdir(self.path_dir_tmp) args = ['python'] args.append(os.path.join(self.path_dir_tmp, 'build.py')) if subprocess.call(args) != 0: raise Exception("Command '{cmdarg}' failed".format(cmdarg = ' '.join(args))) os.chdir(previous_working_directory) # Make zip common.make_zip(self.get_bindings_name(), self.path_dir_tmp, root_dir, common.get_changelog_version(root_dir))
def get_csharp_import(self): include = """{0} using System; namespace Tinkerforge {{""" date = datetime.datetime.now().strftime("%Y-%m-%d") version = common.get_changelog_version(self.get_generator().get_bindings_root_directory()) return include.format(common.gen_text_star.format(date, *version))
def get_ruby_header(self): include = """# -*- ruby encoding: utf-8 -*- {0} """ date = datetime.datetime.now().strftime("%Y-%m-%d") version = common.get_changelog_version(self.get_generator().get_bindings_root_directory()) lower_type = self.get_category().lower() return include.format(common.gen_text_hash.format(date, *version), lower_type, self.get_underscore_name())
def get_php_import(self): include = """{0} namespace Tinkerforge; require_once(__DIR__ . '/IPConnection.php'); """ date = datetime.datetime.now().strftime("%Y-%m-%d") version = common.get_changelog_version(self.get_generator().get_bindings_root_directory()) return include.format(common.gen_text_star.format(date, *version))
def generate(path): # Make temporary generator directory if os.path.exists('/tmp/generator'): shutil.rmtree('/tmp/generator/') os.makedirs('/tmp/generator/jar/source/com/tinkerforge') os.chdir('/tmp/generator') # Copy examples common.generate(path, 'en', make_files, None, False) lines = [] for line in file(common.path_binding.replace('/generators/java', '/doc/en/source/Software/Example.java'), 'rb'): lines.append(line.replace('public class Example {', 'public class ExampleEnumerate {')) file('/tmp/generator/jar/examples/ExampleEnumerate.java', 'wb').writelines(lines) # Copy bindings and readme for filename in glob.glob(path + '/bindings/*.java'): shutil.copy(filename, '/tmp/generator/jar/source/com/tinkerforge') shutil.copy(path + '/Device.java', '/tmp/generator/jar/source/com/tinkerforge') shutil.copy(path + '/IPConnection.java', '/tmp/generator/jar/source/com/tinkerforge') shutil.copy(path + '/TinkerforgeException.java', '/tmp/generator/jar/source/com/tinkerforge') shutil.copy(path + '/TimeoutException.java', '/tmp/generator/jar/source/com/tinkerforge') shutil.copy(path + '/AlreadyConnectedException.java', '/tmp/generator/jar/source/com/tinkerforge') shutil.copy(path + '/NotConnectedException.java', '/tmp/generator/jar/source/com/tinkerforge') shutil.copy(path + '/changelog.txt', '/tmp/generator/jar') shutil.copy(path + '/Readme.txt', '/tmp/generator/jar') # Make Manifest version = common.get_changelog_version(path) file('/tmp/generator/manifest.txt', 'wb').write('Bindings-Version: {0}.{1}.{2}\n'.format(*version)) # Make jar args = ['/usr/bin/javac ' + '-Xlint ' + '/tmp/generator/jar/source/com/tinkerforge/*.java'] if subprocess.call(args, shell=True) != 0: raise Exception("Command '{0}' failed".format(' '.join(args))) os.chdir('/tmp/generator/jar/source') args = ['/usr/bin/jar ' + 'cfm ' + '/tmp/generator/jar/Tinkerforge.jar ' + '/tmp/generator/manifest.txt ' + 'com'] if subprocess.call(args, shell=True) != 0: raise Exception("Command '{0}' failed".format(' '.join(args))) # Remove class for f in os.listdir('/tmp/generator/jar/source/com/tinkerforge/'): if f.endswith('.class'): os.remove('/tmp/generator/jar/source/com/tinkerforge/' + f) # Make zip common.make_zip('java', '/tmp/generator/jar', path, version)
def get_ruby_header(self): include = """# -*- ruby encoding: utf-8 -*- {0} """ date = datetime.datetime.now().strftime("%Y-%m-%d") version = common.get_changelog_version( self.get_generator().get_bindings_root_directory()) lower_type = self.get_underscore_category() return include.format(common.gen_text_hash.format(date, *version), lower_type, self.get_underscore_name())
def get_csharp_import(self): include = """{0} using System; namespace Tinkerforge {{""" date = datetime.datetime.now().strftime("%Y-%m-%d") version = common.get_changelog_version( self.get_generator().get_bindings_root_directory()) return include.format(common.gen_text_star.format(date, *version))
def get_php_import(self): include = """{0} namespace Tinkerforge; require_once(__DIR__ . '/IPConnection.php'); """ date = datetime.datetime.now().strftime("%Y-%m-%d") version = common.get_changelog_version( self.get_generator().get_bindings_root_directory()) return include.format(common.gen_text_star.format(date, *version))
def finish(self): root_dir = self.get_bindings_root_directory() # Copy IP Connection examples for example in common.find_examples(root_dir, '^Example .*\.vi$'): shutil.copy(example[1], self.tmp_examples_dir) parts = os.path.split(example[1]) shutil.copy(os.path.join(parts[0], '10.0', parts[1]), self.tmp_examples_10_dir) # Copy bindings and readme for filename in released_files: shutil.copy(os.path.join(root_dir, 'bindings', filename), self.tmp_source_tinkerforge_dir) shutil.copy(os.path.join(root_dir, '..', 'csharp', 'IPConnection.cs'), self.tmp_source_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 AssemblyInfo.cs version = common.get_changelog_version(root_dir) common.specialize_template( os.path.join(root_dir, '..', 'csharp', 'AssemblyInfo.cs.template'), os.path.join(self.tmp_source_tinkerforge_dir, 'AssemblyInfo.cs'), { '<<BINDINGS>>': 'LabVIEW', '<<VERSION>>': '.'.join(version) }) # Make dll for sdk in [2, 4]: os.makedirs(os.path.join(self.tmp_dir, 'net{0}0'.format(sdk))) with common.ChangedDirectory(self.tmp_dir): args = [ '/usr/bin/gmcs', '/optimize', '/target:library', '/sdk:{0}'.format(sdk), '/out:' + os.path.join(self.tmp_dir, 'net{0}0'.format(sdk), 'Tinkerforge.dll'), os.path.join(self.tmp_source_tinkerforge_dir, '*.cs') ] if subprocess.call(args) != 0: raise Exception("Command '{0}' failed".format( ' '.join(args))) # Make zip common.make_zip(self.get_bindings_name(), self.tmp_dir, root_dir, version)
def finish(self): root = self.get_bindings_root_directory() # Copy IPConnection examples examples = common.find_examples(root, '^Example.*\.cs$') for example in examples: shutil.copy(example[1], '/tmp/generator/dll/examples') # Copy bindings and readme for filename in released_files: shutil.copy(os.path.join(root, 'bindings', filename), '/tmp/generator/dll/source/Tinkerforge') shutil.copy(os.path.join(root, 'IPConnection.cs'), '/tmp/generator/dll/source/Tinkerforge') shutil.copy(os.path.join(root, 'changelog.txt'), '/tmp/generator/dll') shutil.copy(os.path.join(root, 'readme.txt'), '/tmp/generator/dll') # Write AssemblyInfo version = common.get_changelog_version(root) file('/tmp/generator/dll/source/Tinkerforge/AssemblyInfo.cs', 'wb').write(""" using System.Reflection; using System.Runtime.CompilerServices; [assembly: AssemblyTitle("C# API Bindings")] [assembly: AssemblyDescription("C# API Bindings for Tinkerforge Bricks and Bricklets")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Tinkerforge GmbH")] [assembly: AssemblyProduct("C# API Bindings")] [assembly: AssemblyCopyright("Tinkerforge GmbH 2011-2013")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: AssemblyVersion("{0}.{1}.{2}.0")] """.format(*version)) # Make dll with common.ChangedDirectory('/tmp/generator'): args = [ '/usr/bin/gmcs', '/optimize', '/target:library', '/out:/tmp/generator/dll/Tinkerforge.dll', '/doc:/tmp/generator/dll/Tinkerforge.xml', '/tmp/generator/dll/source/Tinkerforge/*.cs' ] if subprocess.call(args) != 0: raise Exception("Command '{0}' failed".format(' '.join(args))) # Make zip common.make_zip(self.get_bindings_name(), '/tmp/generator/dll', root, version)
def finish(self): root_dir = self.get_bindings_root_directory() # Copy IP Connection examples for example in common.find_examples(root_dir, '^Example.*\.php$'): shutil.copy(example[1], self.tmp_examples_dir) # Copy bindings and readme package_files = [ '<file name="Tinkerforge/IPConnection.php" role="php" />' ] for filename in released_files: shutil.copy(os.path.join(root_dir, 'bindings', filename), self.tmp_source_tinkerforge_dir) package_files.append( '<file name="Tinkerforge/{0}" role="php" />'.format( os.path.basename(filename))) shutil.copy(os.path.join(root_dir, 'IPConnection.php'), self.tmp_source_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 package.xml version = common.get_changelog_version(root_dir) date = datetime.datetime.now().strftime("%Y-%m-%d") common.specialize_template( os.path.join(root_dir, 'package.xml.template'), os.path.join(self.tmp_source_dir, 'package.xml'), { '{{VERSION}}': '.'.join(version), '{{DATE}}': date, '{{FILES}}': '\n '.join(package_files) }) # Make PEAR package with common.ChangedDirectory(self.tmp_source_dir): common.execute(['/usr/bin/pear', 'package', 'package.xml']) # Remove build stuff shutil.move( os.path.join(self.tmp_source_dir, 'Tinkerforge-{0}.{1}.{2}.tgz'.format(*version)), os.path.join(self.tmp_dir, 'Tinkerforge.tgz')) os.remove(os.path.join(self.tmp_source_dir, 'package.xml')) # Make zip self.create_zip_file(self.tmp_dir)
def get_delphi_unit_header(self): include = """{0} unit {1}{2}; {{$ifdef FPC}}{{$mode OBJFPC}}{{$H+}}{{$endif}} interface uses Device, IPConnection, LEConverter; """ date = datetime.datetime.now().strftime("%Y-%m-%d") version = common.get_changelog_version( self.get_generator().get_bindings_root_directory()) return include.format(common.gen_text_curly.format(date, *version), self.get_category(), self.get_camel_case_name())
def finish(self): template = """{0} package com.tinkerforge; public class DeviceFactory {{ public static Device createDevice(int deviceIdentifier, String uid, IPConnection ipcon) throws Exception {{ return getDeviceClass(deviceIdentifier).getConstructor(String.class, IPConnection.class).newInstance(uid, ipcon); }} public static Class<? extends Device> getDeviceClass(int deviceIdentifier) {{ switch (deviceIdentifier) {{ {1} default: throw new IllegalArgumentException("Unknown device identifier: " + deviceIdentifier); }} }} }} """ date = datetime.datetime.now().strftime("%Y-%m-%d") version = common.get_changelog_version( self.get_bindings_root_directory()) classes = [] for name in sorted(self.device_factory_classes): classes.append( '\t\tcase {0}.DEVICE_IDENTIFIER: return {0}.class;'.format( name)) suffix = '' if self.is_matlab(): suffix = '_matlab' elif self.is_octave(): suffix = '_octave' java = open( os.path.join(self.get_bindings_root_directory(), 'bindings' + suffix, 'DeviceFactory.java'), 'wb') java.write( template.format(common.gen_text_star.format(date, *version), '\n'.join(classes))) java.close() return common.BindingsGenerator.finish(self)
def get_c_include_c(self): include = """{0} #define IPCON_EXPOSE_INTERNALS #include "{1}_{2}.h" #include <string.h> #ifdef __cplusplus extern "C" {{ #endif """ date = datetime.datetime.now().strftime("%Y-%m-%d") version = common.get_changelog_version(self.get_generator().get_bindings_root_directory()) return include.format(common.gen_text_star.format(date, *version), self.get_underscore_category(), self.get_underscore_name())
def finish(self): root_dir = self.get_bindings_root_directory() # Copy IP Connection examples for example in common.find_examples(root_dir, '^example-.*\.sh$'): shutil.copy(example[1], self.tmp_examples_dir) # Copy bindings and readme shutil.copy(os.path.join(root_dir, 'tinkerforge'), self.tmp_dir) shutil.copy(os.path.join(root_dir, 'tinkerforge-bash-completion.sh'), 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, '..', 'configs', 'license.txt'), self.tmp_dir) # Make zip version = common.get_changelog_version(root_dir) common.make_zip(self.get_bindings_name(), self.tmp_dir, root_dir, version)
def get_perl_package(self): package = """ {0} =pod =encoding utf8 =head1 NAME Tinkerforge::{1}{2} - {3} =cut package Tinkerforge::{1}{2}; """ date = datetime.datetime.now().strftime("%Y-%m-%d") version = common.get_changelog_version(self.get_generator().get_bindings_root_directory()) return package.format(common.gen_text_hash.format(date, *version), self.get_category(), self.get_camel_case_name(), self.get_description())
def generate(bindings_root_directory): tmp_dir = os.path.join(bindings_root_directory, 'maven_package') tmp_src_main_java_dir = os.path.join(tmp_dir, 'src', 'main', 'java') tmp_unzipped_dir = os.path.join(tmp_dir, 'unzipped') # Make directories common.recreate_directory(tmp_dir) os.makedirs(tmp_src_main_java_dir) # Unzip version = common.get_changelog_version(bindings_root_directory) args = ['/usr/bin/unzip', '-q', os.path.join(bindings_root_directory, 'tinkerforge_java_bindings_{0}_{1}_{2}.zip'.format(*version)), '-d', tmp_unzipped_dir] if subprocess.call(args) != 0: raise Exception("Command '{0}' failed".format(' '.join(args))) # Copy source shutil.copytree(os.path.join(tmp_unzipped_dir, 'source', 'com'), os.path.join(tmp_src_main_java_dir, 'com')) # Make pom.xml common.specialize_template(os.path.join(bindings_root_directory, 'pom.xml.template'), os.path.join(tmp_dir, 'pom.xml'), {'{{VERSION}}': '.'.join(version)}) # Make package with common.ChangedDirectory(tmp_dir): args = ['/usr/bin/mvn', 'clean', 'verify'] if subprocess.call(args) != 0: raise Exception("Command '{0}' failed".format(' '.join(args)))
def get_python_import(self): include = """# -*- coding: utf-8 -*- {0} try: from collections import namedtuple except ImportError: try: from .ip_connection import namedtuple except ValueError: from ip_connection import namedtuple try: from .ip_connection import Device, IPConnection, Error except ValueError: from ip_connection import Device, IPConnection, Error """ date = datetime.datetime.now().strftime("%Y-%m-%d") version = common.get_changelog_version( self.get_generator().get_bindings_root_directory()) lower_type = self.get_category().lower() return include.format(common.gen_text_hash.format(date, *version), lower_type, self.get_underscore_name())
def finish(self): root_dir = self.get_bindings_root_directory() # Copy IP Connection examples for example in common.find_examples(root_dir, '^Example.*\.java$'): shutil.copy(example[1], self.tmp_examples_dir) # Copy bindings and readme for filename in released_files: shutil.copy(os.path.join(root_dir, 'bindings', filename), self.tmp_source_com_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'BrickDaemon.java'), self.tmp_source_com_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'Device.java'), self.tmp_source_com_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'DeviceBase.java'), self.tmp_source_com_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'DeviceListener.java'), self.tmp_source_com_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'IPConnection.java'), self.tmp_source_com_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'IPConnectionBase.java'), self.tmp_source_com_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'TinkerforgeException.java'), self.tmp_source_com_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'TimeoutException.java'), self.tmp_source_com_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'AlreadyConnectedException.java'), self.tmp_source_com_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'NotConnectedException.java'), self.tmp_source_com_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'CryptoException.java'), self.tmp_source_com_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'TinkerforgeListener.java'), self.tmp_source_com_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 manifest version = common.get_changelog_version(root_dir) file(os.path.join(self.tmp_dir, 'manifest.txt'), 'wb').write('Bindings-Version: {0}.{1}.{2}\n'.format(*version)) # Compile source with common.ChangedDirectory(self.tmp_dir): args = [ '/usr/bin/javac ' + '-Xlint ' + '-source 1.5 ' + '-target 1.5 ' + os.path.join(self.tmp_source_com_tinkerforge_dir, '*.java') ] if subprocess.call(args, shell=True) != 0: raise Exception("Command '{0}' failed".format(' '.join(args))) # Make jar with common.ChangedDirectory(self.tmp_source_dir): args = [ '/usr/bin/jar ' + 'cfm ' + os.path.join(self.tmp_dir, 'Tinkerforge.jar') + ' ' + os.path.join(self.tmp_dir, 'manifest.txt') + ' ' + 'com' ] if subprocess.call(args, shell=True) != 0: raise Exception("Command '{0}' failed".format(' '.join(args))) # Remove manifest os.remove(os.path.join(self.tmp_dir, 'manifest.txt')) # Remove classes for f in os.listdir(self.tmp_source_com_tinkerforge_dir): if f.endswith('.class'): os.remove(os.path.join(self.tmp_source_com_tinkerforge_dir, f)) # Make zip common.make_zip(self.get_bindings_name(), self.tmp_dir, root_dir, version)
def finish(self): root_dir = self.get_bindings_root_directory() # Copy IP Connection examples for example in common.find_examples(root_dir, '^Example.*\.js'): shutil.copy(example[1], self.tmp_nodejs_examples_dir) for example in common.find_examples(root_dir, '^Example.*\.html'): shutil.copy(example[1], self.tmp_browser_examples_dir) # Copy bindings and readme for filename in released_files: if filename == 'TinkerforgeNPM.js': shutil.copy( os.path.join(root_dir, 'bindings', filename), os.path.join(self.tmp_nodejs_package_dir, 'Tinkerforge.js')) elif filename == 'BrowserAPI.js': shutil.copy(os.path.join(root_dir, 'bindings', filename), self.tmp_nodejs_source_tinkerforge_dir) elif filename == 'TinkerforgeSource.js': shutil.copy( os.path.join(root_dir, 'bindings', filename), os.path.join(self.tmp_nodejs_source_dir, 'Tinkerforge.js')) else: shutil.copy(os.path.join(root_dir, 'bindings', filename), self.tmp_nodejs_source_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'bindings', filename), self.tmp_nodejs_package_lib_dir) # Make package.json version = common.get_changelog_version(root_dir) common.specialize_template( os.path.join(root_dir, 'package.json.template'), os.path.join(self.tmp_nodejs_package_dir, 'package.json'), {'<<VERSION>>': '.'.join(version)}) shutil.copy(os.path.join(root_dir, 'IPConnection.js'), self.tmp_nodejs_package_lib_dir) shutil.copy(os.path.join(root_dir, 'Device.js'), self.tmp_nodejs_package_lib_dir) shutil.copy(os.path.join(root_dir, 'LICENSE'), self.tmp_nodejs_package_dir) shutil.copy(os.path.join(root_dir, 'README.md'), self.tmp_nodejs_package_dir) shutil.copy(os.path.join(root_dir, 'IPConnection.js'), self.tmp_nodejs_source_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'Device.js'), self.tmp_nodejs_source_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) # Copy browser specific files shutil.copy(os.path.join(root_dir, 'es5-shim.js'), self.tmp_nodejs_source_tinkerforge_dir) shutil.copy(os.path.join(root_dir, 'es5-sham.js'), self.tmp_nodejs_source_tinkerforge_dir) # Make Tinkerforge.js for browser with browserify with common.ChangedDirectory(self.tmp_nodejs_source_tinkerforge_dir): args = ['browserify'] args.extend( sorted(os.listdir(self.tmp_nodejs_source_tinkerforge_dir))) args.append('-o') args.append( os.path.join(self.tmp_browser_source_dir, 'Tinkerforge.js')) if subprocess.call(args) != 0: raise Exception("Command '{0}' failed".format(' '.join(args))) # Remove browser specific files os.remove( os.path.join(self.tmp_nodejs_source_tinkerforge_dir, 'BrowserAPI.js')) os.remove( os.path.join(self.tmp_nodejs_source_tinkerforge_dir, 'es5-shim.js')) os.remove( os.path.join(self.tmp_nodejs_source_tinkerforge_dir, 'es5-sham.js')) # Generate the NPM package and put it on the root of ZIP archive with common.ChangedDirectory(self.tmp_nodejs_package_dir): if subprocess.call('npm pack', shell=True) != 0: raise Exception("Command 'npm pack' failed") package_name = 'tinkerforge-{0}.{1}.{2}.tgz'.format(*version) shutil.copy(os.path.join(self.tmp_nodejs_package_dir, package_name), os.path.join(self.tmp_nodejs_dir, 'tinkerforge.tgz')) shutil.copy(os.path.join(self.tmp_nodejs_package_dir, package_name), os.path.join(root_dir, package_name)) # Remove package directory shutil.rmtree(self.tmp_nodejs_package_dir) # Make zip version = common.get_changelog_version(root_dir) common.make_zip(self.get_bindings_name(), self.tmp_dir, root_dir, version) # copy Tinkerforge.js to bindings root dir so copy_all.py can pick it up shutil.copy( os.path.join(self.tmp_browser_source_dir, 'Tinkerforge.js'), root_dir)