Exemplo n.º 1
0
					self.logger.error("The file \"home_structure.conf\" is not found in \"conf\" directory")
					raise cherrypy.HTTPError("404 Not found", "the file \"home_structure.conf\" is not found in \"conf\" directory")
			else:
				self.logger.error("Wrongparameters %s. Use /rest/home/configuration/updaterule" % str (ids))
				raise cherrypy.HTTPError("404 Not found", "wrong parameters %s. Use /rest/home/configuration/updaterule" % str (ids))

		else:
			self.logger.error("Wrong parameters %s. Use /rest/home/configuration/updaterule" % str (ids))
			raise cherrypy.HTTPError("404 Not found", "wrong parameters %s. Use /rest/home/configuration/updaterule" % str (ids))
	
		return result	
		
	def DELETE(self, *ids):
		self.logger.error("Subclasses must override DELETE(self, *ids)!")
		raise NotImplementedError('subclasses must override DELETE(self, *ids)!')


if __name__ == "__main__":
	home = HomeAgent("HomeAgent", logLevel)
	AbstractAgent.startCherrypy(httpPort, home)
	




	
	

	

Exemplo n.º 2
0
                error = "Command not found"
                #raise cherrypy.HTTPError("404 Not found", "command not found")
        except (TimeoutException, SerialException) as reason:
            self.logger.error("Error: %s" % (reason))
            error = "Error: %s" % (reason)
            #raise cherrypy.HTTPError("404 Not found", ("Error: %s" % (reason)))

        self.__lock.release()

        if error is not None:
            raise cherrypy.HTTPError("404 Not found", ("Error: %s" % (error)))
        return result

    def POST(self, *ids):
        self.logger.error("Subclasses must override POST(self, *ids)!")
        raise NotImplementedError('subclasses must override POST(self, *ids)!')

    def PUT(self, *ids):
        self.logger.error("Subclasses must override PUT(self, *ids)!")
        raise NotImplementedError('subclasses must override PUT(self, *ids)!')

    def DELETE(self, *ids):
        self.logger.error("Subclasses must override DELETE(self, *ids)!")
        raise NotImplementedError(
            'subclasses must override DELETE(self, *ids)!')


if __name__ == "__main__":
    plugwise = PlugwiseAgent("PlugwiseAgent", logLevel)
    AbstractAgent.startCherrypy(httpPort, plugwise)
Exemplo n.º 3
0
        if len(ids) > 1:
            param_0 = str(ids[0]).lower()
            param_1 = str(ids[1])
            if param_0 == "static" and param_1 == "saveDashboard":
                try:
                    with open(self.dashboardJsonPath, 'w') as outfile:
                        outfile.write(params['json_string'].encode('utf-8'))
                        outfile.close()
                except Exception, e:
                    self.logger.error("Unable to save: %s" % e)
                    raise cherrypy.HTTPError("404 Not found",
                                             "Unable to save: %s" % e)
            else:
                self.logger.error("Resource not found")
                raise cherrypy.HTTPError("404 Not found", "resource not found")
        return open(os.path.join(self.freeboard, "index.html"))

    def PUT(self, *ids):
        self.logger.error("Must override PUT(self, *ids)!")
        raise NotImplementedError('subclasses must override PUT(self, *ids)!')

    def DELETE(self, *ids):
        self.logger.error("Must override DELETE(self, *ids)!")
        raise NotImplementedError(
            'subclasses must override DELETE(self, *ids)!')


if __name__ == "__main__":
    freeboard = FreeboardAgent("FreeboardAgent", logLevel)
    AbstractAgent.startCherrypy(httpPort, freeboard)
Exemplo n.º 4
0
                raise cherrypy.HTTPError("404 Not found", "command not found")

        else:
            self.logger.error("Command not found")
            raise cherrypy.HTTPError("404 Not found", "command not found")

        return result

    def POST(self, *ids):
        self.logger.error("Subclasses must override POST(self, *ids)!")
        raise NotImplementedError('subclasses must override POST(self, *ids)!')

    def PUT(self, *ids):
        self.logger.error("Subclasses must override PUT(self, *ids)!")
        raise NotImplementedError('subclasses must override PUT(self, *ids)!')

    def DELETE(self, *ids):
        self.logger.error("Subclasses must override DELETE(self, *ids)!")
        raise NotImplementedError(
            'subclasses must override DELETE(self, *ids)!')


if __name__ == "__main__":
    raspberry = RaspberryAgent("RaspberryAgent", logLevel)
    raspberry.setDHTInstalled(True)
    raspberry.setDHTPin(18)
    raspberry.setDHTType(22)
    raspberry.setPirInstalled(True)
    raspberry.setPirPin(7)
    AbstractAgent.startCherrypy(httpPort, raspberry)
Exemplo n.º 5
0
			else:
				self.logger.error("Command not found")
				raise cherrypy.HTTPError("404 Not found", "command not found")

		else:
			self.logger.error("Command not found")
			raise cherrypy.HTTPError("404 Not found", "command not found")

	
		return result	

		
	def POST(self, *ids):
		self.logger.error("Subclasses must override POST(self, *ids)!")
		raise NotImplementedError('subclasses must override POST(self, *ids)!')
		
	def PUT(self, *ids):
		self.logger.error("Subclasses must override PUT(self, *ids)!")
		raise NotImplementedError('subclasses must override PUT(self, *ids)!')
		
	def DELETE(self, *ids):
		self.logger.error("Subclasses must override DELETE(self, *ids)!")
		raise NotImplementedError('subclasses must override DELETE(self, *ids)!')


