示例#1
0
 def BumpTemp(self, setpoint, degrees):
     debug.debugPrint('Main', "Bump temp: ", setpoint, degrees, ' to ',
                      self.info[setpoint][0] + degrees)
     self.isy.try_ISY_comm(
         'nodes/' + self.ISYObj.address + '/cmd/' + setpoint + '/' +
         str(self.info[setpoint][0] + degrees)
     )  # todo fix for lost connect when move to common screen
示例#2
0
 def format(self, journaling=True):
     if for_real:
         if journaling:
             f = os.popen("mkswap %s" % (self.partition.path))
         f.close()
     else:
         debugPrint("Formatted %s volume" % (self.name))
示例#3
0
 def __init__(self, name, keys, overrides=fixedoverrides):
     screen.BaseKeyScreenDesc.__init__(self, overrides, name)
     debug.debugPrint('Screen', "Build Maintenance Screen")
     self.NavKeysShowing = False
     self.DefaultNavKeysShowing = False
     screen.AddUndefaultedParams(self,
                                 None,
                                 TitleFontSize=40,
                                 SubFontSize=25)
     for k, kt in keys.items():
         NK = toucharea.ManualKeyDesc(self,
                                      k, [kt[0]],
                                      'gold',
                                      'black',
                                      'red',
                                      KOn='black',
                                      KOff='red')
         if kt[1] is not None:
             if len(
                     kt
             ) == 3:  # need to add key reference to the proc for this key
                 NK.Proc = functools.partial(kt[1], NK)
             else:
                 NK.Proc = kt[1]
         self.Keys[k] = NK
     topoff = self.TitleFontSize + self.SubFontSize
     self.LayoutKeys(topoff, self.useablevertspacesansnav - topoff)
     self.DimTO = 60
     self.PersistTO = 1  # setting to 0 would turn off timer and stick us here
     utilities.register_example("MaintScreenDesc", self)
示例#4
0
	def __init__(self, thisscreen, keysection, keyname):
		debug.debugPrint('Screen', "             New SetVar Key Desc ", keyname)
		ManualKeyDesc.__init__(self, thisscreen, keysection, keyname)
		screen.AddUndefaultedParams(self, keysection, VarType='undef', Var='', Value=0)
		try:
			self.Proc = self.SetVarKeyPressed
			if self.VarType != 'undef':  # deprecate

				if self.VarType == 'State':
					self.VarName = (hubs.hubs.defaulthub.name, 'State', self.Var)  # use default hub for each of these 2
				elif self.VarType == 'Int':
					self.VarName = (hubs.hubs.defaulthub.name, 'Int', self.Var)
				elif self.VarType == 'Local':
					self.VarName = ('LocalVars', self.Var)
				else:
					logsupport.Logs.Log('VarType not specified for key ', self.Var, ' on screen ', thisscreen.name,
										severity=ConsoleWarning)
					self.Proc = ErrorKey
				logsupport.Logs.Log('VarKey definition using depreacted VarKey ', self.VarType, ' change to ',
									valuestore.ExternalizeVarName(self.VarName), severity=ConsoleWarning)
			else:
				self.VarName = self.Var.split(':')
		except Exception as e:
			logsupport.Logs.Log('Var key error on screen: ' + thisscreen.name + ' Var: ' + self.Var,
								severity=ConsoleWarning)
			logsupport.Logs.Log('Excpt: ', str(e))
			self.Proc = ErrorKey

		utilities.register_example("SetVarKey", self)
示例#5
0
	def InitDisplay(self, nav):
		debug.debugPrint("Screen", "Base Screen InitDisplay: ", self.name)
		self.PaintBase()
		self.NavKeys = nav
		self.PaintKeys()
		if self.ScreenTitleBlk is not None:
			hw.screen.blit(self.ScreenTitleBlk, (self.titleoffset, self.TopBorder))
