Commit 4026505c by Csók Tamás

client: few flake8 correction

parent 1fa0050b
...@@ -47,10 +47,10 @@ def parse_arguments(): ...@@ -47,10 +47,10 @@ def parse_arguments():
parser.add_argument("-p", "--password", type=str) parser.add_argument("-p", "--password", type=str)
parser.add_argument( parser.add_argument(
"-d", "--driver", "-d", "--driver",
help = "Select webdriver. Aside from Firefox, you have to install "+ help="Select webdriver. Aside from Firefox, you have to install "
"first the proper driver.", type=str, + "first the proper driver.", type=str,
choices = ['firefox', 'chrome', 'ie', 'opera'], choices=['firefox', 'chrome', 'ie', 'opera'],
default = "firefox") default="firefox")
args = parser.parse_args() args = parser.parse_args()
return args return args
...@@ -108,7 +108,7 @@ class Browser: ...@@ -108,7 +108,7 @@ class Browser:
vm.state, vm.protocol = "", "NONE" vm.state, vm.protocol = "", "NONE"
try: try:
while vm.state.upper()[:3] not in ("FUT", "RUN"): while vm.state.upper()[:3] not in ("FUT", "RUN"):
element = WebDriverWait(driver,7200).until( WebDriverWait(driver, 7200).until(
EC.presence_of_element_located(( EC.presence_of_element_located((
By.CSS_SELECTOR, By.CSS_SELECTOR,
"#vm-details-pw-eye.fa.fa-eye-slash"))) "#vm-details-pw-eye.fa.fa-eye-slash")))
...@@ -132,6 +132,7 @@ class Browser: ...@@ -132,6 +132,7 @@ class Browser:
raise raise
return vm return vm
def main(): def main():
""" """
Main program Main program
...@@ -141,7 +142,7 @@ def main(): ...@@ -141,7 +142,7 @@ def main():
if args.uri is not None: if args.uri is not None:
vm = Struct() vm = Struct()
vm.protocol, vm.user, vm.password, vm.host, vm.port = \ vm.protocol, vm.user, vm.password, vm.host, vm.port = \
args.uri.split(':',4) args.uri.split(':', 4)
vm.protocol = vm.protocol.upper() vm.protocol = vm.protocol.upper()
vm.state = "RUN" vm.state = "RUN"
else: else:
......
...@@ -22,7 +22,7 @@ class NXKeyGen: ...@@ -22,7 +22,7 @@ class NXKeyGen:
def __init__(self, password): def __init__(self, password):
""" """
Initialize the class Initialize the class
Keyword arguments: Keyword arguments:
@param password -- Password that will be scrambled @param password -- Password that will be scrambled
""" """
...@@ -31,7 +31,7 @@ class NXKeyGen: ...@@ -31,7 +31,7 @@ class NXKeyGen:
def getEncrypted(self): def getEncrypted(self):
""" """
Encrypt (scramble) the given password Encrypt (scramble) the given password
Keyword arguments: Keyword arguments:
@return scrambleString -- Scrambled version of the original @return scrambleString -- Scrambled version of the original
password password
...@@ -41,7 +41,7 @@ class NXKeyGen: ...@@ -41,7 +41,7 @@ class NXKeyGen:
def getvalidCharList(self, pos): def getvalidCharList(self, pos):
""" """
Valid character list Valid character list
Keyword arguments: Keyword arguments:
@return validcharlist -- List of the valid characters @return validcharlist -- List of the valid characters
""" """
...@@ -60,7 +60,7 @@ class NXKeyGen: ...@@ -60,7 +60,7 @@ class NXKeyGen:
def encodePassword(self, p): def encodePassword(self, p):
""" """
Password encoder Password encoder
Keyword arguments: Keyword arguments:
@return sPass -- Encoded password @return sPass -- Encoded password
""" """
...@@ -79,7 +79,7 @@ class NXKeyGen: ...@@ -79,7 +79,7 @@ class NXKeyGen:
def findCharInList(self, c): def findCharInList(self, c):
""" """
Character position finder Character position finder
Keyword arguments: Keyword arguments:
@param c -- Character that needs to be matched if valid @param c -- Character that needs to be matched if valid
@return i -- Place where the character is in the valid list @return i -- Place where the character is in the valid list
...@@ -91,11 +91,11 @@ class NXKeyGen: ...@@ -91,11 +91,11 @@ class NXKeyGen:
i = j i = j
return i return i
return i return i
def getRandomValidCharFromList(self): def getRandomValidCharFromList(self):
""" """
Random valid character getter Random valid character getter
Keyword arguments: Keyword arguments:
@return char -- Valid character placed 0-60 in the valid list @return char -- Valid character placed 0-60 in the valid list
""" """
...@@ -104,7 +104,7 @@ class NXKeyGen: ...@@ -104,7 +104,7 @@ class NXKeyGen:
def scrambleString(self, s): def scrambleString(self, s):
""" """
Password scrambler Password scrambler
Keyword arguments: Keyword arguments:
@param s -- Password that needs to be scrambled @param s -- Password that needs to be scrambled
@return sRet -- NoMachine NX scrambled password @return sRet -- NoMachine NX scrambled password
...@@ -136,7 +136,7 @@ class NXKeyGen: ...@@ -136,7 +136,7 @@ class NXKeyGen:
sRet = sRet + c2 sRet = sRet + c2
return escape(sRet) return escape(sRet)
def substr_replace(self,in_str,ch,pos,qt): def substr_replace(self, in_str, ch, pos, qt):
""" """
Replace a character at a special position Replace a character at a special position
""" """
......
...@@ -13,9 +13,10 @@ import shutil ...@@ -13,9 +13,10 @@ import shutil
from win32com.shell import shell, shellcon from win32com.shell import shell, shellcon
import windowsclasses import windowsclasses
try: try:
from collections import * # noqa from collections import * # noqa
except ImportError: except ImportError:
from OrderedDict import * # noqa from OrderedDict import * # noqa
def parse_arguments(): def parse_arguments():
""" """
...@@ -27,10 +28,10 @@ def parse_arguments(): ...@@ -27,10 +28,10 @@ def parse_arguments():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument( parser.add_argument(
"-d", "--driver", "-d", "--driver",
help="Select webdriver. Aside from Firefox, you have to install "+ help="Select webdriver. Aside from Firefox, you have to install "
"first the proper driver.", type=str, default="firefox", + "first the proper driver.", type=str, default="firefox",
required=False, choices=['firefox', 'chrome', required=False, choices=['firefox', 'chrome',
'iexplore', 'opera']) 'iexplore', 'opera'])
if windowsclasses.DecideArchitecture.Is64Windows(): if windowsclasses.DecideArchitecture.Is64Windows():
local_default = (windowsclasses.DecideArchitecture.GetProgramFiles64() local_default = (windowsclasses.DecideArchitecture.GetProgramFiles64()
+ "\\CIRCLE\\") + "\\CIRCLE\\")
...@@ -92,7 +93,7 @@ def main(): ...@@ -92,7 +93,7 @@ def main():
try: try:
args = parse_arguments() args = parse_arguments()
shortcut = pythoncom.CoCreateInstance( shortcut = pythoncom.CoCreateInstance(
shell.CLSID_ShellLink, shell.CLSID_ShellLink,
None, None,
pythoncom.CLSCTX_INPROC_SERVER, pythoncom.CLSCTX_INPROC_SERVER,
shell.IID_IShellLink shell.IID_IShellLink
......
...@@ -11,11 +11,11 @@ Currently here: ...@@ -11,11 +11,11 @@ Currently here:
import os import os
import argparse import argparse
import errno import errno
from _winreg import * # noqa from _winreg import * # noqa
try: try:
from collections import * # noqa from collections import * # noqa
except ImporError: except ImporError:
from OrderedDict import * # noqa from OrderedDict import * # noqa
def parse_arguments(): def parse_arguments():
...@@ -36,7 +36,7 @@ def parse_arguments(): ...@@ -36,7 +36,7 @@ def parse_arguments():
action="store_true") action="store_true")
parser.add_argument( parser.add_argument(
"-r", "--registry", "-r", "--registry",
help="Which HKEY_* const registry type the program should use", help="Which HKEY_* const registry type the program should use",
type=str, choices=['HKLM', 'HKCR', 'HKCU', 'HKU', 'HKPD', 'HKCC'], type=str, choices=['HKLM', 'HKCR', 'HKCU', 'HKU', 'HKPD', 'HKCC'],
default="HKLM") default="HKLM")
args = parser.parse_args() args = parser.parse_args()
...@@ -116,13 +116,13 @@ class RegistryHandler: ...@@ -116,13 +116,13 @@ class RegistryHandler:
self, dict_chain, both=False, architect=KEY_WOW64_64KEY, self, dict_chain, both=False, architect=KEY_WOW64_64KEY,
needed_rights=KEY_ALL_ACCESS): needed_rights=KEY_ALL_ACCESS):
"""" """"
Create registry key and value multilevel tree by chained Create registry key and value multilevel tree by chained
dictionaries. dictionaries.
Can raise AttributeError if the provided dict chain isn't Can raise AttributeError if the provided dict chain isn't
correct correct
Keyword arguments: Keyword arguments:
@param key_value_chain -- The dict chain containing all the @param key_value_chain -- The dict chain containing all the
information information
@param both -- Whether create the registry in WOW64 @param both -- Whether create the registry in WOW64
node too node too
...@@ -138,19 +138,19 @@ class RegistryHandler: ...@@ -138,19 +138,19 @@ class RegistryHandler:
if not DecideArchitecture.Is64Windows(): if not DecideArchitecture.Is64Windows():
architect = 0 architect = 0
connected_registy = self.connect_registry() connected_registy = self.connect_registry()
if (isinstance(dict_chain, dict) if (isinstance(dict_chain, dict)
or isinstance(dict_chain, OrderedDict)): or isinstance(dict_chain, OrderedDict)):
for key, value in dict_chain.iteritems(): for key, value in dict_chain.iteritems():
if isinstance(value, dict) or isinstance(value, OrderedDict): if isinstance(value, dict) or isinstance(value, OrderedDict):
temp_dict = OrderedDict() temp_dict = OrderedDict()
for my_key, my_value in value.iteritems(): for my_key, my_value in value.iteritems():
temp_dict[key+"\\"+my_key] = my_value temp_dict[key+"\\"+my_key] = my_value
self.create_registry_from_dict_chain( self.create_registry_from_dict_chain(
temp_dict, False, architect, needed_rights) temp_dict, False, architect, needed_rights)
else: else:
if isinstance(value, list): if isinstance(value, list):
if len(value)%2 != 0: if len(value) % 2 != 0:
#print "Not enough member in the list" # print "Not enough member in the list"
raise AttributeError raise AttributeError
else: else:
new_key = CreateKeyEx( new_key = CreateKeyEx(
...@@ -164,7 +164,7 @@ class RegistryHandler: ...@@ -164,7 +164,7 @@ class RegistryHandler:
my_key = None my_key = None
SetValueEx( SetValueEx(
new_key, my_key, 0, REG_SZ, my_value) new_key, my_key, 0, REG_SZ, my_value)
else: else:
new_key = CreateKeyEx( new_key = CreateKeyEx(
connected_registy, key, 0, connected_registy, key, 0,
needed_rights | architect) needed_rights | architect)
...@@ -173,7 +173,7 @@ class RegistryHandler: ...@@ -173,7 +173,7 @@ class RegistryHandler:
print "The provided attribute wasn't a dictionary chain" print "The provided attribute wasn't a dictionary chain"
raise AttributeError raise AttributeError
def get_key(self, key_name, needed_rights = KEY_ALL_ACCESS): def get_key(self, key_name, needed_rights=KEY_ALL_ACCESS):
""" """
Getting a registry value by it's key's name Getting a registry value by it's key's name
Can raise KeyError if key is not found in the registry Can raise KeyError if key is not found in the registry
...@@ -194,8 +194,8 @@ class RegistryHandler: ...@@ -194,8 +194,8 @@ class RegistryHandler:
connected_registy = self.connect_registry() connected_registy = self.connect_registry()
architect = 0 architect = 0
if DecideArchitecture.Is64Windows(): if DecideArchitecture.Is64Windows():
architect = KEY_WOW64_64KEY architect = KEY_WOW64_64KEY
try: try:
key = OpenKey(connected_registy, key_name, 0, key = OpenKey(connected_registy, key_name, 0,
needed_rights | architect) needed_rights | architect)
except WindowsError: except WindowsError:
...@@ -222,23 +222,23 @@ class RegistryHandler: ...@@ -222,23 +222,23 @@ class RegistryHandler:
Keyword arguments: Keyword arguments:
@param key_name -- The specific key name of which subkey's @param key_name -- The specific key name of which subkey's
we are interested in we are interested in
@param subkey_list -- List containing all the subkeys names @param subkey_list -- List containing all the subkeys names
which values we are interested in which values we are interested in
@param subroutine -- Whether suppress exception about not @param subroutine -- Whether suppress exception about not
having enough results or not having enough results or not
(default: False) (default: False)
@param depth -- How depth the search should go for @param depth -- How depth the search should go for
[options: key, subkeys, all] [options: key, subkeys, all]
(default: subkeys) (default: subkeys)
@return results{} -- Dictionary with the subkey_name - value @return results{} -- Dictionary with the subkey_name - value
combinations as keys and values combinations as keys and values
""" """
if depth == "key": if depth == "key":
int_depth = 0; int_depth = 0
elif depth == "subkeys": elif depth == "subkeys":
int_depth = 1; int_depth = 1
elif depth == "all": elif depth == "all":
int_depth = 2; int_depth = 2
else: else:
raise AttributeError raise AttributeError
try: try:
......
...@@ -47,10 +47,10 @@ def parse_arguments(): ...@@ -47,10 +47,10 @@ def parse_arguments():
parser.add_argument("-p", "--password", type=str) parser.add_argument("-p", "--password", type=str)
parser.add_argument( parser.add_argument(
"-d", "--driver", "-d", "--driver",
help = "Select webdriver. Aside from Firefox, you have to install "+ help="Select webdriver. Aside from Firefox, you have to install "
"first the proper driver.", type=str, + "first the proper driver.", type=str,
choices = ['firefox', 'chrome', 'ie', 'opera'], choices=['firefox', 'chrome', 'ie', 'opera'],
default = "firefox") default="firefox")
args = parser.parse_args() args = parser.parse_args()
return args return args
...@@ -108,7 +108,7 @@ class Browser: ...@@ -108,7 +108,7 @@ class Browser:
vm.state, vm.protocol = "", "NONE" vm.state, vm.protocol = "", "NONE"
try: try:
while vm.state.upper()[:3] not in ("FUT", "RUN"): while vm.state.upper()[:3] not in ("FUT", "RUN"):
element = WebDriverWait(driver,7200).until( WebDriverWait(driver, 7200).until(
EC.presence_of_element_located(( EC.presence_of_element_located((
By.CSS_SELECTOR, By.CSS_SELECTOR,
"#vm-details-pw-eye.fa.fa-eye-slash"))) "#vm-details-pw-eye.fa.fa-eye-slash")))
...@@ -132,6 +132,7 @@ class Browser: ...@@ -132,6 +132,7 @@ class Browser:
raise raise
return vm return vm
def main(): def main():
""" """
Main program Main program
...@@ -141,7 +142,7 @@ def main(): ...@@ -141,7 +142,7 @@ def main():
if args.uri is not None: if args.uri is not None:
vm = Struct() vm = Struct()
vm.protocol, vm.user, vm.password, vm.host, vm.port = \ vm.protocol, vm.user, vm.password, vm.host, vm.port = \
args.uri.split(':',4) args.uri.split(':', 4)
vm.protocol = vm.protocol.upper() vm.protocol = vm.protocol.upper()
vm.state = "RUN" vm.state = "RUN"
else: else:
......
...@@ -22,7 +22,7 @@ class NXKeyGen: ...@@ -22,7 +22,7 @@ class NXKeyGen:
def __init__(self, password): def __init__(self, password):
""" """
Initialize the class Initialize the class
Keyword arguments: Keyword arguments:
@param password -- Password that will be scrambled @param password -- Password that will be scrambled
""" """
...@@ -31,7 +31,7 @@ class NXKeyGen: ...@@ -31,7 +31,7 @@ class NXKeyGen:
def getEncrypted(self): def getEncrypted(self):
""" """
Encrypt (scramble) the given password Encrypt (scramble) the given password
Keyword arguments: Keyword arguments:
@return scrambleString -- Scrambled version of the original @return scrambleString -- Scrambled version of the original
password password
...@@ -41,7 +41,7 @@ class NXKeyGen: ...@@ -41,7 +41,7 @@ class NXKeyGen:
def getvalidCharList(self, pos): def getvalidCharList(self, pos):
""" """
Valid character list Valid character list
Keyword arguments: Keyword arguments:
@return validcharlist -- List of the valid characters @return validcharlist -- List of the valid characters
""" """
...@@ -60,7 +60,7 @@ class NXKeyGen: ...@@ -60,7 +60,7 @@ class NXKeyGen:
def encodePassword(self, p): def encodePassword(self, p):
""" """
Password encoder Password encoder
Keyword arguments: Keyword arguments:
@return sPass -- Encoded password @return sPass -- Encoded password
""" """
...@@ -79,7 +79,7 @@ class NXKeyGen: ...@@ -79,7 +79,7 @@ class NXKeyGen:
def findCharInList(self, c): def findCharInList(self, c):
""" """
Character position finder Character position finder
Keyword arguments: Keyword arguments:
@param c -- Character that needs to be matched if valid @param c -- Character that needs to be matched if valid
@return i -- Place where the character is in the valid list @return i -- Place where the character is in the valid list
...@@ -91,11 +91,11 @@ class NXKeyGen: ...@@ -91,11 +91,11 @@ class NXKeyGen:
i = j i = j
return i return i
return i return i
def getRandomValidCharFromList(self): def getRandomValidCharFromList(self):
""" """
Random valid character getter Random valid character getter
Keyword arguments: Keyword arguments:
@return char -- Valid character placed 0-60 in the valid list @return char -- Valid character placed 0-60 in the valid list
""" """
...@@ -104,7 +104,7 @@ class NXKeyGen: ...@@ -104,7 +104,7 @@ class NXKeyGen:
def scrambleString(self, s): def scrambleString(self, s):
""" """
Password scrambler Password scrambler
Keyword arguments: Keyword arguments:
@param s -- Password that needs to be scrambled @param s -- Password that needs to be scrambled
@return sRet -- NoMachine NX scrambled password @return sRet -- NoMachine NX scrambled password
...@@ -136,7 +136,7 @@ class NXKeyGen: ...@@ -136,7 +136,7 @@ class NXKeyGen:
sRet = sRet + c2 sRet = sRet + c2
return escape(sRet) return escape(sRet)
def substr_replace(self,in_str,ch,pos,qt): def substr_replace(self, in_str, ch, pos, qt):
""" """
Replace a character at a special position Replace a character at a special position
""" """
......
...@@ -13,9 +13,10 @@ import shutil ...@@ -13,9 +13,10 @@ import shutil
from win32com.shell import shell, shellcon from win32com.shell import shell, shellcon
import windowsclasses import windowsclasses
try: try:
from collections import * # noqa from collections import * # noqa
except ImportError: except ImportError:
from OrderedDict import * # noqa from OrderedDict import * # noqa
def parse_arguments(): def parse_arguments():
""" """
...@@ -27,10 +28,10 @@ def parse_arguments(): ...@@ -27,10 +28,10 @@ def parse_arguments():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument( parser.add_argument(
"-d", "--driver", "-d", "--driver",
help="Select webdriver. Aside from Firefox, you have to install "+ help="Select webdriver. Aside from Firefox, you have to install "
"first the proper driver.", type=str, default="firefox", + "first the proper driver.", type=str, default="firefox",
required=False, choices=['firefox', 'chrome', required=False, choices=['firefox', 'chrome',
'iexplore', 'opera']) 'iexplore', 'opera'])
if windowsclasses.DecideArchitecture.Is64Windows(): if windowsclasses.DecideArchitecture.Is64Windows():
local_default = (windowsclasses.DecideArchitecture.GetProgramFiles64() local_default = (windowsclasses.DecideArchitecture.GetProgramFiles64()
+ "\\CIRCLE\\") + "\\CIRCLE\\")
...@@ -92,7 +93,7 @@ def main(): ...@@ -92,7 +93,7 @@ def main():
try: try:
args = parse_arguments() args = parse_arguments()
shortcut = pythoncom.CoCreateInstance( shortcut = pythoncom.CoCreateInstance(
shell.CLSID_ShellLink, shell.CLSID_ShellLink,
None, None,
pythoncom.CLSCTX_INPROC_SERVER, pythoncom.CLSCTX_INPROC_SERVER,
shell.IID_IShellLink shell.IID_IShellLink
......
...@@ -11,11 +11,11 @@ Currently here: ...@@ -11,11 +11,11 @@ Currently here:
import os import os
import argparse import argparse
import errno import errno
from _winreg import * # noqa from _winreg import * # noqa
try: try:
from collections import * # noqa from collections import * # noqa
except ImporError: except ImporError:
from OrderedDict import * # noqa from OrderedDict import * # noqa
def parse_arguments(): def parse_arguments():
...@@ -36,7 +36,7 @@ def parse_arguments(): ...@@ -36,7 +36,7 @@ def parse_arguments():
action="store_true") action="store_true")
parser.add_argument( parser.add_argument(
"-r", "--registry", "-r", "--registry",
help="Which HKEY_* const registry type the program should use", help="Which HKEY_* const registry type the program should use",
type=str, choices=['HKLM', 'HKCR', 'HKCU', 'HKU', 'HKPD', 'HKCC'], type=str, choices=['HKLM', 'HKCR', 'HKCU', 'HKU', 'HKPD', 'HKCC'],
default="HKLM") default="HKLM")
args = parser.parse_args() args = parser.parse_args()
...@@ -116,13 +116,13 @@ class RegistryHandler: ...@@ -116,13 +116,13 @@ class RegistryHandler:
self, dict_chain, both=False, architect=KEY_WOW64_64KEY, self, dict_chain, both=False, architect=KEY_WOW64_64KEY,
needed_rights=KEY_ALL_ACCESS): needed_rights=KEY_ALL_ACCESS):
"""" """"
Create registry key and value multilevel tree by chained Create registry key and value multilevel tree by chained
dictionaries. dictionaries.
Can raise AttributeError if the provided dict chain isn't Can raise AttributeError if the provided dict chain isn't
correct correct
Keyword arguments: Keyword arguments:
@param key_value_chain -- The dict chain containing all the @param key_value_chain -- The dict chain containing all the
information information
@param both -- Whether create the registry in WOW64 @param both -- Whether create the registry in WOW64
node too node too
...@@ -138,19 +138,19 @@ class RegistryHandler: ...@@ -138,19 +138,19 @@ class RegistryHandler:
if not DecideArchitecture.Is64Windows(): if not DecideArchitecture.Is64Windows():
architect = 0 architect = 0
connected_registy = self.connect_registry() connected_registy = self.connect_registry()
if (isinstance(dict_chain, dict) if (isinstance(dict_chain, dict)
or isinstance(dict_chain, OrderedDict)): or isinstance(dict_chain, OrderedDict)):
for key, value in dict_chain.iteritems(): for key, value in dict_chain.iteritems():
if isinstance(value, dict) or isinstance(value, OrderedDict): if isinstance(value, dict) or isinstance(value, OrderedDict):
temp_dict = OrderedDict() temp_dict = OrderedDict()
for my_key, my_value in value.iteritems(): for my_key, my_value in value.iteritems():
temp_dict[key+"\\"+my_key] = my_value temp_dict[key+"\\"+my_key] = my_value
self.create_registry_from_dict_chain( self.create_registry_from_dict_chain(
temp_dict, False, architect, needed_rights) temp_dict, False, architect, needed_rights)
else: else:
if isinstance(value, list): if isinstance(value, list):
if len(value)%2 != 0: if len(value) % 2 != 0:
#print "Not enough member in the list" # print "Not enough member in the list"
raise AttributeError raise AttributeError
else: else:
new_key = CreateKeyEx( new_key = CreateKeyEx(
...@@ -164,7 +164,7 @@ class RegistryHandler: ...@@ -164,7 +164,7 @@ class RegistryHandler:
my_key = None my_key = None
SetValueEx( SetValueEx(
new_key, my_key, 0, REG_SZ, my_value) new_key, my_key, 0, REG_SZ, my_value)
else: else:
new_key = CreateKeyEx( new_key = CreateKeyEx(
connected_registy, key, 0, connected_registy, key, 0,
needed_rights | architect) needed_rights | architect)
...@@ -173,7 +173,7 @@ class RegistryHandler: ...@@ -173,7 +173,7 @@ class RegistryHandler:
print "The provided attribute wasn't a dictionary chain" print "The provided attribute wasn't a dictionary chain"
raise AttributeError raise AttributeError
def get_key(self, key_name, needed_rights = KEY_ALL_ACCESS): def get_key(self, key_name, needed_rights=KEY_ALL_ACCESS):
""" """
Getting a registry value by it's key's name Getting a registry value by it's key's name
Can raise KeyError if key is not found in the registry Can raise KeyError if key is not found in the registry
...@@ -194,8 +194,8 @@ class RegistryHandler: ...@@ -194,8 +194,8 @@ class RegistryHandler:
connected_registy = self.connect_registry() connected_registy = self.connect_registry()
architect = 0 architect = 0
if DecideArchitecture.Is64Windows(): if DecideArchitecture.Is64Windows():
architect = KEY_WOW64_64KEY architect = KEY_WOW64_64KEY
try: try:
key = OpenKey(connected_registy, key_name, 0, key = OpenKey(connected_registy, key_name, 0,
needed_rights | architect) needed_rights | architect)
except WindowsError: except WindowsError:
...@@ -222,23 +222,23 @@ class RegistryHandler: ...@@ -222,23 +222,23 @@ class RegistryHandler:
Keyword arguments: Keyword arguments:
@param key_name -- The specific key name of which subkey's @param key_name -- The specific key name of which subkey's
we are interested in we are interested in
@param subkey_list -- List containing all the subkeys names @param subkey_list -- List containing all the subkeys names
which values we are interested in which values we are interested in
@param subroutine -- Whether suppress exception about not @param subroutine -- Whether suppress exception about not
having enough results or not having enough results or not
(default: False) (default: False)
@param depth -- How depth the search should go for @param depth -- How depth the search should go for
[options: key, subkeys, all] [options: key, subkeys, all]
(default: subkeys) (default: subkeys)
@return results{} -- Dictionary with the subkey_name - value @return results{} -- Dictionary with the subkey_name - value
combinations as keys and values combinations as keys and values
""" """
if depth == "key": if depth == "key":
int_depth = 0; int_depth = 0
elif depth == "subkeys": elif depth == "subkeys":
int_depth = 1; int_depth = 1
elif depth == "all": elif depth == "all":
int_depth = 2; int_depth = 2
else: else:
raise AttributeError raise AttributeError
try: try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment