示例#1
0
    def run(self, config_path=None):
        if self.console.arguments:
            config_path = abspath(join('.', self.console.arguments[-1]))

        if not config_path:
            config_path = abspath(join(os.curdir, 'www', 'config.xml'))

        if not exists(config_path):
            print 'The configuration file %s was not found!' % config_path
            sys.exit(1)

        try:
            values = ReadConfigCommand.get_values(config_path)
        except ExpatError:
            print 'The configuration file at %s is not well formed!' % config_path
            sys.exit(1)

        if 'id' not in values or not values['id']:
            print 'The configuration file at %s is missing an id attribute!' % config_path
            sys.exit(1)

        if 'name' not in values or not values['name']:
            print 'The configuration file at %s is missing a name attribute!' % config_path
            sys.exit(1)

        if 'version' not in values or not values['version']:
            print 'The configuration file at %s is missing a version attribute!' % config_path
            sys.exit(1)
示例#2
0
    def run(self, config_path=None):
        if self.console.arguments:
            config_path = abspath(join('.', self.console.arguments[-1]))

        if not config_path:
            config_path = abspath(join(os.curdir, 'www', 'config.xml'))

        if not exists(config_path):
            print 'The configuration file %s was not found!' % config_path
            sys.exit(1)

        try:
            values = ReadConfigCommand.get_values(config_path)
        except ExpatError:
            print 'The configuration file at %s is not well formed!' % config_path
            sys.exit(1)

        if 'id' not in values or not values['id']:
            print 'The configuration file at %s is missing an id attribute!' % config_path
            sys.exit(1)

        if 'name' not in values or not values['name']:
            print 'The configuration file at %s is missing a name attribute!' % config_path
            sys.exit(1)

        if 'version' not in values or not values['version']:
            print 'The configuration file at %s is missing a version attribute!' % config_path
            sys.exit(1)
示例#3
0
    def run(self, config_path=None, index_path=None):
        if self.console.arguments and self.console.arguments[-1].endswith(
                'index.html'):
            index_path = abspath(join('.', self.console.arguments.pop()))

        if self.console.arguments and self.console.arguments[-1].endswith(
                'config.xml'):
            config_path = abspath(join('.', self.console.arguments.pop()))

        if not config_path:
            config_path = abspath(join(os.curdir, 'www', 'config.xml'))

        if not index_path:
            index_path = abspath(join(os.curdir, 'www', 'index.html'))

        if not exists(config_path):
            print 'The configuration file %s was not found!' % config_path
            sys.exit(1)

        if not exists(index_path):
            print 'The main PhoneGap file %s was not found!' % config_path
            sys.exit(1)

        values = ReadConfigCommand.get_values(config_path)

        expr = '<div id="version">.*?</div>'
        new_version = '<div id="version">' + values['version'] + '</div>'

        reader = open(index_path, 'r')
        index = reader.read()
        match = re.search(expr, index)

        if match:
            tmp = re.sub(expr, new_version, index)
        else:
            tmp = index.replace('</body>', new_version + '</body>')

        reader.close()

        writer = open(index_path, 'w')
        writer.write(tmp)
        writer.close()
示例#4
0
    def run(self, config_path=None, index_path=None):
        if self.console.arguments and self.console.arguments[-1].endswith('index.html'):
            index_path = abspath(join('.', self.console.arguments.pop()))

        if self.console.arguments and self.console.arguments[-1].endswith('config.xml'):
            config_path = abspath(join('.', self.console.arguments.pop()))

        if not config_path:
            config_path = abspath(join(os.curdir, 'www', 'config.xml'))

        if not index_path:
            index_path = abspath(join(os.curdir, 'www', 'index.html'))

        if not exists(config_path):
            print 'The configuration file %s was not found!' % config_path
            sys.exit(1)

        if not exists(index_path):
            print 'The main PhoneGap file %s was not found!' % config_path
            sys.exit(1)

        values = ReadConfigCommand.get_values(config_path)

        expr = '<div id="version">.*?</div>'
        new_version = '<div id="version">' + values['version'] + '</div>'

        reader = open(index_path, 'r')
        index = reader.read()
        match = re.search(expr, index)

        if match:
            tmp = re.sub(expr, new_version, index)
        else:
            tmp = index.replace('</body>', new_version + '</body>')

        reader.close()

        writer = open(index_path, 'w')
        writer.write(tmp)
        writer.close()