示例#6
0
	def __init__(self, thisscreen, keysection, kn, keytype):
		keyname, self.Hub = _resolvekeyname(kn, thisscreen.DefaultHubObj)
		#self.ControlObj = None  # object on which to make operation calls
		self.DisplayObj = None  # object whose state is reflected in key

		debug.debugPrint('Screen', "             New ", keytype, " Key Desc ", keyname)
		ManualKeyDesc.__init__(self, thisscreen, keysection, keyname)
		screen.AddUndefaultedParams(self, keysection, SceneProxy='', NodeName='')

		if keyname == '*Action*': keyname = self.NodeName  # special case for alert screen action keys that always have same name todo - can nodename ever be explicitly set otherwise?
		self.ControlObj, self.DisplayObj = self.Hub.GetNode(keyname, self.SceneProxy)

		if self.ControlObjUndefined():
			debug.debugPrint('Screen', "Screen", keyname, "unbound")
			logsupport.Logs.Log('Key Binding missing: ' + self.name, severity=ConsoleWarning)

		if self.Verify:
			self.VerifyScreen = supportscreens.VerifyScreen(self, self.GoMsg, self.NoGoMsg, self.Verified, None,
															thisscreen, self.KeyColorOff,
															thisscreen.BackgroundColor, thisscreen.CharColor,
															self.State, thisscreen.HubInterestList)
			self.Proc = self.VerifyScreen.Invoke  # todo make this a goto key; make verify screen always do a pop and get rid of the switch screens below
		else:
			self.Proc = self.KeyPressAction
			self.ProcDblTap = self.KeyPressActionDbl

		if keytype == 'ONOFF':
			self.KeyAction = 'OnOff'
		elif keytype == 'ON':
			self.KeyAction = 'On'
		else:
			self.KeyAction = 'Off'

		utilities.register_example("OnOffKey", self)
示例#7
0
文件: lvm.py 项目: effigies/tedd
 def create(self):
     free, total, size = self.volume_group.extents()
     lv_extents = int(min((float(self.size) / size)*total, free))
     if for_real:
         os.system("lvcreate %s -l %s -n %s" % (self.volume_group.group_name, lv_extents, self.name))
     else:
         debugPrint("Creating logical volume")
示例#8
0
文件: disk.py 项目: effigies/tedd
 def deletePart(self, part_list):
     for part in part_list:
         if for_real:
             os.system("parted %s rm %s" % (part.disk.path, part.number))
         debugPrint("Deleting partition %s%s" % (part.disk.path, part.number))
         if part.path in self.partitions:
             del self.partitions[part.path]
示例#9
0
	def Font(self, fsize, face="", bold=False, italic=False):
		def gennewfont(gname, gsize, gbold, gitalic):
			# logsupport.Logs.Log('Generated Font: ', repr(name), str(size), str(utilities.scaleH(size)), str(bold),
			#					str(italic))
			return pygame.font.SysFont(gname, hw.scaleH(gsize), gbold, gitalic)

		size = int(fsize)
		try:
			return self.fontcache[face][size][italic][bold]
		except KeyError:
			name = face if face != "" else None
			if face not in self.fontcache:
				self.fontcache[face] = {size: {italic: {bold: gennewfont(name, size, bold, italic)}}}
			else:
				if size not in self.fontcache[face]:
					self.fontcache[face][size] = {italic: {bold: gennewfont(name, size, bold, italic)}}
				else:
					if italic not in self.fontcache[face][size]:
						self.fontcache[face][size][italic] = {bold: gennewfont(name, size, bold, italic)}
					else:
						if bold not in self.fontcache[face][size][italic]:
							self.fontcache[face][size][italic][bold] = gennewfont(name, size, bold, italic)
						else:
							pass  # log this - should never get here
			debug.debugPrint('Fonts', 'New font: ', face if face != "" else '-Sys-', ' :', size, (' b', ' B')[bold],
							 (' i', ' I')[italic])
			return self.fontcache[face][size][italic][bold]
示例#10
0
	def __init__(self, thisscreen, keysection, keyname):
		debug.debugPrint('Screen', "             New Blank Key Desc ", keyname)
		ManualKeyDesc.__init__(self, thisscreen, keysection, keyname)
		self.Proc = ErrorKey
		self.State = False
		self.label = self.label.append('(NoOp)')

		utilities.register_example("BlankKey", self)
示例#11
0
	def __init__(self, thisscreen, keysection, keyname):
		debug.debugPrint('Screen', "             New SetVarValue Key Desc ", keyname)
		self.Value = None
		ManualKeyDesc.__init__(self, thisscreen, keysection, keyname)
		screen.AddUndefaultedParams(self, keysection, Var='')
		self.Proc = self.SetVarValue

		utilities.register_example("SetVarValueKey", self)
示例#12
0
def VarChanged(storeitem, old, new, param, modifier):
    debug.debugPrint('DaemonCtl', 'Var changed ', storeitem.name, ' from ',
                     old, ' to ', new)
    # noinspection PyArgumentList
    if old != new:
        PostEvent(
            ConsoleEvent(CEvent.ISYVar, hub='AlertTasksVarChange',
                         alert=param))
示例#13
0
	def __init__(self, thisscreen, keysection, keyname):
		debug.debugPrint('Screen', "             New GoTo Key ", keyname)
		ManualKeyDesc.__init__(self, thisscreen, keysection, keyname)
		screen.AddUndefaultedParams(self, keysection, ScreenName='**unspecified**')
		self.targetscreen = None
		GoToTargetList[self] = self.ScreenName

		self.Proc = self.GoToKeyPressed
