def __init__(self): super(Samovar, self).__init__(args, ['samovar.commands'], { 'description' : 'Samovar', 'options' : options.OPTIONS, 'defaults' : options.DEFAULTS, 'check_and_set_func' : options.check_and_set_func, }, os.path.join(system.get_appdata(), 'Samovar', 'Samovar.json'), Configuration) self._ui.formatter.style = StatusStyle self._ui.formatter.lexer = StatusLexer()
def __init__(self): super(Samovar, self).__init__( args, ['samovar.commands'], { 'description': 'Samovar', 'options': options.OPTIONS, 'defaults': options.DEFAULTS, 'check_and_set_func': options.check_and_set_func, }, os.path.join(system.get_appdata(), 'Samovar', 'Samovar.json'), Configuration) self._ui.formatter.style = StatusStyle self._ui.formatter.lexer = StatusLexer()
def get_key(): from tea.system import get_appdata from tea.shutil import mkdir dir_path = os.path.join(get_appdata(), 'Tea') key_path = os.path.join(dir_path, 'key.bin') if os.path.exists(dir_path) and os.path.exists(key_path): with open(key_path, 'rb') as f: cr_key = Array[Byte](map(ord, f.read())) key = ProtectedData.Unprotect(cr_key, None, DataProtectionScope.CurrentUser) return [int(k, 10) for k in key] else: mkdir(dir_path) key = _generate_key() arr_key = Array[Byte](key) cr_key = ProtectedData.Protect(arr_key, None, DataProtectionScope.CurrentUser) with open(key_path, 'wb') as f: f.write(cr_key) return key
def get_key(): from tea.system import get_appdata from tea.shell import mkdir dir_path = os.path.join(get_appdata(), 'Tea') key_path = os.path.join(dir_path, 'key.bin') if os.path.exists(dir_path) and os.path.exists(key_path): with open(key_path, 'rb') as f: cr_key = Array[Byte](map(ord, f.read())) key = ProtectedData.Unprotect(cr_key, None, DataProtectionScope.CurrentUser) return [int(k, 10) for k in key] else: mkdir(dir_path) key = _generate_key() arr_key = Array[Byte](key) cr_key = ProtectedData.Protect(arr_key, None, DataProtectionScope.CurrentUser) with open(key_path, 'wb') as f: f.write(cr_key) return key