def test(): reg = registry.Registry("file.reg") reg.printFullTree() entries = reg.get("Uninstall") print("returned entries: " + str(len(entries))) for e in entries: print("Key: " + e.name) n = e.get("DisplayName") # print(e.values) print("Display name is: " + str(n)) reg2 = registry.Registry("missing.reg") reg2.printFullTree()
def add_to_store(input_file): if not os.path.exists(OUTPUT_PATH): print('%s does not exist, creating...' % OUTPUT_PATH) os.makedirs(OUTPUT_PATH) orig_sha1 = compute_sha1(input_file) print('Original SHA1 %s' % orig_sha1) reg = registry.Registry(OUTPUT_PATH) reg.load() existing_sha1 = reg.get_orig_sha1(input_file) if orig_sha1 == existing_sha1: print('File %s is already stored' % input_file) return elif existing_sha1: print('Something is wrong, file is already stored with SHA1: %s' % existing_sha1) return print('Storing file %s' % input_file) stored_filename = STORED_FILE_PATTERN % os.path.basename(input_file) stored_file = os.path.join(OUTPUT_PATH, os.path.basename(stored_filename)) compress(input_file, stored_file) stored_sha1 = compute_sha1(stored_file) print('Stored SHA1 %s' % stored_sha1) reg.add_file_entry(input_file, orig_sha1, stored_filename, stored_sha1) reg.save()
def __init__(self, name): """Initializes a new instance of a TestRun. Args: name: (string) The name to use for the test run. """ self.name = name self.tests = registry.AutoKeyRegistry(lambda test: test.full_name) self.variables = registry.Registry() self.setup = registry.AutoKeyRegistry(lambda func: func.__name__) self.teardown = registry.AutoKeyRegistry(lambda func: func.__name__) self.test_case_setup = registry.AutoKeyRegistry( lambda func: func.__name__) self.test_case_teardown = registry.AutoKeyRegistry( lambda func: func.__name__) self.test_suites = _TestRunSuiteRegistry(self) # Parameterizations are stored with the key as the test's full name and the # value is a parameterization registry. param_key = lambda param: param.name # pylint: disable=line-too-long parameterization_registry_factory = lambda: registry.AutoKeyRegistry( param_key) # pylint: enable=line-too-long self.parameterizations = registry.SuperRegistry( parameterization_registry_factory)
def regcheck(pid=None, wholekey=0): poss = [] robj = registry.Registry() try: kkey = robj.openKey( r'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Serenum\Enum' ) except: return -3 slist = kkey.valueNames() for each in slist: if each == 'Count' or each == 'NextInstance': continue valk = kkey.valueQuery(each) if valk[1] == 1: parts = valk[0].split('\\') if parts[0] != 'FTDIBUS': continue pieces = parts[1].split('+') if pid: if pieces[1] != pid: #print pieces,pid continue if wholekey: poss.append(parts[1]) else: poss.append(pieces[2]) return poss
def __init__(self, surface): # Set a global registry self.registry = registry.Registry() self.registry.set('surface', surface) self.registry.set('soundHandler', sounds.SoundHandler()) controls = pygame.image.load(os.path.join(fullPath, 'controls.png')) tup7 = (int(states.adjpos(*controls.get_size())[0]), int(states.adjpos(*controls.get_size())[1])) self.registry.set('controlImgs', pygame.transform.smoothscale(controls, tup7)) sprites = pygame.image.load(os.path.join(fullPath, 'sprites.png')) tup8 = (int(states.adjpos(*sprites.get_size())[0]), int(states.adjpos(*sprites.get_size())[1])) sprites = pygame.transform.scale(sprites, tup8) self.registry.set('sprites', sprites) rsprites = pygame.transform.flip(sprites, True, False) self.registry.set('rsprites', rsprites) self.registry.set('score', 0) self.registry.set('round', 1) # Start the game self.state = states.StartState(self.registry) self.state = self.state.start()
def start(): """ Create new instance of this game by calling sequence of startup functions """ # create new registry object and boot reg = registry.Registry() __boot(reg)
def setCacheLevel(val): ''' Sets the desired level of caching for all accessible objects created after this function is invoked. Immediately clears the current accessible cache. @param val: None indicating no caching is in effect. L{constants.CACHE_INTERFACES} indicating all interface query results are cached. L{constants.CACHE_PROPERTIES} indicating all basic accessible properties are cached plus all interfaces. @type val: integer ''' global _CACHE_LEVEL if _CACHE_LEVEL != val: # empty our accessible cache _ACCESSIBLE_CACHE.clear() # need to register/unregister for listeners depending on caching level if val == constants.CACHE_PROPERTIES: r = registry.Registry() r.registerEventListener(_updateCache, *constants.CACHE_EVENTS) else: r = registry.Registry() r.deregisterEventListener(_updateCache, *constants.CACHE_EVENTS) _CACHE_LEVEL = val
def readValuesFromStorage_Registry(self): #print 'readValuesFromStorage_Regitry' if not self._registry_key: self._registry = registry.Registry() self._registry_key = self._registry.openKey( self._registry_key_name) existing_keys = self._registry_key.subKeyNames() for key in existing_keys: sub_key_name = registry.keyNameMake((self._registry_key_name, key)) sub_key = self._registry.openKey(sub_key_name) val, ignore = sub_key.valueQuery() #print 'read %s as %s' % (sub_key_name, val) val = self.convert_on_read(key, val) self[key] = val self._fileread = 1 return
def __init__(self, test_case, test_run, **variables): """Initializes a new instance of a Context. The variables arg can be a dict, but it can also be an existing variable registry since it behaves like a variable dict. Args: test_case: (TestCase) The test case that the context is associated with. test_run: (TestRun) The test run that contains the test. **variables: (dict) Variables that need to be passed through to the test. """ # The test case associated with the context self.test_case = test_case # The test run that owns/controls the test. self.test_run = test_run # Set of variables available for the test. self.variables = registry.Registry() for key, value in variables.iteritems(): self.variables.register(key, value) # Of course, the context itself must be available to tests. self.variables.register('context', self)
def main(): config = configparser.ConfigParser() config.read('config.ini') ## logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.DEBUG) reg = registry.Registry() market_data = marketdata.MarketData() market_data.load_from_file() ### ??? ### ## slist = screener.ShortList() ## scr = screener.Screener() ## slist.assemble(scr) ## ## slist.save_to_file() # wait for key stroke os.system('pause')
def installedwiz(): poss = regcheck(pid='PID_E958', wholekey=1) if type(poss) == type(1): return poss, '' if len(poss) != 1: #print poss return -1, len(poss) robj = registry.Registry() try: ekey = robj.openKey( r'HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\FTDIBUS\%s\0000' % poss[0]) friend = ekey.valueQuery('FriendlyName')[0] except: return -3 p1 = friend.split('(') p2 = p1[1].split(')') pieces = poss[0].split('+') if pieces[2][:2] == 'WQ': return 4, p2[0] if pieces[2][:2] == 'WU': return 2, p2[0] return 0, p2[0]
def _regcheck(drive): robj=registry.Registry() tkey=robj.openKey('HKEY_LOCAL_MACHINE\\SYSTEM\\MountedDevices') try: val=tkey.valueQuery('\\DosDevices\\%s:' % drive) except: val=(0,0) del tkey del robj ##print val if val[1] == 3: if len(val[0]) > 30: m='' for inx,v in enumerate(val[0]): if ord(v): m=m+v else: if inx&1 == 0: #print 'huh' return 0 # drive,m if 'USBSTOR' in m: return 1 # this LOOKS like a flash drive return 0
License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ''' __version__ = "0.0.3" from comtypes.client import GetModule GetModule('oleacc.dll') from comtypes.gen.Accessibility import IAccessible GetModule(r'ia2_api_all.tlb') from comtypes.gen.IAccessible2Lib import IAccessible2 del GetModule import accessible from utils import * from constants import * import registry # Create singleton registry. Registry = registry.Registry() registry.Registry = Registry del registry
# coding=utf-8 __author__ = "Philip_Cheng" import registry import six import tensorflow as tf import framwork _layer_functions_registry = registry.Registry("layer_functions") class RegisterLayerFunction(object): def __init__(self, layer_type): """Creates a new decorator with `op_type` as the Operation type. Args: op_type: The string type of an operation. This corresponds to the `OpDef.name` field for the proto that defines the operation. """ if not isinstance(layer_type, six.string_types): raise TypeError("op_type must be a string") self._layer_type = layer_type def __call__(self, f): """Registers the function `f` as gradient function for `op_type`.""" _layer_functions_registry.register(f, self._layer_type) return f def NoGradient(op_type): """Specifies that ops of type `op_type` do not have a defined gradient. This function is only used when defining a new op type. It may be
'Square', ['num'], ['result'], {}, [UnitInstance('Mul', { 'a': '$num', 'b': '$num' })]) triple = create_derived_unit('Triple', ['num'], ['result'], {}, [ UnitInstance('Double', {}), UnitInstance('Add', { 'a': '$result', 'b': '$num' }), ]) ctx = Context() ctx.registry = registry.Registry() ctx.registry.add_unit('Context', add_ctx_unit) ctx.registry.add_unit('Add', add_unit) ctx.registry.add_unit('Add3', add_3) ctx.registry.add_unit('Mul', mul_unit) ctx.registry.add_unit('Square', square) ctx.registry.add_unit('Double', double) ctx.registry.add_unit('Triple', triple) ctx.registry.add_unit('Greet', greet_unit) ab_flow = create_from_dict({ 'abflow': [ { 'input': { 'a': "Integer", 'b': "Integer"
def guess_ext( fname, sniff_order=None, is_multi_byte=False ): """ Returns an extension that can be used in the datatype factory to generate a data for the 'fname' file >>> fname = get_test_fname('megablast_xml_parser_test1.blastxml') >>> guess_ext(fname) 'blastxml' >>> fname = get_test_fname('interval.interval') >>> guess_ext(fname) 'interval' >>> fname = get_test_fname('interval1.bed') >>> guess_ext(fname) 'bed' >>> fname = get_test_fname('test_tab.bed') >>> guess_ext(fname) 'bed' >>> fname = get_test_fname('sequence.maf') >>> guess_ext(fname) 'maf' >>> fname = get_test_fname('sequence.fasta') >>> guess_ext(fname) 'fasta' >>> fname = get_test_fname('file.html') >>> guess_ext(fname) 'html' >>> fname = get_test_fname('test.gtf') >>> guess_ext(fname) 'gtf' >>> fname = get_test_fname('test.gff') >>> guess_ext(fname) 'gff' >>> fname = get_test_fname('gff_version_3.gff') >>> guess_ext(fname) 'gff3' >>> fname = get_test_fname('temp.txt') >>> file(fname, 'wt').write("a\\t2\\nc\\t1\\nd\\t0") >>> guess_ext(fname) 'tabular' >>> fname = get_test_fname('temp.txt') >>> file(fname, 'wt').write("a 1 2 x\\nb 3 4 y\\nc 5 6 z") >>> guess_ext(fname) 'txt' >>> fname = get_test_fname('test_tab1.tabular') >>> guess_ext(fname) 'tabular' >>> fname = get_test_fname('alignment.lav') >>> guess_ext(fname) 'lav' >>> fname = get_test_fname('1.sff') >>> guess_ext(fname) 'sff' >>> fname = get_test_fname('1.bam') >>> guess_ext(fname) 'bam' >>> fname = get_test_fname('3unsorted.bam') >>> guess_ext(fname) 'bam' """ if sniff_order is None: datatypes_registry = registry.Registry() datatypes_registry.load_datatypes() sniff_order = datatypes_registry.sniff_order for datatype in sniff_order: """ Some classes may not have a sniff function, which is ok. In fact, the Tabular and Text classes are 2 examples of classes that should never have a sniff function. Since these classes are default classes, they contain few rules to filter out data of other formats, so they should be called from this function after all other datatypes in sniff_order have not been successfully discovered. """ try: if datatype.sniff( fname ): return datatype.file_ext except: pass headers = get_headers( fname, None ) is_binary = False if is_multi_byte: is_binary = False else: for hdr in headers: for char in hdr: if len( char ) > 1: for c in char: if ord( c ) > 128: is_binary = True break elif ord( char ) > 128: is_binary = True break if is_binary: break if is_binary: break if is_binary: return 'data' #default binary data type file extension if is_column_based( fname, '\t', 1, is_multi_byte=is_multi_byte ): return 'tabular' #default tabular data type file extension return 'txt' #default text data type file extension
def __init__(self, host, insecure=False, config_file="~/docker/config.json"): logging.debug("Creating new registry api: host=%s, insecure=%s, config_file=%s", host, insecure, config_file) self.registry = registry.Registry(host, insecure)
def usage(): return " USAGE:\n\t%s <.reg file> <Registry Hive file>" % (sys.argv[0]) if __name__ == '__main__': if len(sys.argv) != 3: print(usage()) sys.exit(-1) f = open(sys.argv[1]) keys = parse(f) print("Parsed .reg file") r = registry.Registry(sys.argv[2]) print("Parsed Registry file") not_found_keys = 0 incorrect_data = 0 not_found_values = 0 for k in [k for k in keys if k]: try: rk = r.open(k.name.partition("\\")[2]) for v in k.values: if v.name == ".Default": v.name = "" try: rv = rk.value(v.name)
def __init__(self): super(SerialPortWindow, self).__init__() self.setupUi(self) self.initForms() self.reg = registry.Registry() self.reg.readDB()