示例#14
0
 def BumpMode(self, mode, vals):
     cv = vals.index(self.info[mode][0])
     cv = (cv + 1) % len(vals)
     debug.debugPrint('Main', "Bump: ", mode, ' to ', cv)
     self.isy.try_ISY_comm(
         'nodes/' + self.ISYObj.address + '/cmd/' + mode + '/' +
         str(vals[cv])
     )  # todo fix for lost connect when move to common screen
示例#15
0
文件: disk.py 项目: effigies/tedd
 def disableSwap(self):
     swap_file = open("/proc/swaps")
     for line in swap_file:
         for part in self.swap_list:
             if line.find(part.path) != -1:
                 if for_real:
                     os.system("swapoff %s" % part.path)
                 debugPrint("Disabling %s as swap" % part.path)
示例#16
0
 def SendOnOffFastCommand(self, settoon):
     selcmd = ('DFOF', 'DFON')
     debug.debugPrint('ISYdbg', "Fast OnOff sent: ", selcmd[settoon],
                      ' to ', self.name)
     r = self.Hub.try_ISY_comm('nodes/' + self.address + '/cmd/' +
                               selcmd[settoon])
     if r == "":  # error in comm - fake a response to see unavailable key
         self.Hub.isyEM.FakeNodeChange()
示例#17
0
 def SetActivityTimer(self, timeinsecs, dbgmsg):
     self.activityseq += 1
     self.ActivityTimer.set(
         ConsoleEvent(CEvent.ACTIVITYTIMER,
                      seq=self.activityseq,
                      msg=dbgmsg), timeinsecs)
     debug.debugPrint('Dispatch', 'Set activity timer: ', timeinsecs, ' ',
                      dbgmsg)
示例#18
0
    def Update(self, **ns):
        oldst = self.state
        if 'attributes' in ns: self.attributes = ns['attributes']
        self.state = ns['state']
        newst = _NormalizeState(self.state)
        if newst != self.internalstate:
            logsupport.Logs.Log("Mediaplayer state change: ",
                                self.Hub.Entities[self.entity_id].name,
                                ' was ',
                                self.internalstate,
                                ' now ',
                                newst,
                                '(',
                                self.state,
                                ')',
                                severity=ConsoleDetail)
            self.internalstate = newst

        if self.Sonos:
            if self.internalstate == -1:  # unavailable
                logsupport.Logs.Log("Sonos room went unavailable: ",
                                    self.Hub.Entities[self.entity_id].name)
                return
            else:
                if oldst == -1:
                    logsupport.Logs.Log("Sonos room became available: ",
                                        self.Hub.Entities[self.entity_id].name)
                self.sonos_group = self.attributes['sonos_group']
                if 'source_list' in self.attributes:
                    self.source_list = self.attributes['source_list']
                self.muted = self.attributes[
                    'is_volume_muted'] if 'is_volume_muted' in self.attributes else 'True'
                self.volume = self.attributes[
                    'volume_level'] if 'volume_level' in self.attributes else 0
                self.song = self.attributes[
                    'media_title'] if 'media_title' in self.attributes else ''
                self.artist = self.attributes[
                    'media_artist'] if 'media_artist' in self.attributes else ''
                self.album = self.attributes[
                    'media_album_name'] if 'media_album_name' in self.attributes else ''

            if screens.DS.AS is not None:
                if self.Hub.name in screens.DS.AS.HubInterestList:
                    if self.entity_id in screens.DS.AS.HubInterestList[
                            self.Hub.name]:
                        debug.debugPrint(
                            'DaemonCtl',
                            time.time() - config.sysStore.ConsoleStartTime,
                            "HA reports node change(screen): ", "Key: ",
                            self.Hub.Entities[self.entity_id].name)

                        # noinspection PyArgumentList
                        PostEvent(
                            ConsoleEvent(CEvent.HubNodeChange,
                                         hub=self.Hub.name,
                                         node=self.entity_id,
                                         value=self.internalstate))
示例#19
0
文件: distro.py 项目: effigies/tedd
 def copy_tree(self, source, destination=None):
     if not destination:
         destination = source
     try:
         shutil.copytree(os.path.join(self.base, source), os.path.join(self.workingdir, "initrd", destination))
     except OSError, exc:
         if exc[0] == 2:
             raise
         elif exc[0] == 17:
             debugPrint("File %s already exists" % (os.path.join(self.workingdir, "initrd", destination)))
示例#20
0
 def format(self, journaling=True):
     if for_real:
         if journaling:
             f = os.popen("mkfs.ext3 -q %s" % (self.partition.path))
         else:
             f = os.popen("mkfs.ext2 -q %s" % (self.partition.path))
         f.close()
         self.free_space, self.free_blocks, self.block_count = self.freeSpace()
     else:
         debugPrint("Formatted ext volume")