if __name__ == "__main__":
	scanner = ScannerAgent("ScannerAgent", logLevel)
	AbstractAgent.startCherrypy(httpPort, scanner)


Exemplo n.º 6
0
		else:
			self.logger.error("Command not found")
			raise cherrypy.HTTPError("404 Not found", "command not found")

	
		return result	

		
	def POST(self, *ids):
		self.logger.error("Subclasses must override POST(self, *ids)!")
		raise NotImplementedError('subclasses must override POST(self, *ids)!')
		
	def PUT(self, *ids):
		self.logger.error("Subclasses must override PUT(self, *ids)!")
		raise NotImplementedError('subclasses must override PUT(self, *ids)!')
		
	def DELETE(self, *ids):
		self.logger.error("Subclasses must override DELETE(self, *ids)!")
		raise NotImplementedError('subclasses must override DELETE(self, *ids)!')


if __name__ == "__main__":
	raspberry = RaspberryAgent("RaspberryAgent", logLevel)
	raspberry.setDHTInstalled(True)
	raspberry.setDHTPin(18)
	raspberry.setDHTType(22)
	raspberry.setPirInstalled(True)
	raspberry.setPirPin(7)
	AbstractAgent.startCherrypy(httpPort, raspberry)

Exemplo n.º 7
0
            elif param_0 == "scan":
                result += self.scan()

            else:
                self.logger.error("Command not found")
                raise cherrypy.HTTPError("404 Not found", "command not found")

        else:
            self.logger.error("Command not found")
            raise cherrypy.HTTPError("404 Not found", "command not found")

        return result

    def POST(self, *ids):
        self.logger.error("Subclasses must override POST(self, *ids)!")
        raise NotImplementedError('subclasses must override POST(self, *ids)!')

    def PUT(self, *ids):
        self.logger.error("Subclasses must override PUT(self, *ids)!")
        raise NotImplementedError('subclasses must override PUT(self, *ids)!')

    def DELETE(self, *ids):
        self.logger.error("Subclasses must override DELETE(self, *ids)!")
        raise NotImplementedError(
            'subclasses must override DELETE(self, *ids)!')


if __name__ == "__main__":
    scanner = ScannerAgent("ScannerAgent", logLevel)
    AbstractAgent.startCherrypy(httpPort, scanner)
Exemplo n.º 8
0
				#raise cherrypy.HTTPError("404 Not found", "command not found")
		except (TimeoutException, SerialException) as reason:
			self.logger.error("Error: %s" % (reason))
			error =  "Error: %s" % (reason)
			#raise cherrypy.HTTPError("404 Not found", ("Error: %s" % (reason)))

		self.__lock.release()

		if error is not None:
			raise cherrypy.HTTPError("404 Not found", ("Error: %s" % (error)))
		return result	

		
	def POST(self, *ids):
		self.logger.error("Subclasses must override POST(self, *ids)!")
		raise NotImplementedError('subclasses must override POST(self, *ids)!')
		
	def PUT(self, *ids):
		self.logger.error("Subclasses must override PUT(self, *ids)!")
		raise NotImplementedError('subclasses must override PUT(self, *ids)!')
		
	def DELETE(self, *ids):
		self.logger.error("Subclasses must override DELETE(self, *ids)!")
		raise NotImplementedError('subclasses must override DELETE(self, *ids)!')

if __name__ == "__main__":
	plugwise = PlugwiseAgent("PlugwiseAgent", logLevel)
	AbstractAgent.startCherrypy(httpPort, plugwise)


Exemplo n.º 9
0
			else:
				self.logger.error("command not found")
				raise cherrypy.HTTPError("404 Not found", "command not found")

		else:
			self.logger.error("command not found")
			raise cherrypy.HTTPError("404 Not found", "command not found")

	
		return result	

		
	def POST(self, *ids):
		self.logger.error("Must override POST(self, *ids)!")
		raise NotImplementedError('subclasses must override POST(self, *ids)!')
		
	def PUT(self, *ids):
		self.logger.error("Must override PUT(self, *ids)!")
		raise NotImplementedError('subclasses must override PUT(self, *ids)!')
		
	def DELETE(self, *ids):
		self.logger.error("Must override DELETE(self, *ids)!")
		raise NotImplementedError('subclasses must override DELETE(self, *ids)!')



if __name__ == "__main__":
	macosx = MacosxAgent("MacosxAgent", logLevel)
	AbstractAgent.startCherrypy(httpPort, macosx)

Exemplo n.º 10
0
				self.mqtt.syncPublish(EventTopics.getSwitchOffAll(), payload, 2)
				result += payload

		else:
			self.logger.error("Command not found")
			raise cherrypy.HTTPError("404 Not found", "command not found")

	
		return result	

		
	def POST(self, *ids, **params):
		self.logger.error("Subclasses must override POST(self, *ids)!")
		raise NotImplementedError('subclasses must override POST(self, *ids)!')
		
	def PUT(self, *ids, **params):
		self.logger.error("Subclasses must override PUT(self, *ids)!")
		raise NotImplementedError('subclasses must override PUT(self, *ids)!')
		
	def DELETE(self, *ids, **params):
		self.logger.error("Subclasses must override DELETE(self, *ids)!")
		raise NotImplementedError('subclasses must override DELETE(self, *ids)!')


if __name__ == "__main__":
	switchOff = SwitchOffAllDevicesAgent("SwitchOffAllDevicesAgent", logLevel)
	AbstractAgent.startCherrypy(httpPort, switchOff)