Beispiel #1
0
def create(args):
    """Process arguments and create the XPI"""

    parser = OptionParser()
    parser.add_option("--force",
                      dest="force",
                      help="force overwrite output file if exists",
                      action="store_true",
                      default=False)
    opts, args = parser.parse_args(args)

    patterns = FILES

    if len(args) != 1:
        raise ValueError("No distinct XPI name provided")
    output = args[0]

    if not opts.force and os.path.exists(output):
        raise ValueError("Output file already exists")

    build_sandboxes()
    build_plugins()

    with BytesIO() as buf:
        with Reset(buf):
            pack(buf, patterns, **opts.__dict__)

        with open(output, "wb") as outp:
            outp.write(buf.read())
Beispiel #2
0
def create(args):
    """Process arguments and create the XPI"""

    parser = OptionParser()
    parser.add_option("--force",
                      dest="force",
                      help="force overwrite output file if exists",
                      action="store_true",
                      default=False)
    opts, args = parser.parse_args(args)

    patterns = FILES

    if len(args) != 1:
        raise ValueError("No distinct XPI name provided")
    output = args[0]

    if not opts.force and os.path.exists(output):
        raise ValueError("Output file already exists")

    build_sandboxes()
    build_plugins()

    with BytesIO() as buf:
        with Reset(buf):
            pack(buf, patterns, **opts.__dict__)

        with open(output, "wb") as outp:
            outp.write(buf.read())
Beispiel #3
0
                hosters = plugin["hosters"]
                del plugin["hosters"]
                for h in hosters:
                    p = deepcopy(plugin)
                    p.update(h)
                    plugins.append(p)
                    filters.append(p['match'])
            else:
                plugins.append(plugin)
                filters.append(plugin['match'])
        except IOError as ex:
            print('Could not open file {0}: {1}'.format(name, ex),
                  file=sys.stderr)
            sys.exit(1)
        except ValueError as ex:
            print('Could not load JSON from file {0}: {1}'.format(
                name, *ex.args),
                  file=sys.stderr)
            sys.exit(1)

    print('Writing {} combined plugins.'.format(len(plugins)))
    with open(os.path.join(base, '../modules/plugins.json'), 'w') as outp:
        json.dump(plugins, outp)


if __name__ == "__main__":
    from build_sandboxes import build_sandboxes
    build_sandboxes()
    build_plugins()
    sys.exit(0)
    base = os.path.split(__file__)[0]

    for fileName in sorted(glob(os.path.join(base, '../plugins/*.json'))):
        try:
            with open(fileName, 'rb') as f:
                content = f.read().decode('utf-8')
                plugin = json.loads(content)
                plugin['date'] = int(os.path.getmtime(fileName) * 1000)

                plugins.append(plugin)
                filters.append(plugin['match'])
        except IOError as e:
            print('Could not open file {0}: {1}'.format(fileName, e),
                  file=sys.stderr)
            sys.exit(1)
        except ValueError as e:
            print('Could not load JSON from file {0}: {1}'.format(fileName,
                                                                  *e.args),
                  file=sys.stderr)
            sys.exit(1)

    print('Writing {} combined plugins.'.format(len(plugins)))
    with open(os.path.join(base, '../modules/plugins.json'), 'w') as f:
        json.dump(plugins, f)

if __name__ == "__main__":
    from build_sandboxes import build_sandboxes
    build_sandboxes()
    build_plugins()
    sys.exit(0)