示例#21
0
 def RemoveTask(self, evnt):
     self.HB.Entry('RemoveTask: ' + repr(evnt))
     debug.debugPrint('EventList', self.RelNow(), ' Remove: ', evnt)
     # noinspection PyBroadException
     try:
         self.finder[id(evnt)].deleted = True
     except Exception:
         self.HB.Entry('Not on List')
         debug.debugPrint('EventList', self.RelNow(),
                          ' Remove item not on list: : ', evnt)
示例#22
0
 def CheckValsUpToDate(self, reload=False):
     goodcheck = True
     for v in self.items():
         l = self.GetVal(v, forceactual=False)
         r = self.GetVal(v)
         if l != r:
             debug.debugPrint('StoreTrack', 'ISY Value Mismatch: (ISY) ', r,
                              ' (Local) ', l)
             goodcheck = False
     if goodcheck:
         debug.debugPrint('StoreTrack', 'ISY Value Check OK')
示例#23
0
 def shrink(self, newSize):
     print newSize
     if for_real:
         debugPrint("yes | resize_reiserfs -s %s %s" % (newSize, self.partition.path))
         if not os.system("yes | resize_reiserfs -s %s %s" % (newSize, self.partition.path)):
             self.partition.size = newSize
             return True
     else:
         debugPrint("Resized %s to %s" % (self.partition.path, new_size))
         self.partition.size = newSize
         return True
     return False
示例#24
0
	def InitDisplay(self):
		debug.debugPrint("Screen", "OnOffKey Key.InitDisplay ", self.Screen.name, self.name)
		state = self.Hub.GetCurrentStatus(self.DisplayObj)
		if state is None:
			logsupport.Logs.Log("No state available for  key: " + self.name + ' on screen: ' + self.Screen.name,
								severity=ConsoleWarning)
			state = -1
			self.State = False
		else:
			self.State = not (state == 0)  # K is off (false) only if state is 0
		self.UnknownState = True if state == -1 else False
		super(OnOffKey, self).InitDisplay()
示例#25
0
    def __init__(self, screensection, screenname):
        debug.debugPrint('Screen', "New WeatherScreenDesc ", screenname)
        screen.ScreenDesc.__init__(self, screensection, screenname)

        self.fmt = WFormatter()

        butsize = self.ButSize(1, 1, 0)
        self.Keys = OrderedDict({
            'condorfcst':
            toucharea.TouchPoint('condorfcst',
                                 (self.HorizBorder + .5 * butsize[0],
                                  self.TopBorder + .5 * butsize[1]),
                                 butsize,
                                 proc=self.CondOrFcst)
        })
        self.currentconditions = True  # show conditions or forecast
        screen.AddUndefaultedParams(self,
                                    screensection,
                                    location='',
                                    LocationSize=40)

        self.SetScreenTitle(screen.FlatenScreenLabel(self.label), 50,
                            self.CharColor)

        self.condformat = u"{d[0]} {d[1]}\u00B0F", u"  Feels like: {d[2]}\u00B0", "Wind {d[3]}@{d[4]}"
        self.condfields = list(
            ((self.location, 'Cond', x)
             for x in ('Sky', 'Temp', 'Feels', 'WindDir', 'WindMPH')))

        # self.dayformat  = "Sunrise: {d[0]:02d}:{d[1]:02d}","Sunset:  {d[2]:02d}:{d[3]:02d}","Moon rise: {d[4]} set: {d[5]}","{d[6]}% illuminated"
        # self.dayfields  = list(((self.location, 'Cond', x) for x in ('SunriseH','SunriseM','SunsetH','SunsetM','Moonrise','Moonset','MoonPct')))
        self.dayformat = "Sunrise: {d[0]}", "Sunset:  {d[1]}", "Moon rise: {d[2]} set: {d[3]}"
        self.dayfields = list(
            ((self.location, 'Cond', x)
             for x in ('Sunrise', 'Sunset', 'Moonrise', 'Moonset')))

        self.footformat = "Readings as of {d[0]}",
        self.footfields = ((self.location, 'Cond', 'Age'), )

        self.fcstformat = u"{d[0]}   {d[1]}\u00B0/{d[2]}\u00B0 {d[3]}", "Wind: {d[4]}"
        self.fcstfields = list(
            ((self.location, 'Fcst', x)
             for x in ('Day', 'High', 'Low', 'Sky', 'WindSpd')))

        try:
            self.store = valuestore.ValueStores[self.location]
        except KeyError:
            logsupport.Logs.Log(
                "Weather screen {} using non-existent location {}".format(
                    screenname, self.location),
                severity=logsupport.ConsoleWarning)
            raise ValueError
        utilities.register_example("WeatherScreenDesc", self)
