Example #1
0
    def build_interface(self):
        self.window = QtGui.QWidget(self)
        self.setCentralWidget(self.window)

        # Center the window.
        #
        self.setWindowTitle("Medusa")
        self.resize(1280, 720)
        geometry = self.frameGeometry()
        center = QtGui.QDesktopWidget().availableGeometry().center()
        geometry.moveCenter(center)
        self.move(geometry.topLeft())

        # Make the background color black.
        #
        palette = self.window.palette()
        palette.setColor(QtGui.QPalette.Window, QtGui.QColor(0, 0, 0))
        self.window.setPalette(palette)
        self.window.setAutoFillBackground(True)

        # Set up a timer that will update playback status to the Head.
        #
        self.timer = QtCore.QTimer(self)
        self.timer.setInterval(config.getint("snake", "update"))
        self.timer.timeout.connect(self.check_status)
Example #2
0
    def build_interface(self):
        self.window = QtGui.QWidget(self)
        self.setCentralWidget(self.window)

        # Center the window.
        #
        self.setWindowTitle("Medusa")
        self.resize(1280, 720)
        geometry = self.frameGeometry()
        center = QtGui.QDesktopWidget().availableGeometry().center()
        geometry.moveCenter(center)
        self.move(geometry.topLeft())

        # Make the background color black.
        #
        palette = self.window.palette()
        palette.setColor(QtGui.QPalette.Window, QtGui.QColor(0, 0, 0))
        self.window.setPalette(palette)
        self.window.setAutoFillBackground(True)

        # Set up a timer that will update playback status to the Head.
        #
        self.timer = QtCore.QTimer(self)
        self.timer.setInterval(config.getint("snake", "update"))
        self.timer.timeout.connect(self.check_status)
Example #3
0
    def __init__(self):
        super(Control, self).__init__()

        self.name = ""
        self.media_path = ""
        self.downloads_path = ""
        self.communicate = None
        self.media_id = None
        self.media_name = ""

        self.jump_increment = config.getint("snake", "jump_increment")
        self.overlay_time = config.getint("snake", "overlay_time") * 1000
        self.volume_increment = config.getint("snake", "volume_increment")
        self.volume_max = config.getint("snake", "volume_max")
        self.volume_min = config.getint("snake", "volume_min")

        self.setup()
Example #4
0
    def __init__(self, proxy, host=None, port=None, name=None, qthread=False):
        self.proxy = proxy
        self.host = host or "0.0.0.0"
        self.port = port or config.getint("ports", "socket")
        self.name = name or ""

        # Determine if we should run as a client or a server.
        #
        if self.name:
            self.client = True

        else:
            self.client = False

            # Keep track of client connections.
            Communicate.connections = {}

        # Use a QThread is we are on the GUI side.
        self.qthread = qthread

        self._start()
Example #5
0
    def _update_elapsed(self):
        if not self.media_id:
            return

        threshold = config.getint("snake", "resume_threshold")
        elapsed, total = self._get_time()

        try:
            percentage = int((elapsed / float(total)) * 100)

        except ZeroDivisionError:
            percentage = 0

        if percentage < threshold:
            self._call_api(["viewed", self.media_id, "delete"])

            return

        if (100 - percentage) < threshold:
            elapsed = 0

        self._call_api(["elapsed", self.media_id, elapsed])
Example #6
0
    def run(self):
        """
        Check every 5 seconds if it is time to index.
        """

        i = 0

        while True:
            i += 5

            if not self.stop:
                if self.now:
                    self.now = False

                    self.index()

                if i >= config.getint("index", "interval"):
                    i = 0

                    self.index()

            time.sleep(5)
Example #7
0
    def run(self):
        """
        Check every 5 seconds if it is time to index.
        """

        i = 0

        while True:
            i += 5

            if not self.stop:
                if self.now:
                    self.now = False

                    self.index()

                if i >= config.getint("index", "interval"):
                    i = 0

                    self.index()

            time.sleep(5)
Example #8
0
Index()

Communicate(proxy=Proxy)

#------------------------------------------------------------------------------

app = flask.Flask(__name__,
                  template_folder="%s/templates" % PATH,
                  static_folder="%s/static" % PATH,
                  static_url_path="/%s/static" % URL_BASE)

app.register_blueprint(api, url_prefix="/%s/%s" % (URL_BASE, API_BASE))
app.register_blueprint(pages, url_prefix="/%s" % URL_BASE)

#------------------------------------------------------------------------------

@app.route("/")
def root():
    return flask.redirect("/%s" % URL_BASE)

#------------------------------------------------------------------------------

if __name__ == "__main__":
    try:
        log.warn("Head initialised")

        app.run(host="0.0.0.0", port=config.getint("ports", "head"))

    finally:
        log.warn("Head exited")