Ejemplo n.º 1
0
	def handleRequest(self, msg):
		if "params" in msg:
			self.log.debug("FileRequest: %s %s %s" % (msg["cmd"], msg["params"].get("site"), msg["params"].get("inner_path")))
		else:
			self.log.debug("FileRequest: %s" % msg["cmd"])
		req = FileRequest(self)
		req.route(msg["cmd"], msg.get("params"))
Ejemplo n.º 2
0
	def handleRequest(self, connection, message):
		if "params" in message:
			self.log.debug("FileRequest: %s %s %s %s" % (str(connection), message["cmd"], message["params"].get("site"), message["params"].get("inner_path")))
		else:
			self.log.debug("FileRequest: %s %s" % (str(connection), req["cmd"]))
		req = FileRequest(self, connection)
		req.route(message["cmd"], message.get("req_id"), message.get("params"))
Ejemplo n.º 3
0
    def handleRequest(self, connection, message):
        if config.verbose:
            if "params" in message:
                self.log.debug("FileRequest: %s %s %s %s" %
                               (str(connection), message["cmd"],
                                message["params"].get("site"),
                                message["params"].get("inner_path")))
            else:
                self.log.debug("FileRequest: %s %s" %
                               (str(connection), message["cmd"]))

        # Internet connection outage detection
        if len(self.connections) > 5:
            if time.time() - self.last_request > 60 * 5:
                self.log.info(
                    "Internet outage detected, no requests received for %.0fs"
                    % (time.time() - self.last_request))
                self.last_request = time.time()
                gevent.spawn(self.checkSites,
                             check_files=False,
                             force_port_check=True)
            else:
                self.last_request = time.time()

        req = FileRequest(self, connection)
        req.route(message["cmd"], message.get("req_id"), message.get("params"))
Ejemplo n.º 4
0
 def handleRequest(self, connection, message):
     if config.verbose:
         if "params" in message:
             self.log.debug(
                 "FileRequest: %s %s %s %s" %
                 (str(connection), message["cmd"], message["params"].get("site"), message["params"].get("inner_path"))
             )
         else:
             self.log.debug("FileRequest: %s %s" % (str(connection), message["cmd"]))
     req = FileRequest(self, connection)
     req.route(message["cmd"], message.get("req_id"), message.get("params"))
     if not self.has_internet:
         self.has_internet = True
         self.onInternetOnline()
Ejemplo n.º 5
0
 def handleRequest(self, connection, message):
     if config.verbose:
         if "params" in message:
             self.log.debug(
                 "FileRequest: %s %s %s %s" %
                 (str(connection), message["cmd"], message["params"].get("site"), message["params"].get("inner_path"))
             )
         else:
             self.log.debug("FileRequest: %s %s" % (str(connection), message["cmd"]))
     req = FileRequest(self, connection)
     req.route(message["cmd"], message.get("req_id"), message.get("params"))
     if not self.has_internet:
         self.has_internet = True
         self.onInternetOnline()
def sendRequest(soc, fileName):
    """
    Sends byte data detailing the information the Client would like to
    retrieve from the Server.
    """
    record = bytearray(0)
    number = 0x497E

    fr = FileRequest(number, fileName)
    fr.encodeFixedHeader(record)

    # Sending Info to the Server
    soc.send(record)
    soc.send(fileName.encode('utf-8'))
Ejemplo n.º 7
0
    def handleRequest(self, connection, message):
        if config.verbose:
            if "params" in message:
                self.log.debug(
                    "FileRequest: %s %s %s %s" %
                    (str(connection), message["cmd"], message["params"].get("site"), message["params"].get("inner_path"))
                )
            else:
                self.log.debug("FileRequest: %s %s" % (str(connection), message["cmd"]))

        # Internet connection outage detection
        if len(self.connections) > 5:
            if time.time() - self.last_request > 60*5:
                self.log.info("Internet outage detected, no requests received for %.0fs" % (time.time() - self.last_request))
                self.last_request = time.time()
                gevent.spawn(self.checkSites, check_files=False, force_port_check=True)
            else:
                self.last_request = time.time()

        req = FileRequest(self, connection)
        req.route(message["cmd"], message.get("req_id"), message.get("params"))