示例#26
0
 def getSectors(self):
     part_file = os.popen("fdisk -ul %s" % self.disk.path)
     for line in part_file:
         if line.strip().startswith(self.path):
             debugPrint(line)
             star_offset = 0
             if line.split()[1] == '*':
                 star_offset = 1
             self.start_sector = int(line.split()[1+star_offset])
             self.end_sector = int(line.split()[2+star_offset])    
             self.num_sectors = self.end_sector - self.start_sector
     part_file.close()
示例#27
0
 def shrink(self, newSize):
     percent = float(newSize)/self.partition.size
     new_size = int(self.block_count * percent)
     if for_real:
         os.system("e2fsck -f %s" % self.partition.path)
         if os.popen("resize2fs %s %s" % (self.partition.path, new_size)):
             self.partition.size = newSize
             return True
     else:
         debugPrint("Resized %s to %s" % (self.partition.path, new_size))
         self.partition.size = newSize
         return True
     return False
示例#28
0
文件: distro.py 项目: effigies/tedd
 def copy_file(self, source, destination=None, base_dest=False):
     if not destination:
         destination = source
     if not base_dest:
         try:
             shutil.copy(os.path.join(self.base, source), os.path.join(self.workingdir, "initrd", destination))
         except IOError:
             debugPrint("Error copying %s to %s" % (os.path.join(self.base, source), os.path.join(self.workingdir, "initrd", destination)))
     else:
         try:
             shutil.copy(os.path.join(self.base, source), os.path.join(self.base, destination))
         except IOError:
             debugPrint("Error copying %s to %s" % (os.path.join(self.base, source), os.path.join(self.base, destination)))
示例#29
0
 def __init__(self, screensection, screenname):
     debug.debugPrint('Screen', "Build House Status Screen")
     screen.ScreenDesc.__init__(self, screensection,
                                screenname)  # no extra cmd keys
     utilities.LocalizeParams(self,
                              screensection,
                              '-',
                              NormalOn=[],
                              NormalOff=[])
     checklist = [
         nm for nm in config.ISY.NodesByName
         if ((nm in self.NormalOn) or (nm in self.NormalOff))
     ]  # addr -> name
     utilities.register_example("HouseStatusScreenDesc", self)
    def BumpFan(self):
        if self.TimeBumpFan is not None:
            self.TimeBumpFan.cancel()  # cancel any pending timer
        self.FanLocal = 0.5  # just do a show screen for mode and fan
        self.fanstates = self.fanstates[1:] + self.fanstates[:1]
        self.fan = self.fanstates[0]

        debug.debugPrint('Main', "Bump fan: ", self.fan)
        self.ShowScreen()
        self.TimerName += 1
        self.TimeBumpFan = timers.OnceTimer(2.0,
                                            name='ThermostatFan' +
                                            str(self.TimerName),
                                            proc=self.PushFanState)
        self.TimeBumpFan.start()
    def BumpMode(self):
        if self.TimeBumpModes is not None:
            self.TimeBumpModes.cancel()  # cancel any pending timer
        self.ModeLocal = 0.5  # just do a show screen for mode and fan
        self.modes = self.modes[1:] + self.modes[:1]
        self.mode = self.modes[0]

        debug.debugPrint('Main', "Bump mode: ", self.mode)
        self.ShowScreen()
        self.TimerName += 1
        self.TimeBumpModes = timers.OnceTimer(2.0,
                                              name='ThermostatModes' +
                                              str(self.TimerName),
                                              proc=self.PushModes)
        self.TimeBumpModes.start()
示例#32
0
	def ExitScreen(self):
		if self.BlinkTimer is not None:
			#logsupport.Logs.Log('Cancelling alert blink for {}'.format(self.BlinkTimer.name))
			self.BlinkTimer.cancel()
			self.BlinkTimer = None

		if self.Alert.trigger.IsTrue():  # if the trigger condition is still true requeue post deferral
			self.Alert.state = 'Deferred'
			self.TimerName += 1
			self.DeferTimer = timers.OnceTimer(self.Defer, start=True, name=self.name + '-Defer-' + str(self.TimerName),
											   proc=alerttasks.HandleDeferredAlert, param=self.Alert)
			debug.debugPrint('Screen', 'Alert screen defer to another screen: ' + self.name)
			logsupport.Logs.Log("Alert screen " + self.name + " deferring", severity=ConsoleDetail)
		else:
			debug.debugPrint('Screen', 'Alert screen cause cleared: ' + self.name)
			logsupport.Logs.Log("Alert screen " + self.name + " cause cleared", severity=ConsoleDetail)
