# Path: modsdk/webserver.py
# def make_application(port=PORT, output_log=False):
#     application = web.Application([
#             (r"/bundles", BundleList),
#             (r"/effects", EffectList),
#             (r"/effect/get/", EffectGet),
#             (r"/effect/image/(screenshot|thumbnail).png", EffectImage),
#             (r"/effect/file/(.*)", EffectFile),
#             (r"/effect/save", EffectSave),
#             (r"/config/get", ConfigurationGet),
#             (r"/config/set", ConfigurationSet),
#             (r"/(icon.html)?", Index),
#             (r"/screenshot", Screenshot),
#             (r"/post/(.+)/?", BundlePost),
#             (r"/js/templates.js$", BulkTemplateLoader),
#             (r"/resources/(.*)", EffectResource),
#             (r"/monitor", BundleMonitorWebsocket),
#             (r"/(.*)", web.StaticFileHandler, {"path": HTML_DIR}),
#             ], debug=output_log)
# 
#     application.listen(port, address="0.0.0.0")
#     if output_log:
#         options.parse_command_line()
# 
#     return ioloop.IOLoop.instance()
# 
# def lv2_init():
#     global _W
#     _W = lilv.World()
#     _W.load_all()
#     lv2_init2()
# 
# def lv2_cleanup():
#     global _W
#     _W = None
#     lv2_cleanup2()
# 
# def get_bundle_plugins(bundle):
#     return [get_plugin_info(p['uri']) for p in get_bundle_plugins2(bundle)]
# 
# def get_plugin_info(uri):
#     global _W
#     ps = _W.get_all_plugins()
#     pn = _W.new_uri(uri)
#     pl = ps.get_by_uri(pn)
#     return get_plugin_info2(_W, pl, True)


import os, glob, subprocess, random, argparse
from PIL import Image
from modsdk.settings import (ROOT, PHANTOM_BINARY, SCREENSHOT_SCRIPT,
                             MAX_THUMB_WIDTH, MAX_THUMB_HEIGHT)
from modsdk.webserver import (make_application,
                              lv2_init, lv2_cleanup,
                              get_bundle_plugins,
                              get_plugin_info)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


#maximum width and height
WIDTH = 1920
HEIGHT = 1080

# port used for the temporary webserver
PORT = 9123

class BundleQueue(object):
    def __init__(self, bundles):
        bundles = [os.path.abspath(b) for b in bundles]

        # make a list of plugin info related to our bundles
        self.bundles_info = dict((b, []) for b in bundles)

        # load info from all the bundles
        loaded_bundles = []

        for bundle in bundles:
            plugins = get_bundle_plugins(bundle)

            if len(plugins) == 0:
                continue
            if bundle in loaded_bundles:
                continue
            loaded_bundles.append(bundle)


# Path: modsdk/webserver.py
# def make_application(port=PORT, output_log=False):
#     application = web.Application([
#             (r"/bundles", BundleList),
#             (r"/effects", EffectList),
#             (r"/effect/get/", EffectGet),
#             (r"/effect/image/(screenshot|thumbnail).png", EffectImage),
#             (r"/effect/file/(.*)", EffectFile),
#             (r"/effect/save", EffectSave),
#             (r"/config/get", ConfigurationGet),
#             (r"/config/set", ConfigurationSet),
#             (r"/(icon.html)?", Index),
#             (r"/screenshot", Screenshot),
#             (r"/post/(.+)/?", BundlePost),
#             (r"/js/templates.js$", BulkTemplateLoader),
#             (r"/resources/(.*)", EffectResource),
#             (r"/monitor", BundleMonitorWebsocket),
#             (r"/(.*)", web.StaticFileHandler, {"path": HTML_DIR}),
#             ], debug=output_log)
# 
#     application.listen(port, address="0.0.0.0")
#     if output_log:
#         options.parse_command_line()
# 
#     return ioloop.IOLoop.instance()
# 
# def lv2_init():
#     global _W
#     _W = lilv.World()
#     _W.load_all()
#     lv2_init2()
# 
# def lv2_cleanup():
#     global _W
#     _W = None
#     lv2_cleanup2()
# 
# def get_bundle_plugins(bundle):
#     return [get_plugin_info(p['uri']) for p in get_bundle_plugins2(bundle)]
# 
# def get_plugin_info(uri):
#     global _W
#     ps = _W.get_all_plugins()
#     pn = _W.new_uri(uri)
#     pl = ps.get_by_uri(pn)
#     return get_plugin_info2(_W, pl, True)


# Path: modsdk/screenshot.py
import os, glob, subprocess, random, argparse
from PIL import Image
from modsdk.settings import (ROOT, PHANTOM_BINARY, SCREENSHOT_SCRIPT,
                             MAX_THUMB_WIDTH, MAX_THUMB_HEIGHT)
from modsdk.webserver import (make_application,
                              lv2_init, lv2_cleanup,
                              get_bundle_plugins,
                              get_plugin_info)

#!/usr/bin/env python3
# -*- coding: utf-8 -*-


#maximum width and height
WIDTH = 1920
HEIGHT = 1080

# port used for the temporary webserver
PORT = 9123

class BundleQueue(object):
    def __init__(self, bundles):
        bundles = [os.path.abspath(b) for b in bundles]

        # make a list of plugin info related to our bundles
        self.bundles_info = dict((b, []) for b in bundles)

        # load info from all the bundles
        loaded_bundles = []

        for bundle in bundles:
            plugins = get_bundle_plugins(bundle)

            if len(plugins) == 0:
                continue
            if bundle in loaded_bundles:
                continue
            loaded_bundles.append(bundle)


            self.bundles_info[bundle] = plugins