Ejemplo n.º 1
0
class pyGIsensors:
	def __init__(self):
		self.sensors = SensorReader()
		self.readvalues()
		self.launchtitlelist = self.sensors.titlelist
		self.labelarray = {}

		self.tray = IconoTray("psensors-tray")
		self.tray.add_menu_item(blank, "Psensors")

		for x in range(0, len(self.launchtitlelist)):
			self.createtraystring(self.launchtitlelist[x])
		self.tray.add_seperator()
		self.tray.add_menu_item(Gtk.main_quit, "Quit")

		timer = GObject.timeout_add(2000, self.updatelabels)

	def readvalues(self):
		self.sensors.updatevalues()

	def printvalues(self):
		self.sensors.printvalues()

	def updatelabels(self):
		self.readvalues()
		for x in range(0, len(self.launchtitlelist)):
			if self.launchtitlelist[x] in self.sensors.fanarray:
				for i, v in self.sensors.fanarray[self.launchtitlelist[x]].iteritems():
					self.labelarray[self.launchtitlelist[x]+i.replace(" ","")].set_label(i + " : " + v + " RPM")
			if self.launchtitlelist[x] in self.sensors.temperaturearray:
				for i, v in self.sensors.temperaturearray[self.launchtitlelist[x]].iteritems():
					self.labelarray[self.launchtitlelist[x]+i.replace(" ","")].set_label(i + " : " + v)
		return True
				
	def createtraystring(self, title):
		self.tray.add_seperator()
		self.tray.add_menu_item(blank, title.split("-")[0])
		self.tray.add_seperator()
		if title in self.sensors.fanarray:
			for i, v in sorted(self.sensors.fanarray[title].iteritems()):
				self.labelarray[title+i.replace(" ","")] = self.tray.add_menu_item(blank, i + " : " + v + " RPM")		
		if title in self.sensors.temperaturearray:
			for i, v in sorted(self.sensors.temperaturearray[title].iteritems()):
				self.labelarray[title+i.replace(" ","")] = self.tray.add_menu_item(blank, i + " : " + v)
Ejemplo n.º 2
0
	def __init__(self):
		self.sensors = SensorReader()
		self.readvalues()
		self.launchtitlelist = self.sensors.titlelist
		self.labelarray = {}

		self.tray = IconoTray("psensors-tray")
		self.tray.add_menu_item(blank, "Psensors")

		for x in range(0, len(self.launchtitlelist)):
			self.createtraystring(self.launchtitlelist[x])
		self.tray.add_seperator()
		self.tray.add_menu_item(Gtk.main_quit, "Quit")

		timer = GObject.timeout_add(2000, self.updatelabels)
Ejemplo n.º 3
0
	def __init__(self):
		self.sensors = SensorReader()
		self.readvalues()
		self.launchtitlelist = self.sensors.titlelist
		self.labelarray = {}

		mainwindow = Gtk.Window()
		mainwindow.connect('destroy', Gtk.main_quit)
		mainwindow.set_default_size(400,200)
		mainwindow.set_title("PSensors") 
		mainwindow.set_icon(GdkPixbuf.Pixbuf().new_from_file('psensors.svg'))

		notebook = Gtk.Notebook()
		notebook.set_tab_pos(Gtk.PositionType.LEFT)
		for x in range(0, len(self.launchtitlelist)):
			self.createpage(self.launchtitlelist[x],notebook)

		mainwindow.add(notebook)
		mainwindow.show_all()
		timer = GObject.timeout_add(2000, self.updatelabels)
Ejemplo n.º 4
0
    def do_GET(self):
        self._set_headers()
        self.wfile.write(json.dumps({'success': True}).encode('utf-8'))

    def do_POST(self):
        length = int(self.headers.get('content-length'))
        message = json.loads(self.rfile.read(length))
        m = re.search(r'^/sensors/([0-9]+)/reading.json$', self.path)
        sensor_id = int(m.group(1))
        if sensor_id < len(sensors):
            sensor = sensors[sensor_id]
            alerts_handler.handle(sensor, message)
            self._set_headers()
            self.wfile.write(json.dumps({'success': True}).encode('utf-8'))
        else:
            self._set_not_found()


def run_server():
    server_address = ('::', 8000)
    httpd = HTTPServer6(server_address, _RequestHandler)
    print('serving at %s:%d' % server_address)
    httpd.serve_forever()


if __name__ == '__main__':
    sensors = SensorReader.from_yaml('sensors.yml')
    print(sensors)
    run_server()
Ejemplo n.º 5
0
class pyGIsensors:
	def __init__(self):
		self.sensors = SensorReader()
		self.readvalues()
		self.launchtitlelist = self.sensors.titlelist
		self.labelarray = {}

		mainwindow = Gtk.Window()
		mainwindow.connect('destroy', Gtk.main_quit)
		mainwindow.set_default_size(400,200)
		mainwindow.set_title("PSensors") 
		mainwindow.set_icon(GdkPixbuf.Pixbuf().new_from_file('psensors.svg'))

		notebook = Gtk.Notebook()
		notebook.set_tab_pos(Gtk.PositionType.LEFT)
		for x in range(0, len(self.launchtitlelist)):
			self.createpage(self.launchtitlelist[x],notebook)

		mainwindow.add(notebook)
		mainwindow.show_all()
		timer = GObject.timeout_add(2000, self.updatelabels)

	def readvalues(self):
		self.sensors.updatevalues()

	def printvalues(self):
		self.sensors.printvalues()

	def updatelabels(self):
		self.readvalues()
		for x in range(0, len(self.launchtitlelist)):
			if self.launchtitlelist[x] in self.sensors.fanarray:
				for i, v in self.sensors.fanarray[self.launchtitlelist[x]].iteritems():
					self.labelarray[self.launchtitlelist[x]+i.replace(" ","")].set_text(v + " RPM")
			if self.launchtitlelist[x] in self.sensors.temperaturearray:
				for i, v in self.sensors.temperaturearray[self.launchtitlelist[x]].iteritems():
					self.labelarray[self.launchtitlelist[x]+i.replace(" ","")].set_text(v)
		return True
		

	def createpage(self, title, notebook):
		alabel = Gtk.Label(title.split("-")[0])
		aVbox = Gtk.VBox()
		if title in self.sensors.fanarray:
			for i, v in self.sensors.fanarray[title].iteritems():
				temphbox = Gtk.HBox()
				temphbox.set_homogeneous(True)
				fanname = Gtk.Label(i)
				self.labelarray[title+i.replace(" ","")] = Gtk.Label(v + " RPM")
				temphbox.pack_start(fanname, False, True, 5)
				temphbox.pack_end(self.labelarray[title+i.replace(" ","")], False, True, 5)
				aVbox.pack_start(temphbox, False, True, 4)
		aVbox.pack_start(Gtk.Separator.new(Gtk.Orientation.HORIZONTAL), False, True, 4)
		if title in self.sensors.temperaturearray:
			for i, v in self.sensors.temperaturearray[title].iteritems():
				temphbox = Gtk.HBox()
				temphbox.set_homogeneous(True)
				fanname = Gtk.Label(i)
				self.labelarray[title+i.replace(" ","")] = Gtk.Label(v)
				temphbox.pack_start(fanname, False, True, 5)
				temphbox.pack_end(self.labelarray[title+i.replace(" ","")], False, True, 5)
				aVbox.pack_start(temphbox, False, True, 4)
		notebook.append_page(aVbox, alabel)