示例#33
0
    def NodeEvent(self, hub='', node=0, value=0, varinfo=()):
        # Watched node reported change event is ("Node", addr, value, seq)
        debug.debugPrint('HUB', hub, node, type(value), value)
        if isinstance(value, float):
            logsupport.Logs.Log("Node event with floating state: " + hub +
                                ':' + str(node) + '->' + str(value),
                                severity=ConsoleWarning)
            value = int(value)

        assert isinstance(value, int)
        if node is None:  # all keys for this hub
            for _, K in self.HubInterestList[hub].items():
                debug.debugPrint('Screen', 'KS Wildcard ISYEvent ', K.name,
                                 str(value), str(K.State))
                K.UnknownState = True
                K.PaintKey()
                pygame.display.update()
        elif node != 0:
            # noinspection PyBroadException
            try:
                K = self.HubInterestList[hub][node]
            except:
                debug.debugPrint('Screen', 'Bad key to KS - race?', self.name,
                                 str(node))
                return  # treat as noop
            debug.debugPrint('Screen', 'KS ISYEvent ', K.name, str(value),
                             str(K.State))
            K.State = not (value == 0)  # K is off (false) only if state is 0
            K.UnknownState = True if value == -1 else False
            K.PaintKey()
            pygame.display.update()
        else:
            # noinspection PyBroadException
            try:
                # varinfo is (keyname, varname)
                K = self.Keys[varinfo[0]]
                K.PaintKey()
                pygame.display.update()
            except:
                debug.debugPrint(
                    'Screen',
                    "Var change reported to screen that doesn't care",
                    self.name, str(varinfo)
                )  # todo event reporting correlation to screens could use rework
                return
示例#34
0
	def __init__(self, screensection, screenname):
		screen.ScreenDesc.__init__(self, screensection, screenname)
		debug.debugPrint('Screen', "Build Clock Screen")
		screen.AddUndefaultedParams(self, screensection, CharSize=[20], Font=fonts.monofont, OutFormat=[],
									ExtraFields=[],
									ExtraSize=[0], ExtraFormat=[])
		for i in range(len(self.CharSize), len(self.OutFormat)):
			self.CharSize.append(self.CharSize[-1])
		self.KeyList = None  # no touch areas active on this screen
		utilities.register_example("ClockScreen", self)

		self.DecodedExtraFields = []
		for f in self.ExtraFields:
			if ':' in f:
				self.DecodedExtraFields.append(f.split(':'))
			else:
				logsupport.Logs.Log("Incomplete field specified on clockscreen", severity=ConsoleWarning)
		self.poster = RepeatingPost(1.0, paused=True, name=self.name, proc=self.repaintClock)
		self.poster.start()
示例#35
0
	def __init__(self, thisscreen, keysection, keyname):
		debug.debugPrint('Screen', "              New Var Key ", keyname)
		ManualKeyDesc.__init__(self, thisscreen, keysection, keyname)
		screen.AddUndefaultedParams(self, keysection, Var='', Appearance=[], ValueSeq=[])
		valuestore.AddAlert(self.Var, (KeyWithVarChanged, (keyname, self.Var)))
		if self.ValueSeq:
			self.Proc = self.VarKeyPressed
			t = []
			for n in self.ValueSeq: t.append(int(n))
			self.ValueSeq = t
		self.displayoptions = []
		self.oldval = None
		self.State = False
		for item in self.Appearance:
			desc = shlex.split(item)
			rng = desc[0].split(':')
			chooser = (int(rng[0]), int(rng[0])) if len(rng) == 1 else (int(rng[0]), int(rng[1]))
			clr = desc[1]
			lab = self.label if len(desc) < 3 else desc[2]
			self.displayoptions.append(self.DistOpt(chooser, clr, lab))
示例#36
0
 def PrintTree(self, startpoint, indent, msg):
     if msg is not None:
         debug.debugPrint('ISYdbg', 'Graph for ', msg)
     if isinstance(startpoint, Scene):
         debug.debugPrint('ISYdbg', indent + startpoint.__repr__())
         for m in startpoint.members:
             if m[0] == 16:
                 sR = 'R'
             elif m[0] == 32:
                 sR = 'C'
             else:
                 sR = 'X'
             debug.debugPrint('ISYdbg',
                              indent + "-" + sR + "--" + (m[1].__repr__()))
     elif isinstance(startpoint, TreeItem):
         debug.debugPrint('ISYdbg', indent + startpoint.__repr__())
         for c in startpoint.children:
             self.PrintTree(c, indent + "....", None)
     else:
         debug.debugPrint('ISYdbg', "Funny thing in tree ",
                          startpoint.__repr__)
