def _copy_extension_files(self, info, src, dst, extension_key, ignore):
        if not os.path.exists(dst):
            os.makedirs(dst)

        # copy common files
        copy_dir_contents(os.path.join(src, 'common'), dst, ignore=ignore)
        info.load(os.path.join(src, 'common', self.EXTENSION_INFO_NAME))

        # copy browser specific files
        names = os.listdir(src)
        names.sort(lambda x, y: cmp(y.count(' '), x.count(' ')))
        merger = DirectoryMerger()
        for name in names:
            if extension_key in name:
                info.load(os.path.join(src, name, self.EXTENSION_INFO_NAME))
                merger.merge(os.path.join(src, name), dst, ignore)
Ejemplo n.º 2
0
    def _copy_extension_files(self, info, src, dst, extension_key, ignore):
        if not os.path.exists(dst):
            os.makedirs(dst)

        # copy common files
        copy_dir_contents(os.path.join(src, 'common'), dst, ignore=ignore)
        info.load(os.path.join(src, 'common', self.EXTENSION_INFO_NAME))

        # copy browser specific files
        names = os.listdir(src)
        names.sort(lambda x, y: cmp(y.count(' '), x.count(' ')))
        merger = DirectoryMerger()
        for name in names:
            if extension_key in name:
                info.load(os.path.join(src, name, self.EXTENSION_INFO_NAME))
                merger.merge(os.path.join(src, name), dst, ignore)
Ejemplo n.º 3
0
    def create(self, project_directory, project_name):
        if project_directory == sys.path[0]:
            die('You must set project directory')

        if project_name is None:
            print 'Input project name: ',
            project_name = sys.stdin.readline()[:-1]

        logger.info('Creating project...')

        template_path = os.path.join(self.templates_directory,
                                     'browser_button')

        self._create_dir(project_directory)

        src_dir = os.path.join(project_directory, 'src')

        self._create_dir(os.path.join(src_dir, 'common'))
        self._create_dir(os.path.join(project_directory, 'certificates'))

        copy_dir_contents(template_path, src_dir)
        copy_dir_contents(
            os.path.join(sys.path[0], 'src', 'js', 'common', 'icons'),
            os.path.join(src_dir, 'common', 'icons'))

        info = ExtensionInfo()
        info_path = os.path.join(src_dir, 'common', self._extension_info_name)
        info.load(info_path)
        info.name = project_name
        info.save(info_path)

        self._create_extension_info(os.path.join(src_dir, 'firefox'),
                                    {'id': self.generate_uuid()})

        if self.opennssl_available():
            try:
                self._generate_private_key(
                    os.path.join(project_directory, 'certificates/chrome.pem'))
                self._create_extension_info(
                    os.path.join(src_dir, 'chrome'), {
                        'id':
                        self.get_chrome_extension_id(
                            os.path.join(project_directory,
                                         'certificates/chrome.pem'))
                    })
            except:
                logger.warning(
                    'OpenSSL found but failed to generate chrome extension id. Please set your Chrome extension id manually'
                )
        else:
            logger.warning(
                'OpenSSL not found, please set your Chrome extension id manually'
            )
            self._create_extension_info(os.path.join(src_dir, 'chrome'),
                                        {'id': self.generate_uuid()})

        bho_clsid = self.generate_uuid()
        toolbar_clsid = self.generate_uuid()
        engine_clsid = self.generate_uuid()

        self._create_extension_info(
            os.path.join(src_dir, 'ie'), {
                'id': bho_clsid,
                'com_objects': {
                    'bho': {
                        'clsid':
                        bho_clsid,
                        'iid':
                        self.get_iid_from_id(
                            '{06E7211D-0650-43CF-8498-4C81E83AEAAA}',
                            bho_clsid),
                        'libid':
                        self.generate_uuid()
                    },
                    'toolbar': {
                        'clsid':
                        toolbar_clsid,
                        'iid':
                        self.get_iid_from_id(
                            '{A0207057-3461-4F7F-B689-D016B7A03964}',
                            toolbar_clsid)
                    },
                    'engine': {
                        'clsid':
                        engine_clsid,
                        'iid':
                        self.get_iid_from_id(
                            '{06ADA96E-5E8C-4550-BEBF-141EFD188227}',
                            engine_clsid),
                        'libid':
                        self.generate_uuid()
                    }
                }
            })

        self._create_extension_info(
            os.path.join(src_dir, 'safari'), {
                'id':
                'com.kangoextensions.' +
                get_prefix_from_name(project_name).lower(),
                'developer_id':
                'YOUR_SAFARI_DEVELOPER_ID'
            })

        logger.info('Project created in directory %s' %
                    os.path.abspath(project_directory))
Ejemplo n.º 4
0
    def create(self, project_directory, project_name):
        if project_directory == sys.path[0]:
            die('You must set project directory')

        if project_name is None:
            print 'Input project name: ',
            project_name = sys.stdin.readline()[:-1]

        logger.info('Creating project...')

        template_path = os.path.join(self.templates_directory, 'browser_button')

        self._create_dir(project_directory)

        src_dir = os.path.join(project_directory, 'src')

        self._create_dir(os.path.join(src_dir, 'common'))
        self._create_dir(os.path.join(project_directory, 'certificates'))

        copy_dir_contents(template_path, src_dir)
        copy_dir_contents(os.path.join(sys.path[0], 'src', 'js', 'common', 'icons'), os.path.join(src_dir, 'common', 'icons'))

        info = ExtensionInfo()
        info_path = os.path.join(src_dir, 'common', self._extension_info_name)
        info.load(info_path)
        info.name = project_name
        info.save(info_path)

        self._create_extension_info(os.path.join(src_dir, 'firefox'), {'id': self.generate_uuid()})

        if self.opennssl_available():
            try:
                self._generate_private_key(os.path.join(project_directory, 'certificates/chrome.pem'))
                self._create_extension_info(os.path.join(src_dir, 'chrome'), {'id': self.get_chrome_extension_id(os.path.join(project_directory, 'certificates/chrome.pem'))})
            except:
                logger.warning('OpenSSL found but failed to generate chrome extension id. Please set your Chrome extension id manually')
        else:
            logger.warning('OpenSSL not found, please set your Chrome extension id manually')
            self._create_extension_info(os.path.join(src_dir, 'chrome'), {'id': self.generate_uuid()})

        bho_clsid = self.generate_uuid()
        toolbar_clsid = self.generate_uuid()
        engine_clsid = self.generate_uuid()

        self._create_extension_info(os.path.join(src_dir, 'ie'), {
            'id': bho_clsid,
            'com_objects': {
                'bho': {
                    'clsid': bho_clsid,
                    'iid': self.get_iid_from_id('{06E7211D-0650-43CF-8498-4C81E83AEAAA}', bho_clsid),
                    'libid': self.generate_uuid()
                },
                'toolbar': {
                    'clsid': toolbar_clsid,
                    'iid': self.get_iid_from_id('{A0207057-3461-4F7F-B689-D016B7A03964}', toolbar_clsid)
                },
                'engine': {
                    'clsid': engine_clsid,
                    'iid': self.get_iid_from_id('{06ADA96E-5E8C-4550-BEBF-141EFD188227}', engine_clsid),
                    'libid': self.generate_uuid()
                }
            }
        })

        self._create_extension_info(os.path.join(src_dir, 'safari'), {
            'id': 'com.kangoextensions.' + get_prefix_from_name(project_name).lower(),
            'developer_id': 'YOUR_SAFARI_DEVELOPER_ID'
        })

        logger.info('Project created in directory %s' % os.path.abspath(project_directory))