def __init__( self, dictNavigator, title : str, onSelected ): ScreenElement.__init__( self, buttonDownMap={ Button.PRESS : self.onOkButtonDown, Button.LEFT : self.onPrevButtonDown, Button.RIGHT : self.onNextButtonDown, Button.DOWN : self.onIncreaseButtonDown, Button.UP : self.onDecreaseButtonDown } ) Log.__init__( self, className="DictNavigatorElement" ) self._titleElement = ScreenElement( isEndingLine=True, text=title ) self._upperDataElement = ScreenElement( isEndingLine=True ) self._lowerDataElement = ScreenElement() self._onSelected = onSelected self._dict = raiseNotInstanceOf( dictNavigator, DictNavigator ) self._started = False self._selectionConfirmed = False self.addChildren( [ self._titleElement, self._upperDataElement, self._lowerDataElement ] ) self.setEnablePropagation( False )
def __init__(self, command: list, callback=None, fullCallback=None, onError=None, onSuccess=None, cooldown=0, timeout=3, stdin: str = None): Log.__init__( self, "ProcHandler", "command: {command} cooldown: {c} timeout: {t}".format( command=command, c=cooldown, t=timeout)) self._command = command self._callback = [callback] if callback else [] self._fullCallback = [fullCallback] if fullCallback else [] self._onError = [onError] if onError else [] self._onSuccess = [onSuccess] if onSuccess else [] self._tempOnError = None self._tempOnSuccess = None self._cooldown = cooldown self._timeout = timeout self._cooldownTimestamp = None self._proc = None self._thread = None self._returnValue = None self._stdin = stdin.encode() if stdin else None
def __init__(self, text: str, button: object, command: list, cooldown: int = 0, timeout: int = 3, callback: object = None, isEndingLine: bool = True): ScreenElement.__init__(self) Log.__init__(self, "SimpleOsCommandElement") self._commandText = text self._button = button self._command = command self._parentCallback = callback self._procHandler = ProcHandler(command=command, onSuccess=self._onSuccess, onError=self._onError, cooldown=cooldown, timeout=timeout) self._finishedProcess = None self._dataElement = ScreenElement(isEndingLine=isEndingLine) self.addChild(self._dataElement) self._resetText()
def __init__(self, passwordList: object, keyStroker: object): ScreenElement.__init__(self, buttonDownMap={ Button.PRESS: self.onOkButtonDown, Button.LEFT: self.onPrevButtonDown, Button.RIGHT: self.onNextButtonDown, Button.DOWN: self.onIncreaseButtonDown, Button.UP: self.onDecreaseButtonDown }) Log.__init__(self, className="PasswordManagerMenuElement") self._passwordList = passwordList self._keyStroker = keyStroker self._accountDict = None self._active = False self._confirmed = False self._titleElement = ScreenElement(isEndingLine=True) self._titleElement.text, self._titleElement.color = "", Color.DEFAULT self._dataElement = ScreenElement() self.addChildren([self._titleElement, self._dataElement]) self.setEnablePropagation(False) self.setButtonDownMapActive(False)
def __init__( self ): ScreenElement.__init__( self, children=[ ScreenElement( children=[ CurrentTimeElement( "%d.%m %H:%M:%S" ) ], isEndingLine=True ), ScreenElement( children=[ ScreenElement( text="GPU ", color=Color.DEFAULT ), PollingElement( osCommand=GetGPUTempCommand, cooldown=10, timeout=3 ), ScreenElement( text=" ", color=Color.DEFAULT ), PollingElement( osCommand=GetGPUMemUsageCommand, cooldown=10, timeout=3 ) ], isEndingLine=True ), ScreenElement( children=[ ScreenElement( text="CPU ", color=Color.DEFAULT ), PollingElement( osCommand=GetCPUTempCommand, cooldown=10, timeout=3 ) ], isEndingLine=True ) ], buttonDownMap={ Button.PRESS : self.toggleSplash } ) Log.__init__( self, "Overview" ) self.menu = MainMenu() self.statusLine = ScreenElement( isEndingLine=True ) self.addChild( self.menu ) self.addChild( self.statusLine ) self.splashProcHandler = ProcHandler( command=CMD_DISPLAY_SPLASH ) self.splashDisplayed = False if Global.DISPLAY_SPLASH: self.enableSplash()
def __init__(self): ScreenElement.__init__(self, buttonDownMap={ Button.LEFT: self.onCancelButtonDown, Button.RIGHT: self.onOkButtonDown }) Log.__init__(self, className="PasswordManagerElement") self._titleElement = ScreenElement(isEndingLine=True, text="[pwman]") self._passwordList = PasswordList() self._keyStroker = KeyStroker() self._pwTextElement = PasswordEditElement() self._accountMenuElement = PasswordManagerMenuElement( passwordList=self._passwordList, keyStroker=self._keyStroker) self._dataWrapperElement = ScreenElement( children=[self._pwTextElement]) self.addChild(self._titleElement) self.addChild(self._dataWrapperElement) self._editingPassword = False self.setEnablePropagation(False)
def __init__(self, procHandlerChain: list): Log.__init__(self, "ProcHandlerChain") self._procHandlerChain = procHandlerChain self._currentHandlerIndex = 0 self._tempOnError = None self._tempOnSuccess = None self._hasProcessedOk = False
def __init__( self ): Log.__init__( self, className="ScreenManager" ) self.cursesWindow = CursesWindow() if not Global.DEBUG else None self.screen = Overview() self.isRefreshing = False self._lastRunTimestamp = None self._maxRunInterval = Global.MAIN_RUN_SECONDS self._setTimestamp()
def __init__(self): Log.__init__(self, "CharPoolManager") self._isCapsActive = False self._characters = CharPool("abcdefghijklmnopqrstuvwxyz") self._numbers = CharPool("0123456789") self._symbols = CharPool('''!"#$%&'()*#,-./:;<=>?@[\]^_|~''') self._activePool = self._characters
def __init__( self ): Log.__init__( self, "Control" ) self.log( "config: {c}".format( c=ConfigReader.getInstance().getData() ) ) if Control.screenManager or Control.buttonHandler: # "enforce singleton..." raise Exception( "initialize Control once!") Control.screenManager = ScreenManager() Control.buttonHandler = ButtonHandler( self.screenManager.onButtonDown ) GlobalRuntime.setAsyncScreenRefreshCallback( Control.procAsyncRefresh )
def __init__(self, osCommand=None, cooldown: int = 5, timeout: int = 3): ScreenElement.__init__(self) Log.__init__(self, className="PollingElement") self.dataChildElement = ScreenElement() self.addChild(self.dataChildElement) self.osCommand = osCommand self.dataProcHandler = ProcHandler(command=self.osCommand.getCommand(), callback=self._procResult, cooldown=cooldown, timeout=timeout)
def __init__( self, buttonNext = None, buttonPrev = None ): ScreenElement.__init__( self ) Log.__init__( self, "MainMenu" ) self.log( "buttonNext: {bn} buttonPrev: {bp}".format( bn=buttonNext, bp=buttonPrev ) ) self._buttonNext = buttonNext or Button.DOWN self._buttonPrev = buttonPrev or Button.UP self._keyStroker = KeyStroker() self._sysCmdProc = None self._sysCmdTempDictName = None self._sysCmdTempKeyName = None self.menuItems = [] self.menuItems.append( PasswordManagerElement() ) try: with open( SHITTALKER_FILE, "rb" ) as file: MainMenu._shitTalkerDict = DictNavigator( json.load( file ) ) self.menuItems.append( DictNavigatorElement( dictNavigator=MainMenu._shitTalkerDict, title="[shittalker]", onSelected=self._onShitTalkerSelected ) ) except Exception as e: self.log("Error loading {err}".format( err=e ) ) self.menuItems.append( DictNavigatorElement( dictNavigator=MainMenu._runtimeConfigDict, title="[cfg]", onSelected=self._onRuntimeConfigSelected )) self.menuItems.append( DictNavigatorElement( dictNavigator=MainMenu._sysCmdDict, title="[cmd]", onSelected=self._onSysCmdSelected )) self._activeElementWrapper = ScreenElement( isEndingLine=True ) self.addChildren( [ ScreenElement( text="---------------", isEndingLine=True, color=COLOR.BORDER ), self._activeElementWrapper ] ) self._activeElement = None self._activeElementIndex = 0 self._setActiveElement() self.setEnablePropagation( False )
def __init__(self, callback): Log.__init__(self, "ButtonHandler") GPIO.setmode(GPIO.BCM) self.parentCallback = callback for v in ButtonMap.values(): GPIO.setup(v, GPIO.IN, pull_up_down=GPIO.PUD_UP) # Input with pull-up ! GPIO.add_event_detect(v, GPIO.RISING, callback=self.buttonDown, bouncetime=100) self.propagating = False
def __init__(self): Log.__init__(self, "PasswordList") self._accountDictLoader = _AccountDictLoader() self._openChain = None self._evalMountedHandler = ProcHandler( command=["mountpoint", DECRYPTED_MOUNT_DIR]) self._closeChain = ProcHandlerChain( procHandlerChain=[UMOUNT_HANDLER, CRYPT_CLOSE_HANDLER]) self._umountChain = ProcHandlerChain(procHandlerChain=[UMOUNT_HANDLER]) self._cryptCloseHandler = ProcHandlerChain( procHandlerChain=[CRYPT_CLOSE_HANDLER]) self._evalMountedHandler.run( onSuccess=self._onInitialEvalMountedSuccess) self._parentOnSuccess = None self._parentOnError = None
def __init__(self, text=None, color=Color.DEFAULT, isEndingLine=None, children=None, index=-1, buttonDownMap: dict = None): Log.__init__( self, "ScreenElement", "text: {t} color: {col} isEndingLine: {l} children: {ch}".format( t=text, col=color, l=isEndingLine, ch=len(children) if children else 0)) self.text = text self.color = color self.isEndingLine = isEndingLine or False self._children = children or [] self._exclusivePropagation = False self._enablePropagation = True self._enableButtonDownMap = True self.buttonDownMap = {} if buttonDownMap == None else buttonDownMap
def __init__(self, hideUnselectedChars: bool = True): ScreenElement.__init__(self, buttonDownMap={ Button.PRESS: self.onOkButtonDown, Button.RIGHT: self.onNextButtonDown, Button.LEFT: self.onPrevButtonDown, Button.UP: self.onDecreaseButtonDown, Button.DOWN: self.onIncreaseButtonDown, Button.KEY1: self.onCapsButtonDown, Button.KEY2: self.onNumbersButtonDown, Button.KEY3: self.onSymbolsButtonDown }) Log.__init__(self, className="PasswordEditElement") self._charPoolManager = CharPoolManager() self._parentOnEditingFinished = None self._parentOnEditingCancelled = None self._titleElement = ScreenElement(isEndingLine=True) self._pwTextPreElement = ScreenElement() self._pwTextCharElement = ScreenElement(color=Color.BLACKWHITE) self._pwTextPostElement = ScreenElement() self.addChildren([ self._titleElement, self._pwTextPreElement, self._pwTextCharElement, self._pwTextPostElement ]) self._pwText = "" self._pwTextCurrentChar = "a" self._pwTextCurrentCharIndex = 0 self._hideUnselectedChars = hideUnselectedChars self.setButtonDownMapActive(False)
def __init__(self): Log.__init__(self, "KeyStroker") self._sending = False self._keyMap_en = {} self._keyMap_de = {} self._keyMap_alpha = {} KeyMapTools.genArrayLoop(self._keyMap_en, NULL_CHAR, 4, "abcdefghijklmnopqrstuvwxyz") KeyMapTools.genArrayLoop(self._keyMap_en, SHIFT_KEY, 4, "ABCDEFGHIJKLMNOPQRSTUVWXYZ") KeyMapTools.genArrayLoop(self._keyMap_en, NULL_CHAR, 30, "1234567890") KeyMapTools.genArrayLoop(self._keyMap_en, SHIFT_KEY, 30, "!@#$%^&*()") KeyMapTools.genKey(self._keyMap_en, NULL_CHAR, 40, "\n") KeyMapTools.genKey(self._keyMap_en, NULL_CHAR, 43, "\t") KeyMapTools.genKey(self._keyMap_en, NULL_CHAR, 44, " ") KeyMapTools.genArrayLoop(self._keyMap_en, NULL_CHAR, 45, "-=[]\\") KeyMapTools.genArrayLoop(self._keyMap_en, NULL_CHAR, 51, ";'`,./") KeyMapTools.genKey(self._keyMap_en, SHIFT_KEY, 52, "’") # map special ´ to ' KeyMapTools.genArrayLoop(self._keyMap_en, SHIFT_KEY, 45, "_+{}|") KeyMapTools.genArrayLoop(self._keyMap_en, SHIFT_KEY, 51, ":\"~<>?") KeyMapTools.genKey(self._keyMap_en, NULL_CHAR, 57, "caps") KeyMapTools.genArrayLoop(self._keyMap_en, NULL_CHAR, 58, [ "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12" ]) KeyMapTools.genArrayLoop(self._keyMap_en, NULL_CHAR, 144, [ "LANG1", "LANG2", "LANG3", "LANG4", "LANG5", "LANG6", "LANG7", "LANG8", "LANG9" ]) KeyMapTools.genArrayLoop(self._keyMap_de, NULL_CHAR, 4, "abcdefghijklmnopqrstuvwxzy") KeyMapTools.genArrayLoop(self._keyMap_de, SHIFT_KEY, 4, "ABCDEFGHIJKLMNOPQRSTUVWXZY") KeyMapTools.genKey(self._keyMap_de, ALT_GR_KEY, 8, "€") KeyMapTools.genKey(self._keyMap_de, ALT_GR_KEY, 16, "µ") KeyMapTools.genKey(self._keyMap_de, ALT_GR_KEY, 20, "@") KeyMapTools.genArrayLoop(self._keyMap_de, NULL_CHAR, 30, "1234567890") KeyMapTools.genArrayLoop(self._keyMap_de, SHIFT_KEY, 30, "!\"§$%&/()=") KeyMapTools.genArrayLoop(self._keyMap_de, ALT_GR_KEY, 31, "²³") KeyMapTools.genArrayLoop(self._keyMap_de, ALT_GR_KEY, 36, "{[]}") KeyMapTools.genKey(self._keyMap_de, NULL_CHAR, 40, "\n") KeyMapTools.genKey(self._keyMap_de, NULL_CHAR, 43, "\t") KeyMapTools.genArrayLoop(self._keyMap_de, NULL_CHAR, 44, " ß´ü+") KeyMapTools.genArrayLoop(self._keyMap_de, SHIFT_KEY, 45, "?`Ü*") KeyMapTools.genArrayLoop(self._keyMap_de, NULL_CHAR, 51, "öä^,.-") KeyMapTools.genArrayLoop(self._keyMap_de, SHIFT_KEY, 51, "ÖÄ°;:_") KeyMapTools.genKey(self._keyMap_de, NULL_CHAR, 49, "#") KeyMapTools.genKey(self._keyMap_de, SHIFT_KEY, 49, "'") KeyMapTools.genKey(self._keyMap_de, SHIFT_KEY, 49, "’") # map special ´ to ' KeyMapTools.genKey(self._keyMap_de, ALT_GR_KEY, 45, "\\") KeyMapTools.genKey(self._keyMap_de, ALT_GR_KEY, 48, "~") KeyMapTools.genKey(self._keyMap_de, NULL_CHAR, 57, "caps") KeyMapTools.genKey(self._keyMap_de, NULL_CHAR, 100, "<") KeyMapTools.genKey(self._keyMap_de, SHIFT_KEY, 100, ">") KeyMapTools.genKey(self._keyMap_de, ALT_GR_KEY, 100, "|") KeyMapTools.genArrayLoop(self._keyMap_de, NULL_CHAR, 58, [ "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12" ]) KeyMapTools.genArrayLoop(self._keyMap_de, NULL_CHAR, 144, [ "LANG1", "LANG2", "LANG3", "LANG4", "LANG5", "LANG6", "LANG7", "LANG8", "LANG9" ]) KeyMapTools.genArrayLoop(self._keyMap_alpha, NULL_CHAR, 4, "abcdefghijklmnopqrstuvwxzy") KeyMapTools.genArrayLoop(self._keyMap_alpha, SHIFT_KEY, 4, "ABCDEFGHIJKLMNOPQRSTUVWXZY") KeyMapTools.genArrayLoop(self._keyMap_alpha, NULL_CHAR, 30, "1234567890") self._layouts = { KEYSETTING.de: self._keyMap_de, KEYSETTING.en: self._keyMap_en, KEYSETTING.alpha: self._keyMap_alpha }
def __init__(self): Log.__init__(self, "_AccountDictLoader") self._dict = None
def __init__(self, d: dict): Log.__init__(self, "_DictNavigator") self._dict = raiseNotInstanceOf(d, dict) self._currentKeyIndex = 0 self._selectedDictPath = []
def __init__(self, poolString): Log.__init__(self, "CharPool") self._poolString = poolString self._poolStringIndex = 0 self._poolStringLength = len(self._poolString)