示例#37
0
 def InitDisplay(self, nav):
     if self.state == 'init':
         debug.debugPrint('Main', "Enter to screen: ", self.name)
         super(LogDisplayScreen, self).InitDisplay(nav)
         logsupport.Logs.Log('Entering Log Screen')
         self.startat = 0
         self.startpage = 0
         self.item = 0
         self.pageno = -1
         self.PageStartItem = [0]
         if config.sysStore.ErrorNotice != -1:
             self.state = 'scroll'
             self.startat = config.sysStore.ErrorNotice
             config.sysStore.ErrorNotice = -1
         else:
             self.state = 'manual'
             self.startat = 0
         UpdateGlobalErrorPointer()
         self.item = 0
         self.PageStartItem = [0]
         self.pageno = -1
     if self.state == 'scroll':
         if (self.item < self.startat) and (
                 self.item != -1
         ):  # if first error not yet up and not last page go to next page
             timers.OnceTimer(.25,
                              start=True,
                              name='LogPage{}'.format(self.item),
                              proc=self.LogSwitch)
         else:
             self.state = 'manual'
     else:
         pass
     self.item = logsupport.Logs.RenderLog(self.BackgroundColor,
                                           start=self.startpage,
                                           pageno=self.pageno + 1)
     if self.pageno + 1 == len(
             self.PageStartItem
     ):  # if first time we saw this page remember its start pos
         self.PageStartItem.append(self.item)
示例#38
0
    def __init__(self, key, gomsg, nogomsg, procyes, procno, callingscreen,
                 bcolor, keycoloroff, charcolor, state, interestlist):
        screen.BaseKeyScreenDesc.__init__(self, {},
                                          key.name + '-Verify',
                                          parentscreen=key)
        debug.debugPrint('Screen', "Build Verify Screen")
        self.NavKeysShowing = False
        self.DefaultNavKeysShowing = False
        self.HubInterestList = interestlist
        self.DimTO = 20
        self.PersistTO = 10
        self.label = screen.FlatenScreenLabel(key.label)
        self.ClearScreenTitle()  # don't use parent screen title
        self.CallingScreen = callingscreen
        screen.AddUndefaultedParams(self,
                                    None,
                                    TitleFontSize=40,
                                    SubFontSize=25)
        self.SetScreenTitle(self.label, 40, charcolor)
        self.Keys['yes'] = ManualKeyDesc(self,
                                         'yes',
                                         gomsg,
                                         bcolor,
                                         keycoloroff,
                                         charcolor,
                                         State=state)
        self.Keys['yes'].Proc = procyes  # functools.partial(proc, True)
        self.Keys['no'] = ManualKeyDesc(self,
                                        'no',
                                        nogomsg,
                                        bcolor,
                                        keycoloroff,
                                        charcolor,
                                        State=state)
        self.Keys[
            'no'].Proc = procno if procno is not None else self.DefaultNo  # functools.partial(proc, False)

        self.LayoutKeys(self.startvertspace, self.useablevertspace)
        utilities.register_example("VerifyScreen", self)
示例#39
0
	def __init__(self, thisscreen, keysection, keyname):
		debug.debugPrint('Screen', "             New RunProgram Key ", keyname)
		ManualKeyDesc.__init__(self, thisscreen, keysection, keyname)
		screen.AddUndefaultedParams(self, keysection, ProgramName='')
		self.State = False
		pn, self.Hub = _resolvekeyname(self.ProgramName, thisscreen.DefaultHubObj)
		self.Program = self.Hub.GetProgram(pn)
		if self.Program is None:
			self.Program = DummyProgram(keyname, self.Hub.name, self.ProgramName)
			logsupport.Logs.Log(
				"Missing Prog binding Key: {} on screen {} Hub: {} Program: {}".format(keyname, thisscreen.name, self.Hub.name, self.ProgramName),
				severity=ConsoleWarning)
		if self.Verify:
			self.VerifyScreen = supportscreens.VerifyScreen(self, self.GoMsg, self.NoGoMsg, self.Verified, None,
															thisscreen, self.KeyColorOff,
															thisscreen.BackgroundColor, thisscreen.CharColor,
															self.State, thisscreen.HubInterestList)
			self.Proc = self.VerifyScreen.Invoke
			self.ProcDblTap = self.VerifyScreen.Invoke
		else:
			self.Proc = self.RunKeyPressed
			self.ProcDblTap = self.RunKeyDblPressed
示例#40
0
def HandleDeferredAlert(param):
    alert = param.param
    AlertsHB.Entry('Deferred Alert' + repr(alert))
    debug.debugPrint('Dispatch', 'Deferred alert fired: ', repr(alert))
    logsupport.Logs.Log("Deferred alert event fired" + repr(alert),
                        severity=ConsoleDetail)
    alert.state = 'Fired'
    if alert.trigger.IsTrue():
        alert.Invoke(
        )  # defered or delayed or scheduled alert firing or any periodic
    else:
        if isinstance(alert.trigger, NodeChgtrigger):
            # why not cleared before getting here?
            logsupport.Logs.Log('NodeChgTrigger cleared while deferred: ',
                                repr(alert),
                                severity=ConsoleDetail,
                                hb=True)
        elif isinstance(alert.trigger, VarChangeTrigger):
            logsupport.Logs.Log('VarChangeTrigger cleared while deferred: ',
                                repr(alert),
                                severity=ConsoleDetail,
                                hb=True)
        alert.state = 'Armed'
示例#41
0
 def resize(self):
     new_size = int(math.ceil((self.size - self.fs.free_space)*1.1))
     # I've had rounding issues. This *should* take care of them.
     percent = new_size/self.size
     percent *= 100
     percent = math.ceil(percent)/100
     debugPrint(new_size)
     self.fs.shrink(new_size)
     self.getSectors()
     # new_end_sectors = int(self.start_sector + math.ceil(self.num_sectors * percent))
     debugPrint(percent)
     if for_real:
         # This is ugly, but I haven't found a better way to do this
         # Using fdisk -u, it deletes the specified partition, creates a new, primary partition
         # at the same partition number and the same start sector. The new end sector is chosen
         # to make the total partition size slightly larger than the filesystem on board.
         # Then, a new primary partition is created in the empty space following the partition
         # that we just created. Changes are written.
         debugPrint("fdisk -u %s << EOF\nd\n%s\nn\np\n%s\n%s\n+%sK\nw" % (self.disk.path, self.number,self.number,self.start_sector, int(math.ceil(new_size/1024.0))))
         os.system("fdisk -u %s << EOF\nd\n%s\nn\np\n%s\n%s\n+%sK\nw" % (self.disk.path, self.number,self.number,self.start_sector, int(math.ceil(new_size/1024.0))))
     self.fs.fillPartition()
示例#42
0
文件: luks.py 项目: effigies/tedd
 def luksOpen(self):
     if for_real:
         os.system("echo -n %s | cryptsetup luksOpen %s %s" % (self.password, self.device.path, self.mapper_name))
     else:
         debugPrint("Creating luks device")
示例#43
0
文件: devices.py 项目: effigies/tedd
def urandom(device):
        if for_real:
            os.system("dd if=/dev/urandom of=%s" % device.path)
        else:
            debugPrint("Filling %s with random data"% device.path)
示例#44
0
文件: luks.py 项目: effigies/tedd
 def luksClose(self):
     if for_real:
         os.system("cryptsetup luksClose %s" % (mapper_name))
     else:
         debugPrint("Closing luks partition")
示例#45
0
文件: devices.py 项目: effigies/tedd
def zeroFill(device):
        if for_real:
            os.system("dd if=/dev/zero of=%s" % device.path)
        else:
            debugPrint("Filling %s zeroes"% device.path)
示例#46
0
 def fillPartition(self):
     debugPrint("%s.fillPartition: Not written!" % self.name)
示例#47
0
 def freeSpace(self):
     debugPrint("%s.freeSpace: Not written!" % self.name)
示例#48
0
 def shrink(self, newSize):
     debugPrint("%s.shrink: %s cannot shrink!" % (self.name, self.name.upper()))
示例#49
0
 def format(self, journaling=True):
     if for_real:
         os.system("mkfs.reiserfs -q %s" % (self.partition.path))
     else:
         debugPrint("Formatted reiser volume")
     self.free_space, self.free_blocks, self.block_count = self.freeSpace()
示例#50
0
 def shrink(self, newSize):
     debugPrint("%s.shrink: Not Written!" % (self.name, self.name.upper()))
示例#51
0
 def fillPartition(self):
     if for_real:
         debugPrint("resize_reiserfs %s" % (self.partition.path))
         os.system("yes | resize_reiserfs %s" % (self.partition.path))
     else:
         debugPrint("Filled available space")
示例#52
0
 def fillPartition(self):
     if for_real:
         os.system("e2fsck -f %s" % self.partition.path)
         os.system("resize2fs %s" % (self.partition.path))
     else:
         debugPrint("Filled available space")
示例#53
0
文件: luks.py 项目: effigies/tedd
 def luksFormat(self):
     if for_real:
         os.system("echo -n %s | cryptsetup luksFormat -q %s " % (self.password, self.device.path))
     else:
         debugPrint("Creating a luks partition")