rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
``order`` is a crude order control mechanism, only rarely used.
``order`` is a crude order control mechanism, only rarely used (has no effect when autocommit is ``True``).
def action(self, discriminator, callable=None, args=(), kw=None, order=0): """ Register an action which will be executed when :meth:`pyramid.config.Configuration.commit` is called (or executed immediately if ``autocommit`` is ``True``).
4a5f9df2c6ecfaea37c231f5c5aa48b92e1b59ad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/4a5f9df2c6ecfaea37c231f5c5aa48b92e1b59ad/config.py
""" Commit any pending configuration actions added. If a configuration conflict has occurred, this method will raise a :exc:`ConfigurationConflictError`; within the traceback of this error will be information about the source of the conflict, usually including file names and line numbers of the cause of the
""" Commit any pending configuration actions. If a configuration conflict is detected in the pending configuration actins, this method will raise a :exc:`ConfigurationConflictError`; within the traceback of this error will be information about the source of the conflict, usually including file names and line numbers of the cause of the
def commit(self): """ Commit any pending configuration actions added. If a configuration conflict has occurred, this method will raise a :exc:`ConfigurationConflictError`; within the traceback of this error will be information about the source of the conflict, usually including file names and line numbers of the cause of the configuration conflicts.""" if self._ctx is None: return self._ctx.execute_actions() # unwrap and reset the context self._ctx = None
4a5f9df2c6ecfaea37c231f5c5aa48b92e1b59ad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/4a5f9df2c6ecfaea37c231f5c5aa48b92e1b59ad/config.py
sourcefiles = []
_context = self._ctx if _context is None: _context = self._ctx = self._make_context(self.autocommit)
def main(global_config, **settings): config = Configurator() config.include('myapp.myconfig.configure')
4a5f9df2c6ecfaea37c231f5c5aa48b92e1b59ad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/4a5f9df2c6ecfaea37c231f5c5aa48b92e1b59ad/config.py
sourcefiles.append((sourcefile, c, module)) _context = self._ctx if _context is None: _context = self._ctx = self._make_context(self.autocommit) for filename, func, module in sourcefiles: spec = module.__name__ + ':' + func.__name__
spec = module.__name__ + ':' + c.__name__
def main(global_config, **settings): config = Configurator() config.include('myapp.myconfig.configure')
4a5f9df2c6ecfaea37c231f5c5aa48b92e1b59ad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/4a5f9df2c6ecfaea37c231f5c5aa48b92e1b59ad/config.py
context.basepath = os.path.dirname(filename)
context.basepath = os.path.dirname(sourcefile)
def main(global_config, **settings): config = Configurator() config.include('myapp.myconfig.configure')
4a5f9df2c6ecfaea37c231f5c5aa48b92e1b59ad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/4a5f9df2c6ecfaea37c231f5c5aa48b92e1b59ad/config.py
func(config)
c(config)
def main(global_config, **settings): config = Configurator() config.include('myapp.myconfig.configure')
4a5f9df2c6ecfaea37c231f5c5aa48b92e1b59ad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/4a5f9df2c6ecfaea37c231f5c5aa48b92e1b59ad/config.py
path = os.path.abspath(__file__) if path.endswith('pyc'): path = path[:-1] self.assertEqual(factory.path, path)
path = os.path.abspath(__file__).split('$')[0] self.failUnless(factory.path.startswith(path))
def test_spec_notyetregistered(self): import os from pyramid import tests module_name = tests.__name__ relpath = 'test_renderers.py' renderer = {} factory = DummyFactory(renderer) spec = '%s:%s' % (module_name, relpath) info = DummyRendererInfo({ 'name':spec, 'package':None, 'registry':self.config.registry, 'settings':{}, 'type':'type', }) result = self._callFUT(info, factory) self.failUnless(result is renderer) path = os.path.abspath(__file__) if path.endswith('pyc'): # pragma: no cover path = path[:-1] self.assertEqual(factory.path, path) self.assertEqual(factory.kw, {})
991a26169252e498e8e0576fc6d88514624b72d3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/991a26169252e498e8e0576fc6d88514624b72d3/test_renderers.py
usage = '\n' + __doc__
def get_app(config_file, name, loadapp=loadapp): """ Return the WSGI application named ``name`` in the PasteDeploy config file ``config_file``""" config_name = 'config:%s' % config_file here_dir = os.getcwd() app = loadapp(config_name, name=name, relative_to=here_dir) return app
791a23ffbba7d22f2b66a04868f76fd97740d618 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/791a23ffbba7d22f2b66a04868f76fd97740d618/paster.py
result, passing ``_app_url`` within the ``**kw`` values passed to ``route_path`` will result in an exception. """ return route_url(route_name, request, *elements, _app_url='', **kw)
result, any ``_app_url`` pass within the ``**kw`` values to ``route_path`` will be ignored. """ kw['_app_url'] = '' return route_url(route_name, request, *elements, **kw)
def route_path(route_name, request, *elements, **kw): """Generates a path (aka a 'relative URL', a URL minus the host, scheme, and port) for a named :app:`Pyramid` :term:`route configuration`. .. note:: Calling :meth:`pyramid.Request.route_path` can be used to achieve the same result as :func:`pyramid.url.route_path`. This function accepts the same argument as :func:`pyramid.url.route_url` and performs the same duty. It just omits the host, port, and scheme information in the return value; only the path, query parameters, and anchor data are present in the returned string. For example, if you've defined a route named 'foobar' with the path ``/:foo/:bar``, this call to ``route_path``:: route_path('foobar', request, foo='1', bar='2') Will return the string ``/1/2``. .. note:: Calling ``route_path('route', request)`` is the same as calling ``route_url('route', request, _app_url='')``. ``route_path`` is, in fact, implemented in terms of ``route_url`` in just this way. As a result, passing ``_app_url`` within the ``**kw`` values passed to ``route_path`` will result in an exception. """ return route_url(route_name, request, *elements, _app_url='', **kw)
647815ef5fb2ca795b2d4ceb8f6740acefb7c695 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/647815ef5fb2ca795b2d4ceb8f6740acefb7c695/url.py
path_info=path_info, match_val=match_val,
path_info=path_info, match_val=match_val,
def register(): config = Configurator(reg, package=_context.package) config.add_view( permission=permission, context=context, view=view, name=name, request_type=request_type, route_name=route_name, request_method=request_method, request_param=request_param, containment=containment, attr=attr, renderer=renderer, wrapper=wrapper, xhr=xhr, accept=accept, header=header, path_info=path_info, match_val=match_val, custom_predicates=custom_predicates, _info=_context.info)
8e18ea4a560b4456ace86bdef6060304de053238 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/8e18ea4a560b4456ace86bdef6060304de053238/zcml.py
config.setup_registry(locale_negotiator='abc')
negotiator = object() config.setup_registry(locale_negotiator=negotiator)
def test_setup_registry_locale_negotiator(self): from repoze.bfg.registry import Registry from repoze.bfg.interfaces import ILocaleNegotiator reg = Registry() config = self._makeOne(reg) config.setup_registry(locale_negotiator='abc') utility = reg.getUtility(ILocaleNegotiator) self.assertEqual(utility, 'abc')
b474b5af1069c24384343766c8bfb6768a8a9520 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/b474b5af1069c24384343766c8bfb6768a8a9520/test_configuration.py
self.assertEqual(utility, 'abc')
self.assertEqual(utility, negotiator)
def test_setup_registry_locale_negotiator(self): from repoze.bfg.registry import Registry from repoze.bfg.interfaces import ILocaleNegotiator reg = Registry() config = self._makeOne(reg) config.setup_registry(locale_negotiator='abc') utility = reg.getUtility(ILocaleNegotiator) self.assertEqual(utility, 'abc')
b474b5af1069c24384343766c8bfb6768a8a9520 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/b474b5af1069c24384343766c8bfb6768a8a9520/test_configuration.py
config.setup_registry(request_factory='abc')
factory = object() config.setup_registry(request_factory=factory)
def test_setup_registry_request_factory(self): from repoze.bfg.registry import Registry from repoze.bfg.interfaces import IRequestFactory reg = Registry() config = self._makeOne(reg) config.setup_registry(request_factory='abc') utility = reg.getUtility(IRequestFactory) self.assertEqual(utility, 'abc')
b474b5af1069c24384343766c8bfb6768a8a9520 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/b474b5af1069c24384343766c8bfb6768a8a9520/test_configuration.py
self.assertEqual(utility, 'abc')
self.assertEqual(utility, factory)
def test_setup_registry_request_factory(self): from repoze.bfg.registry import Registry from repoze.bfg.interfaces import IRequestFactory reg = Registry() config = self._makeOne(reg) config.setup_registry(request_factory='abc') utility = reg.getUtility(IRequestFactory) self.assertEqual(utility, 'abc')
b474b5af1069c24384343766c8bfb6768a8a9520 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/b474b5af1069c24384343766c8bfb6768a8a9520/test_configuration.py
config.setup_registry(renderer_globals_factory='abc')
factory = object() config.setup_registry(renderer_globals_factory=factory)
def test_setup_registry_renderer_globals_factory(self): from repoze.bfg.registry import Registry from repoze.bfg.interfaces import IRendererGlobalsFactory reg = Registry() config = self._makeOne(reg) config.setup_registry(renderer_globals_factory='abc') utility = reg.getUtility(IRendererGlobalsFactory) self.assertEqual(utility, 'abc')
b474b5af1069c24384343766c8bfb6768a8a9520 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/b474b5af1069c24384343766c8bfb6768a8a9520/test_configuration.py
self.assertEqual(utility, 'abc')
self.assertEqual(utility, factory)
def test_setup_registry_renderer_globals_factory(self): from repoze.bfg.registry import Registry from repoze.bfg.interfaces import IRendererGlobalsFactory reg = Registry() config = self._makeOne(reg) config.setup_registry(renderer_globals_factory='abc') utility = reg.getUtility(IRendererGlobalsFactory) self.assertEqual(utility, 'abc')
b474b5af1069c24384343766c8bfb6768a8a9520 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/b474b5af1069c24384343766c8bfb6768a8a9520/test_configuration.py
config.set_request_factory('abc') self.assertEqual(config.registry.getUtility(IRequestFactory), 'abc')
factory = object() config.set_request_factory(factory) self.assertEqual(config.registry.getUtility(IRequestFactory), factory)
def test_set_request_factory(self): from repoze.bfg.interfaces import IRequestFactory config = self._makeOne() config.set_request_factory('abc') self.assertEqual(config.registry.getUtility(IRequestFactory), 'abc')
b474b5af1069c24384343766c8bfb6768a8a9520 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/b474b5af1069c24384343766c8bfb6768a8a9520/test_configuration.py
Default: ``None``. Maximum number of seconds after which a newly issued ticket will be considered valid. After this amount of time, the ticket will expire (effectively logging the user out). If this value is ``None``, the token never expires.
Default: ``None``. Maximum number of seconds which a newly issued ticket will be considered valid. After this amount of time, the ticket will expire (effectively logging the user out). If this value is ``None``, the ticket never expires.
def forget(self, request): return []
b955cccdd38dcb63c9cf6e49070c8acb55928250 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/b955cccdd38dcb63c9cf6e49070c8acb55928250/authentication.py
default_filters = settings.get('mako.default_filters', [])
default_filters = settings.get('mako.default_filters', None)
def renderer_factory(info): path = info.name registry = info.registry settings = info.settings lookup = registry.queryUtility(IMakoLookup) if lookup is None: reload_templates = settings.get('reload_templates', False) directories = settings.get('mako.directories') module_directory = settings.get('mako.module_directory') input_encoding = settings.get('mako.input_encoding', 'utf-8') error_handler = settings.get('mako.error_handler', None) default_filters = settings.get('mako.default_filters', []) imports = settings.get('mako.imports', []) if directories is None: raise ConfigurationError( 'Mako template used without a ``mako.directories`` setting') directories = directories.splitlines() directories = [ abspath_from_resource_spec(d) for d in directories ] lookup = PkgResourceTemplateLookup(directories=directories, module_directory=module_directory, input_encoding=input_encoding, error_handler=error_handler, default_filters=default_filters, imports=imports, filesystem_checks=reload_templates) registry_lock.acquire() try: registry.registerUtility(lookup, IMakoLookup) finally: registry_lock.release() return MakoLookupTemplateRenderer(path, lookup)
60e316de2a685a1662006047ee89aca4f442e7ef /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/60e316de2a685a1662006047ee89aca4f442e7ef/mako_templating.py
def template_renderer_factory(spec, impl):
registry_lock = threading.Lock() def template_renderer_factory(spec, impl, lock=registry_lock):
def template_renderer_factory(spec, impl): reg = get_current_registry() if os.path.isabs(spec): # 'spec' is an absolute filename if not os.path.exists(spec): raise ValueError('Missing template file: %s' % spec) renderer = reg.queryUtility(ITemplateRenderer, name=spec) if renderer is None: renderer = impl(spec) reg.registerUtility(renderer, ITemplateRenderer, name=spec) else: # spec is a package:relpath resource spec renderer = reg.queryUtility(ITemplateRenderer, name=spec) if renderer is None: try: package_name, filename = spec.split(':', 1) except ValueError: # pragma: no cover # somehow we were passed a relative pathname; this # should die package_name = caller_package(4).__name__ filename = spec abspath = pkg_resources.resource_filename(package_name, filename) if not pkg_resources.resource_exists(package_name, filename): raise ValueError( 'Missing template resource: %s (%s)' % (spec, abspath)) renderer = impl(abspath) if not _reload_resources(): # cache the template reg.registerUtility(renderer, ITemplateRenderer, name=spec) return renderer
75aa412d1dadda6c955e094e91380c7ae70695fb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/75aa412d1dadda6c955e094e91380c7ae70695fb/renderers.py
reg.registerUtility(renderer, ITemplateRenderer, name=spec)
try: lock.acquire() reg.registerUtility(renderer, ITemplateRenderer, name=spec) finally: lock.release()
def template_renderer_factory(spec, impl): reg = get_current_registry() if os.path.isabs(spec): # 'spec' is an absolute filename if not os.path.exists(spec): raise ValueError('Missing template file: %s' % spec) renderer = reg.queryUtility(ITemplateRenderer, name=spec) if renderer is None: renderer = impl(spec) reg.registerUtility(renderer, ITemplateRenderer, name=spec) else: # spec is a package:relpath resource spec renderer = reg.queryUtility(ITemplateRenderer, name=spec) if renderer is None: try: package_name, filename = spec.split(':', 1) except ValueError: # pragma: no cover # somehow we were passed a relative pathname; this # should die package_name = caller_package(4).__name__ filename = spec abspath = pkg_resources.resource_filename(package_name, filename) if not pkg_resources.resource_exists(package_name, filename): raise ValueError( 'Missing template resource: %s (%s)' % (spec, abspath)) renderer = impl(abspath) if not _reload_resources(): # cache the template reg.registerUtility(renderer, ITemplateRenderer, name=spec) return renderer
75aa412d1dadda6c955e094e91380c7ae70695fb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/75aa412d1dadda6c955e094e91380c7ae70695fb/renderers.py
reg.registerUtility(renderer, ITemplateRenderer, name=spec)
try: lock.acquire() reg.registerUtility(renderer, ITemplateRenderer, name=spec) finally: lock.release()
def template_renderer_factory(spec, impl): reg = get_current_registry() if os.path.isabs(spec): # 'spec' is an absolute filename if not os.path.exists(spec): raise ValueError('Missing template file: %s' % spec) renderer = reg.queryUtility(ITemplateRenderer, name=spec) if renderer is None: renderer = impl(spec) reg.registerUtility(renderer, ITemplateRenderer, name=spec) else: # spec is a package:relpath resource spec renderer = reg.queryUtility(ITemplateRenderer, name=spec) if renderer is None: try: package_name, filename = spec.split(':', 1) except ValueError: # pragma: no cover # somehow we were passed a relative pathname; this # should die package_name = caller_package(4).__name__ filename = spec abspath = pkg_resources.resource_filename(package_name, filename) if not pkg_resources.resource_exists(package_name, filename): raise ValueError( 'Missing template resource: %s (%s)' % (spec, abspath)) renderer = impl(abspath) if not _reload_resources(): # cache the template reg.registerUtility(renderer, ITemplateRenderer, name=spec) return renderer
75aa412d1dadda6c955e094e91380c7ae70695fb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/75aa412d1dadda6c955e094e91380c7ae70695fb/renderers.py
def __call__(self, request): environ = request.environ try: # empty if mounted under a path in mod_wsgi, for example path = environ['PATH_INFO'] or '/' except KeyError: path = '/'
d61024a2a7f625dd61b5face58f4190c9e233718 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/d61024a2a7f625dd61b5face58f4190c9e233718/urldispatch.py
self.assertEqual(lookup.directories, ['a', 'b'])
module_path = os.path.dirname(sys.modules['__main__'].__file__) self.assertEqual(lookup.directories, [ os.path.join(module_path, 'a'), os.path.join(module_path, 'b')])
def test_directories_list(self): from pyramid.mako_templating import IMakoLookup settings = {'mako.directories':['a', 'b']} info = DummyRendererInfo({ 'name':'helloworld.mak', 'package':None, 'registry':self.config.registry, 'settings':settings, }) self._callFUT(info) lookup = self.config.registry.getUtility(IMakoLookup) self.assertEqual(lookup.directories, ['a', 'b'])
b4675031ed9b2313e9df5cd73dc2575bec67192b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/b4675031ed9b2313e9df5cd73dc2575bec67192b/test_mako_templating.py
if '__init__.py' in getattr(module, '__file__', ''):
f = getattr(module, '__file__', '') if (('__init__.py' in f) or ('__init__$py' in f)):
def caller_package(level=2, caller_module=caller_module): # caller_module in arglist for tests module = caller_module(level+1) if '__init__.py' in getattr(module, '__file__', ''): # empty at >>> # Module is a package return module # Go up one level to get package package_name = module.__name__.rsplit('.', 1)[0] return sys.modules[package_name]
bfee0aa99963ec88ccb9cdf0b41f40e72ee371e4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/bfee0aa99963ec88ccb9cdf0b41f40e72ee371e4/path.py
summary = 'pyramid SQLAlchemy project using Routes (no traversal)'
summary = 'pyramid SQLAlchemy project using url dispatch (no traversal)'
def pre(self, command, output_dir, vars): # pragma: no cover vars['random_string'] = os.urandom(20).encode('hex') return Template.pre(self, command, output_dir, vars)
aa6c4267b330a5665dcb7c98d75fe21f8eeececb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/14321/aa6c4267b330a5665dcb7c98d75fe21f8eeececb/paster.py
return mysqldump_command ("-u%s %s%s --add-drop-table --default-character-set=utf8 %s" % (user, "-p" if password else "", password, db))
host = config["db_host"] return mysqldump_command ("-u%s %s%s %s --add-drop-table --default-character-set=utf8 %s" % (user, "-p" if password else "", password, "-h"+host if host <> 'localhost' else "", db))
def restore_point(): config = cmds.init.config() user = config["db_user"] password = config["db_pass"] db = config["db_db"] return mysqldump_command ("-u%s %s%s --add-drop-table --default-character-set=utf8 %s" % (user, "-p" if password else "", password, db))
0ea96c3450610cb3811024eb7e8e8a803ca09dd5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10536/0ea96c3450610cb3811024eb7e8e8a803ca09dd5/dump.py
return mysqldump_command ("--no-data --compact -u%s %s%s --default-character-set=utf8 %s" % (user, "-p" if password else "", password, db))
host = config["db_host"] return mysqldump_command ("--no-data --add-lock=false --compact -u%s %s%s %s --default-character-set=utf8 %s" % (user, "-p" if password else "", password, "-h"+host if host <> 'localhost' else "", db))
def dump(): config = cmds.init.config() user = config["db_user"] password = config["db_pass"] db = config["db_db"] return mysqldump_command ("--no-data --compact -u%s %s%s --default-character-set=utf8 %s" % (user, "-p" if password else "", password, db))
0ea96c3450610cb3811024eb7e8e8a803ca09dd5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10536/0ea96c3450610cb3811024eb7e8e8a803ca09dd5/dump.py
(output, errors) = mysql_command ("-u%s %s%s --default-character-set=utf8 %s < %s" % (user, "-p" if password else "", password, db, tempfile))
(output, errors) = mysql_command ("-u%s %s%s %s --default-character-set=utf8 %s < %s" % (user, "-p" if password else "", password, "-h"+host if host <> 'localhost' else "", db, tempfile))
def load (sql): config = cmds.init.config() user = config["db_user"] password = config["db_pass"] db = config["db_db"] tempfile = ".temp-mygrate-%s" % str(datetime.time()).replace (':', '_') f = open (tempfile, 'w') f.write (sql) f.close() (output, errors) = mysql_command ("-u%s %s%s --default-character-set=utf8 %s < %s" % (user, "-p" if password else "", password, db, tempfile)) os.unlink(tempfile) if errors: raise SQLLoadError (sql = sql, errors = errors) return True
0ea96c3450610cb3811024eb7e8e8a803ca09dd5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/10536/0ea96c3450610cb3811024eb7e8e8a803ca09dd5/dump.py
return self.GetName()
return self.name
def _toText(self): if self.type == OPERAND_IMMEDIATE: if self.value >= 0: return "0x%x" % self.value else: return "-0x%x" % abs(self.value) elif self.type == OPERAND_REGISTER: return self.GetName() elif self.type == OPERAND_ABSOLUTE_ADDRESS: return '[0x%x]' % self.disp elif self.type == OPERAND_FAR_MEMORY: return '%s:%s' % (hex(self.seg), hex(self.off)) elif (self.type == OPERAND_MEMORY): result = "[" if self.base != None: result += Registers[self.base] + "+" if self.index != None: result += Registers[self.index] if self.scale > 1: result += "*%d" % self.scale if self.disp >= 0: result += "+0x%x" % self.disp else: result += "-0x%x" % abs(self.disp) return result + "]"
28f13676d20558fc94a3b323cdcd95b1192ac993 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/28f13676d20558fc94a3b323cdcd95b1192ac993/__init__.py
p_code = byref(create_string_buffer(code))
code_buf = create_string_buffer(code) p_code = byref(code_buf)
def DecodeGenerator(codeOffset, code, dt): """ @type codeOffset: long @param codeOffset: Memory address where the code is located. This is B{not} an offset into the code! It's the actual memory address where it was read from. @type code: str @param code: Code to disassemble. @type dt: int @param dt: Disassembly type. Can be one of the following: * L{Decode16Bits}: 80286 decoding * L{Decode32Bits}: IA-32 decoding * L{Decode64Bits}: AMD64 decoding @rtype: generator of tuple( long, int, str, str ) @return: Generator of tuples. Each tuple represents an assembly instruction and contains: - Memory address of instruction. - Size of instruction in bytes. - Disassembly line of instruction. - Hexadecimal dump of instruction. @raise ValueError: Invalid arguments. """ if not code: return if not codeOffset: codeOffset = 0 if dt not in (Decode16Bits, Decode32Bits, Decode64Bits): raise ValueError("Invalid decode type value: %r" % (dt,)) codeLen = len(code) p_code = byref(create_string_buffer(code)) result = (_DecodedInst * MAX_INSTRUCTIONS)() p_result = byref(result) instruction_off = 0 while codeLen > 0: usedInstructionsCount = c_uint(0) status = internal_decode(_OffsetType(codeOffset), p_code, codeLen, dt, p_result, MAX_INSTRUCTIONS, byref(usedInstructionsCount)) if status == DECRES_INPUTERR: raise ValueError("Invalid arguments passed to distorm_decode()") used = usedInstructionsCount.value if not used: break for index in xrange(used): di = result[index] asm = di.mnemonic.p if len(di.operands.p): asm += " " + di.operands.p pydi = ( di.offset, di.size, asm, di.instructionHex.p ) instruction_off += di.size yield pydi di = result[used - 1] delta = di.offset - codeOffset + result[used -1].size if delta <= 0: break codeOffset = codeOffset + delta p_code = byref(create_string_buffer(code), instruction_off) codeLen = codeLen - delta
3f82ebcac111500fb94ed82f56165397b9844120 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/3f82ebcac111500fb94ed82f56165397b9844120/__init__.py
p_code = byref(create_string_buffer(code), instruction_off)
p_code = byref(code_buf, instruction_off)
def DecodeGenerator(codeOffset, code, dt): """ @type codeOffset: long @param codeOffset: Memory address where the code is located. This is B{not} an offset into the code! It's the actual memory address where it was read from. @type code: str @param code: Code to disassemble. @type dt: int @param dt: Disassembly type. Can be one of the following: * L{Decode16Bits}: 80286 decoding * L{Decode32Bits}: IA-32 decoding * L{Decode64Bits}: AMD64 decoding @rtype: generator of tuple( long, int, str, str ) @return: Generator of tuples. Each tuple represents an assembly instruction and contains: - Memory address of instruction. - Size of instruction in bytes. - Disassembly line of instruction. - Hexadecimal dump of instruction. @raise ValueError: Invalid arguments. """ if not code: return if not codeOffset: codeOffset = 0 if dt not in (Decode16Bits, Decode32Bits, Decode64Bits): raise ValueError("Invalid decode type value: %r" % (dt,)) codeLen = len(code) p_code = byref(create_string_buffer(code)) result = (_DecodedInst * MAX_INSTRUCTIONS)() p_result = byref(result) instruction_off = 0 while codeLen > 0: usedInstructionsCount = c_uint(0) status = internal_decode(_OffsetType(codeOffset), p_code, codeLen, dt, p_result, MAX_INSTRUCTIONS, byref(usedInstructionsCount)) if status == DECRES_INPUTERR: raise ValueError("Invalid arguments passed to distorm_decode()") used = usedInstructionsCount.value if not used: break for index in xrange(used): di = result[index] asm = di.mnemonic.p if len(di.operands.p): asm += " " + di.operands.p pydi = ( di.offset, di.size, asm, di.instructionHex.p ) instruction_off += di.size yield pydi di = result[used - 1] delta = di.offset - codeOffset + result[used -1].size if delta <= 0: break codeOffset = codeOffset + delta p_code = byref(create_string_buffer(code), instruction_off) codeLen = codeLen - delta
3f82ebcac111500fb94ed82f56165397b9844120 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/3f82ebcac111500fb94ed82f56165397b9844120/__init__.py
p_code = byref(create_string_buffer(code))
code_buf = create_string_buffer(code) p_code = byref(code_buf)
def DecomposeGenerator(codeOffset, code, dt): """ @type codeOffset: long @param codeOffset: Memory address where the code is located. This is B{not} an offset into the code! It's the actual memory address where it was read from. @type code: str @param code: Code to disassemble. @type dt: int @param dt: Disassembly type. Can be one of the following: * L{Decode16Bits}: 80286 decoding * L{Decode32Bits}: IA-32 decoding * L{Decode64Bits}: AMD64 decoding @rtype: generator of TODO @return: Generator of TODO @raise ValueError: Invalid arguments. """ if not code: return if not codeOffset: codeOffset = 0 if dt not in (Decode16Bits, Decode32Bits, Decode64Bits): raise ValueError("Invalid decode type value: %r" % (dt,)) codeLen = len(code) p_code = byref(create_string_buffer(code)) result = (_DInst * MAX_INSTRUCTIONS)() instruction_off = 0 while codeLen > 0: usedInstructionsCount = c_uint(0) codeInfo = _CodeInfo(_OffsetType(codeOffset), _OffsetType(0), cast(p_code, c_char_p), codeLen, dt, 0) status = internal_decompose(byref(codeInfo), byref(result), MAX_INSTRUCTIONS, byref(usedInstructionsCount)) if status == DECRES_INPUTERR: raise ValueError("Invalid arguments passed to distorm_decode()") used = usedInstructionsCount.value if not used: break delta = 0 for index in xrange(used): di = result[index] yield Instruction(di, code[instruction_off : instruction_off + di.size], dt) delta += di.size instruction_off += di.size if delta <= 0: break codeOffset = codeOffset + delta p_code = byref(create_string_buffer(code), instruction_off) codeLen = codeLen - delta
3f82ebcac111500fb94ed82f56165397b9844120 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/3f82ebcac111500fb94ed82f56165397b9844120/__init__.py
p_code = byref(create_string_buffer(code), instruction_off)
p_code = byref(code_buf, instruction_off)
def DecomposeGenerator(codeOffset, code, dt): """ @type codeOffset: long @param codeOffset: Memory address where the code is located. This is B{not} an offset into the code! It's the actual memory address where it was read from. @type code: str @param code: Code to disassemble. @type dt: int @param dt: Disassembly type. Can be one of the following: * L{Decode16Bits}: 80286 decoding * L{Decode32Bits}: IA-32 decoding * L{Decode64Bits}: AMD64 decoding @rtype: generator of TODO @return: Generator of TODO @raise ValueError: Invalid arguments. """ if not code: return if not codeOffset: codeOffset = 0 if dt not in (Decode16Bits, Decode32Bits, Decode64Bits): raise ValueError("Invalid decode type value: %r" % (dt,)) codeLen = len(code) p_code = byref(create_string_buffer(code)) result = (_DInst * MAX_INSTRUCTIONS)() instruction_off = 0 while codeLen > 0: usedInstructionsCount = c_uint(0) codeInfo = _CodeInfo(_OffsetType(codeOffset), _OffsetType(0), cast(p_code, c_char_p), codeLen, dt, 0) status = internal_decompose(byref(codeInfo), byref(result), MAX_INSTRUCTIONS, byref(usedInstructionsCount)) if status == DECRES_INPUTERR: raise ValueError("Invalid arguments passed to distorm_decode()") used = usedInstructionsCount.value if not used: break delta = 0 for index in xrange(used): di = result[index] yield Instruction(di, code[instruction_off : instruction_off + di.size], dt) delta += di.size instruction_off += di.size if delta <= 0: break codeOffset = codeOffset + delta p_code = byref(create_string_buffer(code), instruction_off) codeLen = codeLen - delta
3f82ebcac111500fb94ed82f56165397b9844120 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/3f82ebcac111500fb94ed82f56165397b9844120/__init__.py
Set("6b", ["IMUL"], [OPT.REG_FULL, OPT.RM_FULL, OPT.IMM8], IFlag.MODRM_REQUIRED)
Set("6b", ["IMUL"], [OPT.REG_FULL, OPT.RM_FULL, OPT.SEIMM8], IFlag.MODRM_REQUIRED)
def init_INTEGER(self): Set = lambda *args: self.SetCallback(ISetClass.INTEGER, *args)
cc989ffc89a182853265741667808e66fb2d4c3d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/cc989ffc89a182853265741667808e66fb2d4c3d/x86sets.py
if self._type == OPERAND_IMMEDIATE: if self._value >= 0: return "0x%x" % self._value
if self.type == OPERAND_IMMEDIATE: if self.value >= 0: return "0x%x" % self.value
def _toText(self): if self._type == OPERAND_IMMEDIATE: if self._value >= 0: return "0x%x" % self._value else: return "-0x%x" % abs(self._value) elif self._type == OPERAND_REGISTER: return self.GetName() elif self._type == OPERAND_ABSOLUTE_ADDRESS: return '[0x%x]' % self._disp elif self._type == OPERAND_FAR_MEMORY: return '%s:%s' % (hex(self._seg), hex(self._off)) elif (self._type == OPERAND_MEMORY): result = "[" if self._base != None: result += Registers[self._base] + "+" if self._index != None: result += Registers[self._index] if self._scale > 1: result += "*%d" % self._scale if self._disp >= 0: result += "+0x%x" % self._disp else: result += "-0x%x" % abs(self._disp) return result + "]"
b8902f36bad23fcde94df6909e52326a5452b7ff /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/b8902f36bad23fcde94df6909e52326a5452b7ff/__init__.py
return "-0x%x" % abs(self._value) elif self._type == OPERAND_REGISTER:
return "-0x%x" % abs(self.value) elif self.type == OPERAND_REGISTER:
def _toText(self): if self._type == OPERAND_IMMEDIATE: if self._value >= 0: return "0x%x" % self._value else: return "-0x%x" % abs(self._value) elif self._type == OPERAND_REGISTER: return self.GetName() elif self._type == OPERAND_ABSOLUTE_ADDRESS: return '[0x%x]' % self._disp elif self._type == OPERAND_FAR_MEMORY: return '%s:%s' % (hex(self._seg), hex(self._off)) elif (self._type == OPERAND_MEMORY): result = "[" if self._base != None: result += Registers[self._base] + "+" if self._index != None: result += Registers[self._index] if self._scale > 1: result += "*%d" % self._scale if self._disp >= 0: result += "+0x%x" % self._disp else: result += "-0x%x" % abs(self._disp) return result + "]"
b8902f36bad23fcde94df6909e52326a5452b7ff /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/b8902f36bad23fcde94df6909e52326a5452b7ff/__init__.py
elif self._type == OPERAND_ABSOLUTE_ADDRESS: return '[0x%x]' % self._disp elif self._type == OPERAND_FAR_MEMORY: return '%s:%s' % (hex(self._seg), hex(self._off)) elif (self._type == OPERAND_MEMORY):
elif self.type == OPERAND_ABSOLUTE_ADDRESS: return '[0x%x]' % self.disp elif self.type == OPERAND_FAR_MEMORY: return '%s:%s' % (hex(self.seg), hex(self.off)) elif (self.type == OPERAND_MEMORY):
def _toText(self): if self._type == OPERAND_IMMEDIATE: if self._value >= 0: return "0x%x" % self._value else: return "-0x%x" % abs(self._value) elif self._type == OPERAND_REGISTER: return self.GetName() elif self._type == OPERAND_ABSOLUTE_ADDRESS: return '[0x%x]' % self._disp elif self._type == OPERAND_FAR_MEMORY: return '%s:%s' % (hex(self._seg), hex(self._off)) elif (self._type == OPERAND_MEMORY): result = "[" if self._base != None: result += Registers[self._base] + "+" if self._index != None: result += Registers[self._index] if self._scale > 1: result += "*%d" % self._scale if self._disp >= 0: result += "+0x%x" % self._disp else: result += "-0x%x" % abs(self._disp) return result + "]"
b8902f36bad23fcde94df6909e52326a5452b7ff /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/b8902f36bad23fcde94df6909e52326a5452b7ff/__init__.py
if self._base != None: result += Registers[self._base] + "+" if self._index != None: result += Registers[self._index] if self._scale > 1: result += "*%d" % self._scale if self._disp >= 0: result += "+0x%x" % self._disp
if self.base != None: result += Registers[self.base] + "+" if self.index != None: result += Registers[self.index] if self.scale > 1: result += "*%d" % self.scale if self.disp >= 0: result += "+0x%x" % self.disp
def _toText(self): if self._type == OPERAND_IMMEDIATE: if self._value >= 0: return "0x%x" % self._value else: return "-0x%x" % abs(self._value) elif self._type == OPERAND_REGISTER: return self.GetName() elif self._type == OPERAND_ABSOLUTE_ADDRESS: return '[0x%x]' % self._disp elif self._type == OPERAND_FAR_MEMORY: return '%s:%s' % (hex(self._seg), hex(self._off)) elif (self._type == OPERAND_MEMORY): result = "[" if self._base != None: result += Registers[self._base] + "+" if self._index != None: result += Registers[self._index] if self._scale > 1: result += "*%d" % self._scale if self._disp >= 0: result += "+0x%x" % self._disp else: result += "-0x%x" % abs(self._disp) return result + "]"
b8902f36bad23fcde94df6909e52326a5452b7ff /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/b8902f36bad23fcde94df6909e52326a5452b7ff/__init__.py
result += "-0x%x" % abs(self._disp)
result += "-0x%x" % abs(self.disp)
def _toText(self): if self._type == OPERAND_IMMEDIATE: if self._value >= 0: return "0x%x" % self._value else: return "-0x%x" % abs(self._value) elif self._type == OPERAND_REGISTER: return self.GetName() elif self._type == OPERAND_ABSOLUTE_ADDRESS: return '[0x%x]' % self._disp elif self._type == OPERAND_FAR_MEMORY: return '%s:%s' % (hex(self._seg), hex(self._off)) elif (self._type == OPERAND_MEMORY): result = "[" if self._base != None: result += Registers[self._base] + "+" if self._index != None: result += Registers[self._index] if self._scale > 1: result += "*%d" % self._scale if self._disp >= 0: result += "+0x%x" % self._disp else: result += "-0x%x" % abs(self._disp) return result + "]"
b8902f36bad23fcde94df6909e52326a5452b7ff /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/b8902f36bad23fcde94df6909e52326a5452b7ff/__init__.py
asm = '%s %s' % (di.mnemonic.p, di.operands.p)
asm = di.mnemonic.p if len(di.operands.p): asm += " " + di.operands.p
def DecodeGenerator(codeOffset, code, dt): """ @type codeOffset: long @param codeOffset: Memory address where the code is located. This is B{not} an offset into the code! It's the actual memory address where it was read from. @type code: str @param code: Code to disassemble. @type dt: int @param dt: Disassembly type. Can be one of the following: * L{Decode16Bits}: 80286 decoding * L{Decode32Bits}: IA-32 decoding * L{Decode64Bits}: AMD64 decoding @rtype: generator of tuple( long, int, str, str ) @return: Generator of tuples. Each tuple represents an assembly instruction and contains: - Memory address of instruction. - Size of instruction in bytes. - Disassembly line of instruction. - Hexadecimal dump of instruction. @raise ValueError: Invalid arguments. """ if not code: return if not codeOffset: codeOffset = 0 if dt not in (Decode16Bits, Decode32Bits, Decode64Bits): raise ValueError("Invalid decode type value: %r" % (dt,)) codeLen = len(code) code = create_string_buffer(code) p_code = addressof(code) result = (_DecodedInst * MAX_INSTRUCTIONS)() p_result = byref(result) while codeLen > 0: usedInstructionsCount = c_uint(0) status = internal_decode(_OffsetType(codeOffset), p_code, codeLen, dt, p_result, MAX_INSTRUCTIONS, byref(usedInstructionsCount)) if status == DECRES_INPUTERR: raise ValueError("Invalid arguments passed to distorm_decode()") used = usedInstructionsCount.value if not used: break for index in xrange(used): di = result[index] asm = '%s %s' % (di.mnemonic.p, di.operands.p) pydi = ( di.offset, di.size, asm, di.instructionHex.p ) yield pydi di = result[used - 1] delta = di.offset - codeOffset if delta <= 0: break codeOffset = codeOffset + delta p_code = p_code + delta codeLen = codeLen - delta
005c58df4b3c5cf2af8b9028cc40a540461beeb1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/005c58df4b3c5cf2af8b9028cc40a540461beeb1/__init__.py
delta = di.offset - codeOffset
delta = di.offset - codeOffset + result[used -1].size
def DecodeGenerator(codeOffset, code, dt): """ @type codeOffset: long @param codeOffset: Memory address where the code is located. This is B{not} an offset into the code! It's the actual memory address where it was read from. @type code: str @param code: Code to disassemble. @type dt: int @param dt: Disassembly type. Can be one of the following: * L{Decode16Bits}: 80286 decoding * L{Decode32Bits}: IA-32 decoding * L{Decode64Bits}: AMD64 decoding @rtype: generator of tuple( long, int, str, str ) @return: Generator of tuples. Each tuple represents an assembly instruction and contains: - Memory address of instruction. - Size of instruction in bytes. - Disassembly line of instruction. - Hexadecimal dump of instruction. @raise ValueError: Invalid arguments. """ if not code: return if not codeOffset: codeOffset = 0 if dt not in (Decode16Bits, Decode32Bits, Decode64Bits): raise ValueError("Invalid decode type value: %r" % (dt,)) codeLen = len(code) code = create_string_buffer(code) p_code = addressof(code) result = (_DecodedInst * MAX_INSTRUCTIONS)() p_result = byref(result) while codeLen > 0: usedInstructionsCount = c_uint(0) status = internal_decode(_OffsetType(codeOffset), p_code, codeLen, dt, p_result, MAX_INSTRUCTIONS, byref(usedInstructionsCount)) if status == DECRES_INPUTERR: raise ValueError("Invalid arguments passed to distorm_decode()") used = usedInstructionsCount.value if not used: break for index in xrange(used): di = result[index] asm = '%s %s' % (di.mnemonic.p, di.operands.p) pydi = ( di.offset, di.size, asm, di.instructionHex.p ) yield pydi di = result[used - 1] delta = di.offset - codeOffset if delta <= 0: break codeOffset = codeOffset + delta p_code = p_code + delta codeLen = codeLen - delta
005c58df4b3c5cf2af8b9028cc40a540461beeb1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/005c58df4b3c5cf2af8b9028cc40a540461beeb1/__init__.py
self._type = type self._index = None self._name = "" self._size = 0 self._value = 0 self._disp = 0 self._dispSize = 0 self._base = 0
self.type = type self.index = None self.name = "" self.size = 0 self.value = 0 self.disp = 0 self.dispSize = 0 self.base = 0
def __init__(self, type, *args): self._type = type self._index = None self._name = "" self._size = 0 self._value = 0 self._disp = 0 self._dispSize = 0 self._base = 0 if type == OPERAND_IMMEDIATE: self._value = int(args[0]) self._size = args[1] elif type == OPERAND_REGISTER: self._index = args[0] self._size = args[1] self._name = Registers[self._index] elif type == OPERAND_MEMORY: self._base = args[0] if args[0] != R_NONE else None self._index = args[1] self._size = args[2] self._scale = args[3] if args[3] > 1 else 1 self._disp = int(args[4]) self._dispSize = args[5] elif type == OPERAND_ABSOLUTE_ADDRESS: self._size = args[0] self._disp = int(args[1]) self._dispSize = args[2] elif type == OPERAND_FAR_MEMORY: self._seg = args[0] self._off = args[1]
005c58df4b3c5cf2af8b9028cc40a540461beeb1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/005c58df4b3c5cf2af8b9028cc40a540461beeb1/__init__.py
self._value = int(args[0]) self._size = args[1]
self.value = int(args[0]) self.size = args[1]
def __init__(self, type, *args): self._type = type self._index = None self._name = "" self._size = 0 self._value = 0 self._disp = 0 self._dispSize = 0 self._base = 0 if type == OPERAND_IMMEDIATE: self._value = int(args[0]) self._size = args[1] elif type == OPERAND_REGISTER: self._index = args[0] self._size = args[1] self._name = Registers[self._index] elif type == OPERAND_MEMORY: self._base = args[0] if args[0] != R_NONE else None self._index = args[1] self._size = args[2] self._scale = args[3] if args[3] > 1 else 1 self._disp = int(args[4]) self._dispSize = args[5] elif type == OPERAND_ABSOLUTE_ADDRESS: self._size = args[0] self._disp = int(args[1]) self._dispSize = args[2] elif type == OPERAND_FAR_MEMORY: self._seg = args[0] self._off = args[1]
005c58df4b3c5cf2af8b9028cc40a540461beeb1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/005c58df4b3c5cf2af8b9028cc40a540461beeb1/__init__.py
self._index = args[0] self._size = args[1] self._name = Registers[self._index]
self.index = args[0] self.size = args[1] self.name = Registers[self.index]
def __init__(self, type, *args): self._type = type self._index = None self._name = "" self._size = 0 self._value = 0 self._disp = 0 self._dispSize = 0 self._base = 0 if type == OPERAND_IMMEDIATE: self._value = int(args[0]) self._size = args[1] elif type == OPERAND_REGISTER: self._index = args[0] self._size = args[1] self._name = Registers[self._index] elif type == OPERAND_MEMORY: self._base = args[0] if args[0] != R_NONE else None self._index = args[1] self._size = args[2] self._scale = args[3] if args[3] > 1 else 1 self._disp = int(args[4]) self._dispSize = args[5] elif type == OPERAND_ABSOLUTE_ADDRESS: self._size = args[0] self._disp = int(args[1]) self._dispSize = args[2] elif type == OPERAND_FAR_MEMORY: self._seg = args[0] self._off = args[1]
005c58df4b3c5cf2af8b9028cc40a540461beeb1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/005c58df4b3c5cf2af8b9028cc40a540461beeb1/__init__.py
self._base = args[0] if args[0] != R_NONE else None self._index = args[1] self._size = args[2] self._scale = args[3] if args[3] > 1 else 1 self._disp = int(args[4]) self._dispSize = args[5]
self.base = args[0] if args[0] != R_NONE else None self.index = args[1] self.size = args[2] self.scale = args[3] if args[3] > 1 else 1 self.disp = int(args[4]) self.dispSize = args[5]
def __init__(self, type, *args): self._type = type self._index = None self._name = "" self._size = 0 self._value = 0 self._disp = 0 self._dispSize = 0 self._base = 0 if type == OPERAND_IMMEDIATE: self._value = int(args[0]) self._size = args[1] elif type == OPERAND_REGISTER: self._index = args[0] self._size = args[1] self._name = Registers[self._index] elif type == OPERAND_MEMORY: self._base = args[0] if args[0] != R_NONE else None self._index = args[1] self._size = args[2] self._scale = args[3] if args[3] > 1 else 1 self._disp = int(args[4]) self._dispSize = args[5] elif type == OPERAND_ABSOLUTE_ADDRESS: self._size = args[0] self._disp = int(args[1]) self._dispSize = args[2] elif type == OPERAND_FAR_MEMORY: self._seg = args[0] self._off = args[1]
005c58df4b3c5cf2af8b9028cc40a540461beeb1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/005c58df4b3c5cf2af8b9028cc40a540461beeb1/__init__.py
self._size = args[0] self._disp = int(args[1]) self._dispSize = args[2]
self.size = args[0] self.disp = int(args[1]) self.dispSize = args[2]
def __init__(self, type, *args): self._type = type self._index = None self._name = "" self._size = 0 self._value = 0 self._disp = 0 self._dispSize = 0 self._base = 0 if type == OPERAND_IMMEDIATE: self._value = int(args[0]) self._size = args[1] elif type == OPERAND_REGISTER: self._index = args[0] self._size = args[1] self._name = Registers[self._index] elif type == OPERAND_MEMORY: self._base = args[0] if args[0] != R_NONE else None self._index = args[1] self._size = args[2] self._scale = args[3] if args[3] > 1 else 1 self._disp = int(args[4]) self._dispSize = args[5] elif type == OPERAND_ABSOLUTE_ADDRESS: self._size = args[0] self._disp = int(args[1]) self._dispSize = args[2] elif type == OPERAND_FAR_MEMORY: self._seg = args[0] self._off = args[1]
005c58df4b3c5cf2af8b9028cc40a540461beeb1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/005c58df4b3c5cf2af8b9028cc40a540461beeb1/__init__.py
self._seg = args[0] self._off = args[1] def GetType(self): return self._type def GetValue(self): return self._value def GetIndex(self): return self._index def GetName(self): return self._name def GetSize(self): return self._size def GetDisplacement(self): return self._disp def GetDisplacementSize(self): return self._dispSize def GetExpression(self): return ""
self.seg = args[0] self.off = args[1]
def __init__(self, type, *args): self._type = type self._index = None self._name = "" self._size = 0 self._value = 0 self._disp = 0 self._dispSize = 0 self._base = 0 if type == OPERAND_IMMEDIATE: self._value = int(args[0]) self._size = args[1] elif type == OPERAND_REGISTER: self._index = args[0] self._size = args[1] self._name = Registers[self._index] elif type == OPERAND_MEMORY: self._base = args[0] if args[0] != R_NONE else None self._index = args[1] self._size = args[2] self._scale = args[3] if args[3] > 1 else 1 self._disp = int(args[4]) self._dispSize = args[5] elif type == OPERAND_ABSOLUTE_ADDRESS: self._size = args[0] self._disp = int(args[1]) self._dispSize = args[2] elif type == OPERAND_FAR_MEMORY: self._seg = args[0] self._off = args[1]
005c58df4b3c5cf2af8b9028cc40a540461beeb1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/005c58df4b3c5cf2af8b9028cc40a540461beeb1/__init__.py
def __init__(self, di): "Expects a filled _DInst structure"
def __init__(self, di, instructionBytes): "Expects a filled _DInst structure, and the corresponding byte code of the whole instruction" flags = di.flags self.instructionBytes = instructionBytes
def __init__(self, di): "Expects a filled _DInst structure" self.opcode = di.opcode self.operands = [] self.flags = [] self.instructionClass = _getISC(0) self.flowControl = _getFC(0) self.address = di.addr self.size = di.size flags = di.flags
005c58df4b3c5cf2af8b9028cc40a540461beeb1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/005c58df4b3c5cf2af8b9028cc40a540461beeb1/__init__.py
flags = di.flags
self.dt = _getOpSize(flags)
def __init__(self, di): "Expects a filled _DInst structure" self.opcode = di.opcode self.operands = [] self.flags = [] self.instructionClass = _getISC(0) self.flowControl = _getFC(0) self.address = di.addr self.size = di.size flags = di.flags
005c58df4b3c5cf2af8b9028cc40a540461beeb1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/005c58df4b3c5cf2af8b9028cc40a540461beeb1/__init__.py
opcodeFmt = "%-10s %s" paramsText = ", ".join(["%s" % i for i in self.operands]) return opcodeFmt % (self.mnemonic, paramsText)
return Decode(self.address, self.instructionBytes, self.dt)[0][2]
def _toText(self): opcodeFmt = "%-10s %s" paramsText = ", ".join(["%s" % i for i in self.operands]) return opcodeFmt % (self.mnemonic, paramsText)
005c58df4b3c5cf2af8b9028cc40a540461beeb1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/005c58df4b3c5cf2af8b9028cc40a540461beeb1/__init__.py
yield Instruction(di, code[codeOffset + delta : codeOffset + delta + di.size])
def DecomposeGenerator(codeOffset, code, dt): """ @type codeOffset: long @param codeOffset: Memory address where the code is located. This is B{not} an offset into the code! It's the actual memory address where it was read from. @type code: str @param code: Code to disassemble. @type dt: int @param dt: Disassembly type. Can be one of the following: * L{Decode16Bits}: 80286 decoding * L{Decode32Bits}: IA-32 decoding * L{Decode64Bits}: AMD64 decoding @rtype: generator of TODO @return: Generator of TODO @raise ValueError: Invalid arguments. """ if not code: return if not codeOffset: codeOffset = 0 if dt not in (Decode16Bits, Decode32Bits, Decode64Bits): raise ValueError("Invalid decode type value: %r" % (dt,)) codeLen = len(code) code = create_string_buffer(code) p_code = addressof(code) result = (_DInst * MAX_INSTRUCTIONS)() p_result = byref(result) codeInfo = _CodeInfo(_OffsetType(codeOffset), p_code, codeLen, dt, 0) while codeLen > 0: usedInstructionsCount = c_uint(0) status = internal_decompose(byref(codeInfo), p_result, MAX_INSTRUCTIONS, byref(usedInstructionsCount)) if status == DECRES_INPUTERR: raise ValueError("Invalid arguments passed to distorm_decode()") used = usedInstructionsCount.value if not used: break delta = 0 for index in xrange(used): di = result[index] delta += di.size yield Instruction(di) if delta <= 0: break codeOffset = codeOffset + delta p_code = p_code + delta codeLen = codeLen - delta
005c58df4b3c5cf2af8b9028cc40a540461beeb1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/005c58df4b3c5cf2af8b9028cc40a540461beeb1/__init__.py
yield Instruction(di)
def DecomposeGenerator(codeOffset, code, dt): """ @type codeOffset: long @param codeOffset: Memory address where the code is located. This is B{not} an offset into the code! It's the actual memory address where it was read from. @type code: str @param code: Code to disassemble. @type dt: int @param dt: Disassembly type. Can be one of the following: * L{Decode16Bits}: 80286 decoding * L{Decode32Bits}: IA-32 decoding * L{Decode64Bits}: AMD64 decoding @rtype: generator of TODO @return: Generator of TODO @raise ValueError: Invalid arguments. """ if not code: return if not codeOffset: codeOffset = 0 if dt not in (Decode16Bits, Decode32Bits, Decode64Bits): raise ValueError("Invalid decode type value: %r" % (dt,)) codeLen = len(code) code = create_string_buffer(code) p_code = addressof(code) result = (_DInst * MAX_INSTRUCTIONS)() p_result = byref(result) codeInfo = _CodeInfo(_OffsetType(codeOffset), p_code, codeLen, dt, 0) while codeLen > 0: usedInstructionsCount = c_uint(0) status = internal_decompose(byref(codeInfo), p_result, MAX_INSTRUCTIONS, byref(usedInstructionsCount)) if status == DECRES_INPUTERR: raise ValueError("Invalid arguments passed to distorm_decode()") used = usedInstructionsCount.value if not used: break delta = 0 for index in xrange(used): di = result[index] delta += di.size yield Instruction(di) if delta <= 0: break codeOffset = codeOffset + delta p_code = p_code + delta codeLen = codeLen - delta
005c58df4b3c5cf2af8b9028cc40a540461beeb1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/005c58df4b3c5cf2af8b9028cc40a540461beeb1/__init__.py
p_code = pointer(create_string_buffer(code))
p_code = byref(create_string_buffer(code))
def DecodeGenerator(codeOffset, code, dt): """ @type codeOffset: long @param codeOffset: Memory address where the code is located. This is B{not} an offset into the code! It's the actual memory address where it was read from. @type code: str @param code: Code to disassemble. @type dt: int @param dt: Disassembly type. Can be one of the following: * L{Decode16Bits}: 80286 decoding * L{Decode32Bits}: IA-32 decoding * L{Decode64Bits}: AMD64 decoding @rtype: generator of tuple( long, int, str, str ) @return: Generator of tuples. Each tuple represents an assembly instruction and contains: - Memory address of instruction. - Size of instruction in bytes. - Disassembly line of instruction. - Hexadecimal dump of instruction. @raise ValueError: Invalid arguments. """ if not code: return if not codeOffset: codeOffset = 0 if dt not in (Decode16Bits, Decode32Bits, Decode64Bits): raise ValueError("Invalid decode type value: %r" % (dt,)) codeLen = len(code) p_code = pointer(create_string_buffer(code)) result = (_DecodedInst * MAX_INSTRUCTIONS)() p_result = byref(result) instruction_off = 0 while codeLen > 0: usedInstructionsCount = c_uint(0) status = internal_decode(_OffsetType(codeOffset), p_code, codeLen, dt, p_result, MAX_INSTRUCTIONS, byref(usedInstructionsCount)) if status == DECRES_INPUTERR: raise ValueError("Invalid arguments passed to distorm_decode()") used = usedInstructionsCount.value if not used: break for index in xrange(used): di = result[index] asm = di.mnemonic.p if len(di.operands.p): asm += " " + di.operands.p pydi = ( di.offset, di.size, asm, di.instructionHex.p ) instruction_off += di.size yield pydi di = result[used - 1] delta = di.offset - codeOffset + result[used -1].size if delta <= 0: break codeOffset = codeOffset + delta p_code = pointer(create_string_buffer(code[instruction_off:])) codeLen = codeLen - delta
7433c529f08a143521f1dd360cf71360105e8873 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/7433c529f08a143521f1dd360cf71360105e8873/__init__.py
p_code = pointer(create_string_buffer(code[instruction_off:]))
p_code = byref(create_string_buffer(code), instruction_off)
def DecodeGenerator(codeOffset, code, dt): """ @type codeOffset: long @param codeOffset: Memory address where the code is located. This is B{not} an offset into the code! It's the actual memory address where it was read from. @type code: str @param code: Code to disassemble. @type dt: int @param dt: Disassembly type. Can be one of the following: * L{Decode16Bits}: 80286 decoding * L{Decode32Bits}: IA-32 decoding * L{Decode64Bits}: AMD64 decoding @rtype: generator of tuple( long, int, str, str ) @return: Generator of tuples. Each tuple represents an assembly instruction and contains: - Memory address of instruction. - Size of instruction in bytes. - Disassembly line of instruction. - Hexadecimal dump of instruction. @raise ValueError: Invalid arguments. """ if not code: return if not codeOffset: codeOffset = 0 if dt not in (Decode16Bits, Decode32Bits, Decode64Bits): raise ValueError("Invalid decode type value: %r" % (dt,)) codeLen = len(code) p_code = pointer(create_string_buffer(code)) result = (_DecodedInst * MAX_INSTRUCTIONS)() p_result = byref(result) instruction_off = 0 while codeLen > 0: usedInstructionsCount = c_uint(0) status = internal_decode(_OffsetType(codeOffset), p_code, codeLen, dt, p_result, MAX_INSTRUCTIONS, byref(usedInstructionsCount)) if status == DECRES_INPUTERR: raise ValueError("Invalid arguments passed to distorm_decode()") used = usedInstructionsCount.value if not used: break for index in xrange(used): di = result[index] asm = di.mnemonic.p if len(di.operands.p): asm += " " + di.operands.p pydi = ( di.offset, di.size, asm, di.instructionHex.p ) instruction_off += di.size yield pydi di = result[used - 1] delta = di.offset - codeOffset + result[used -1].size if delta <= 0: break codeOffset = codeOffset + delta p_code = pointer(create_string_buffer(code[instruction_off:])) codeLen = codeLen - delta
7433c529f08a143521f1dd360cf71360105e8873 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/7433c529f08a143521f1dd360cf71360105e8873/__init__.py
p_code = pointer(create_string_buffer(code))
p_code = byref(create_string_buffer(code))
def DecomposeGenerator(codeOffset, code, dt): """ @type codeOffset: long @param codeOffset: Memory address where the code is located. This is B{not} an offset into the code! It's the actual memory address where it was read from. @type code: str @param code: Code to disassemble. @type dt: int @param dt: Disassembly type. Can be one of the following: * L{Decode16Bits}: 80286 decoding * L{Decode32Bits}: IA-32 decoding * L{Decode64Bits}: AMD64 decoding @rtype: generator of TODO @return: Generator of TODO @raise ValueError: Invalid arguments. """ if not code: return if not codeOffset: codeOffset = 0 if dt not in (Decode16Bits, Decode32Bits, Decode64Bits): raise ValueError("Invalid decode type value: %r" % (dt,)) codeLen = len(code) p_code = pointer(create_string_buffer(code)) result = (_DInst * MAX_INSTRUCTIONS)() instruction_off = 0 while codeLen > 0: usedInstructionsCount = c_uint(0) codeInfo = _CodeInfo(_OffsetType(codeOffset), _OffsetType(0), cast(p_code, c_char_p), codeLen, dt, 0) status = internal_decompose(byref(codeInfo), byref(result), MAX_INSTRUCTIONS, byref(usedInstructionsCount)) if status == DECRES_INPUTERR: raise ValueError("Invalid arguments passed to distorm_decode()") used = usedInstructionsCount.value if not used: break delta = 0 for index in xrange(used): di = result[index] yield Instruction(di, code[instruction_off : instruction_off + di.size], dt) delta += di.size instruction_off += di.size if delta <= 0: break codeOffset = codeOffset + delta p_code = pointer(create_string_buffer(code[instruction_off:])) codeLen = codeLen - delta
7433c529f08a143521f1dd360cf71360105e8873 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/7433c529f08a143521f1dd360cf71360105e8873/__init__.py
p_code = pointer(create_string_buffer(code[instruction_off:]))
p_code = byref(create_string_buffer(code), instruction_off)
def DecomposeGenerator(codeOffset, code, dt): """ @type codeOffset: long @param codeOffset: Memory address where the code is located. This is B{not} an offset into the code! It's the actual memory address where it was read from. @type code: str @param code: Code to disassemble. @type dt: int @param dt: Disassembly type. Can be one of the following: * L{Decode16Bits}: 80286 decoding * L{Decode32Bits}: IA-32 decoding * L{Decode64Bits}: AMD64 decoding @rtype: generator of TODO @return: Generator of TODO @raise ValueError: Invalid arguments. """ if not code: return if not codeOffset: codeOffset = 0 if dt not in (Decode16Bits, Decode32Bits, Decode64Bits): raise ValueError("Invalid decode type value: %r" % (dt,)) codeLen = len(code) p_code = pointer(create_string_buffer(code)) result = (_DInst * MAX_INSTRUCTIONS)() instruction_off = 0 while codeLen > 0: usedInstructionsCount = c_uint(0) codeInfo = _CodeInfo(_OffsetType(codeOffset), _OffsetType(0), cast(p_code, c_char_p), codeLen, dt, 0) status = internal_decompose(byref(codeInfo), byref(result), MAX_INSTRUCTIONS, byref(usedInstructionsCount)) if status == DECRES_INPUTERR: raise ValueError("Invalid arguments passed to distorm_decode()") used = usedInstructionsCount.value if not used: break delta = 0 for index in xrange(used): di = result[index] yield Instruction(di, code[instruction_off : instruction_off + di.size], dt) delta += di.size instruction_off += di.size if delta <= 0: break codeOffset = codeOffset + delta p_code = pointer(create_string_buffer(code[instruction_off:])) codeLen = codeLen - delta
7433c529f08a143521f1dd360cf71360105e8873 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/7433c529f08a143521f1dd360cf71360105e8873/__init__.py
status = internal_decode(_OffsetType(codeOffset), p_code, codeLen, dt, p_result, MAX_INSTRUCTIONS, byref(usedInstructionsCount))
status = internal_decode(_OffsetType(codeOffset), p_code, codeLen, dt, p_result, MAX_INSTRUCTIONS, byref(usedInstructionsCount))
def DecodeGenerator(codeOffset, code, dt): """ @type codeOffset: long @param codeOffset: Memory address where the code is located. This is B{not} an offset into the code! It's the actual memory address where it was read from. @type code: str @param code: Code to disassemble. @type dt: int @param dt: Disassembly type. Can be one of the following: * L{Decode16Bits}: 80286 decoding * L{Decode32Bits}: IA-32 decoding * L{Decode64Bits}: AMD64 decoding @rtype: generator of tuple( long, int, str, str ) @return: Generator of tuples. Each tuple represents an assembly instruction and contains: - Memory address of instruction. - Size of instruction in bytes. - Disassembly line of instruction. - Hexadecimal dump of instruction. @raise ValueError: Invalid arguments. """ if not code: return if not codeOffset: codeOffset = 0 if dt not in (Decode16Bits, Decode32Bits, Decode64Bits): raise ValueError("Invalid decode type value: %r" % (dt,)) codeLen = len(code) code = create_string_buffer(code) p_code = addressof(code) result = (_DecodedInst * MAX_INSTRUCTIONS)() p_result = byref(result) while codeLen > 0: usedInstructionsCount = c_uint(0) status = internal_decode(_OffsetType(codeOffset), p_code, codeLen, dt, p_result, MAX_INSTRUCTIONS, byref(usedInstructionsCount)) if status == DECRES_INPUTERR: raise ValueError("Invalid arguments passed to distorm_decode()") used = usedInstructionsCount.value if not used: break for index in xrange(used): di = result[index] asm = di.mnemonic.p if len(di.operands.p): asm += " " + di.operands.p pydi = ( di.offset, di.size, asm, di.instructionHex.p ) yield pydi di = result[used - 1] delta = di.offset - codeOffset + result[used -1].size if delta <= 0: break codeOffset = codeOffset + delta p_code = p_code + delta codeLen = codeLen - delta
b14352da15a7f1400c88d0dc92ac6c391430eee6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/b14352da15a7f1400c88d0dc92ac6c391430eee6/__init__.py
code = create_string_buffer(code) p_code = addressof(code)
scode = create_string_buffer(code) p_code = addressof(scode)
def DecomposeGenerator(codeOffset, code, dt): """ @type codeOffset: long @param codeOffset: Memory address where the code is located. This is B{not} an offset into the code! It's the actual memory address where it was read from. @type code: str @param code: Code to disassemble. @type dt: int @param dt: Disassembly type. Can be one of the following: * L{Decode16Bits}: 80286 decoding * L{Decode32Bits}: IA-32 decoding * L{Decode64Bits}: AMD64 decoding @rtype: generator of TODO @return: Generator of TODO @raise ValueError: Invalid arguments. """ if not code: return if not codeOffset: codeOffset = 0 if dt not in (Decode16Bits, Decode32Bits, Decode64Bits): raise ValueError("Invalid decode type value: %r" % (dt,)) codeLen = len(code) code = create_string_buffer(code) p_code = addressof(code) result = (_DInst * MAX_INSTRUCTIONS)() p_result = byref(result) codeInfo = _CodeInfo(_OffsetType(codeOffset), _OffsetType(0), p_code, codeLen, dt, 0) while codeLen > 0: usedInstructionsCount = c_uint(0) status = internal_decompose(byref(codeInfo), p_result, MAX_INSTRUCTIONS, byref(usedInstructionsCount)) if status == DECRES_INPUTERR: raise ValueError("Invalid arguments passed to distorm_decode()") used = usedInstructionsCount.value if not used: break delta = 0 for index in xrange(used): di = result[index] yield Instruction(di, code[codeOffset + delta : codeOffset + delta + di.size]) delta += di.size if delta <= 0: break codeOffset = codeOffset + delta p_code = p_code + delta codeLen = codeLen - delta
b14352da15a7f1400c88d0dc92ac6c391430eee6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/b14352da15a7f1400c88d0dc92ac6c391430eee6/__init__.py
p_result = byref(result) codeInfo = _CodeInfo(_OffsetType(codeOffset), _OffsetType(0), p_code, codeLen, dt, 0)
instruction_off = 0
def DecomposeGenerator(codeOffset, code, dt): """ @type codeOffset: long @param codeOffset: Memory address where the code is located. This is B{not} an offset into the code! It's the actual memory address where it was read from. @type code: str @param code: Code to disassemble. @type dt: int @param dt: Disassembly type. Can be one of the following: * L{Decode16Bits}: 80286 decoding * L{Decode32Bits}: IA-32 decoding * L{Decode64Bits}: AMD64 decoding @rtype: generator of TODO @return: Generator of TODO @raise ValueError: Invalid arguments. """ if not code: return if not codeOffset: codeOffset = 0 if dt not in (Decode16Bits, Decode32Bits, Decode64Bits): raise ValueError("Invalid decode type value: %r" % (dt,)) codeLen = len(code) code = create_string_buffer(code) p_code = addressof(code) result = (_DInst * MAX_INSTRUCTIONS)() p_result = byref(result) codeInfo = _CodeInfo(_OffsetType(codeOffset), _OffsetType(0), p_code, codeLen, dt, 0) while codeLen > 0: usedInstructionsCount = c_uint(0) status = internal_decompose(byref(codeInfo), p_result, MAX_INSTRUCTIONS, byref(usedInstructionsCount)) if status == DECRES_INPUTERR: raise ValueError("Invalid arguments passed to distorm_decode()") used = usedInstructionsCount.value if not used: break delta = 0 for index in xrange(used): di = result[index] yield Instruction(di, code[codeOffset + delta : codeOffset + delta + di.size]) delta += di.size if delta <= 0: break codeOffset = codeOffset + delta p_code = p_code + delta codeLen = codeLen - delta
b14352da15a7f1400c88d0dc92ac6c391430eee6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/b14352da15a7f1400c88d0dc92ac6c391430eee6/__init__.py
status = internal_decompose(byref(codeInfo), p_result, MAX_INSTRUCTIONS, byref(usedInstructionsCount))
codeInfo = _CodeInfo(_OffsetType(codeOffset), _OffsetType(0), p_code, codeLen, dt, 0) status = internal_decompose(byref(codeInfo), byref(result), MAX_INSTRUCTIONS, byref(usedInstructionsCount))
def DecomposeGenerator(codeOffset, code, dt): """ @type codeOffset: long @param codeOffset: Memory address where the code is located. This is B{not} an offset into the code! It's the actual memory address where it was read from. @type code: str @param code: Code to disassemble. @type dt: int @param dt: Disassembly type. Can be one of the following: * L{Decode16Bits}: 80286 decoding * L{Decode32Bits}: IA-32 decoding * L{Decode64Bits}: AMD64 decoding @rtype: generator of TODO @return: Generator of TODO @raise ValueError: Invalid arguments. """ if not code: return if not codeOffset: codeOffset = 0 if dt not in (Decode16Bits, Decode32Bits, Decode64Bits): raise ValueError("Invalid decode type value: %r" % (dt,)) codeLen = len(code) code = create_string_buffer(code) p_code = addressof(code) result = (_DInst * MAX_INSTRUCTIONS)() p_result = byref(result) codeInfo = _CodeInfo(_OffsetType(codeOffset), _OffsetType(0), p_code, codeLen, dt, 0) while codeLen > 0: usedInstructionsCount = c_uint(0) status = internal_decompose(byref(codeInfo), p_result, MAX_INSTRUCTIONS, byref(usedInstructionsCount)) if status == DECRES_INPUTERR: raise ValueError("Invalid arguments passed to distorm_decode()") used = usedInstructionsCount.value if not used: break delta = 0 for index in xrange(used): di = result[index] yield Instruction(di, code[codeOffset + delta : codeOffset + delta + di.size]) delta += di.size if delta <= 0: break codeOffset = codeOffset + delta p_code = p_code + delta codeLen = codeLen - delta
b14352da15a7f1400c88d0dc92ac6c391430eee6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/b14352da15a7f1400c88d0dc92ac6c391430eee6/__init__.py
di = result[index] yield Instruction(di, code[codeOffset + delta : codeOffset + delta + di.size])
di = result[index] yield Instruction(di, code[instruction_off : instruction_off + di.size])
def DecomposeGenerator(codeOffset, code, dt): """ @type codeOffset: long @param codeOffset: Memory address where the code is located. This is B{not} an offset into the code! It's the actual memory address where it was read from. @type code: str @param code: Code to disassemble. @type dt: int @param dt: Disassembly type. Can be one of the following: * L{Decode16Bits}: 80286 decoding * L{Decode32Bits}: IA-32 decoding * L{Decode64Bits}: AMD64 decoding @rtype: generator of TODO @return: Generator of TODO @raise ValueError: Invalid arguments. """ if not code: return if not codeOffset: codeOffset = 0 if dt not in (Decode16Bits, Decode32Bits, Decode64Bits): raise ValueError("Invalid decode type value: %r" % (dt,)) codeLen = len(code) code = create_string_buffer(code) p_code = addressof(code) result = (_DInst * MAX_INSTRUCTIONS)() p_result = byref(result) codeInfo = _CodeInfo(_OffsetType(codeOffset), _OffsetType(0), p_code, codeLen, dt, 0) while codeLen > 0: usedInstructionsCount = c_uint(0) status = internal_decompose(byref(codeInfo), p_result, MAX_INSTRUCTIONS, byref(usedInstructionsCount)) if status == DECRES_INPUTERR: raise ValueError("Invalid arguments passed to distorm_decode()") used = usedInstructionsCount.value if not used: break delta = 0 for index in xrange(used): di = result[index] yield Instruction(di, code[codeOffset + delta : codeOffset + delta + di.size]) delta += di.size if delta <= 0: break codeOffset = codeOffset + delta p_code = p_code + delta codeLen = codeLen - delta
b14352da15a7f1400c88d0dc92ac6c391430eee6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/b14352da15a7f1400c88d0dc92ac6c391430eee6/__init__.py
return glob('src/*.c') + glob('include/*.c')
return glob('src/*.c')
def get_sources(): """Returns a list of C source files that should be compiled to create the libdistorm3 library. """ return glob('src/*.c') + glob('include/*.c')
3d4435b8494898c58e53cb86d4855c037f613448 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/4918/3d4435b8494898c58e53cb86d4855c037f613448/setup.py
if self.__curindex_type==float64:
if pts.dtype==float64:
def nn(self, pts, qpts, num_neighbors = 1, **kwargs): """ Returns the num_neighbors nearest points in dataset for each point in testset. """ if not pts.dtype.type in allowed_types: raise FLANNException("Cannot handle type: %s"%pts.dtype)
d2c634b413ba845c77eca502f1a6d8f72d12df43 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12913/d2c634b413ba845c77eca502f1a6d8f72d12df43/index.py
array.shape = (-1,array.size)
array = array.reshape(-1,array.size)
def ensure_2d_array(array, flags, **kwargs): array = require(array, requirements = flags, **kwargs) if len(array.shape) == 1: array.shape = (-1,array.size) return array
91ba84c569ec1fa7e0107733c16ccb2845feb843 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12913/91ba84c569ec1fa7e0107733c16ccb2845feb843/flann_ctypes.py
except:
except Exception as e: print e
def load_flann_library(): root_dir = os.path.abspath(os.path.dirname(__file__)) libname = 'libflann' if sys.platform == 'win32': libname = 'flann' flann = None loaded = False while (not loaded) and root_dir!="/": try: flann = load_library(libname, os.path.join(root_dir,'lib')) loaded = True except: root_dir = os.path.dirname(root_dir) return flann
12b505a18bdc9f2d084c8cd9463a34b3b66d4601 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12913/12b505a18bdc9f2d084c8cd9463a34b3b66d4601/flann_ctypes.py
def kmeans(self, pts, num_clusters, centers_init = "random", max_iterations = None,
def kmeans(self, pts, num_clusters, max_iterations = None,
def kmeans(self, pts, num_clusters, centers_init = "random", max_iterations = None, dtype = None, **kwargs): """ Runs kmeans on pts with num_clusters centroids. Returns a numpy array of size num_clusters x dim.
149ee94c322d8ffa93c01ab6dfa79f4c06d4755d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/12913/149ee94c322d8ffa93c01ab6dfa79f4c06d4755d/index.py
"resultsLog", "workspace", "displayInfo"
"resultsLog", "workspace", "displayInfo", "infoLineEdit"
def import_to_global(modname, attrs=None, math=False): """ import_to_global(modname, (a,b,c,...), math): like "from modname import a,b,c,...", but imports to global namespace (__main__). If math==True, also registers functions with QtiPlot's math function list. """ import sys import os sys.path.append(os.path.dirname(__file__)) mod = __import__(modname) for submod in modname.split(".")[1:]: mod = getattr(mod, submod) if attrs==None: attrs=dir(mod) for name in attrs: f = getattr(mod, name) setattr(__main__, name, f) # make functions available in QtiPlot's math function list if math and callable(f): qti.mathFunctions[name] = f
228a6c50f2986e8b378eca1bd5adcb7a2f00cad3 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/2185/228a6c50f2986e8b378eca1bd5adcb7a2f00cad3/qtiplotrc.py
else:
else:
def __init__(self, base_path=None, template_path=None, script_path=None, environ=None, cwd=None, start_clear=True, ignore_paths=None, ignore_hidden=True): """ Creates an environment. ``base_path`` is used as the current working directory, and generally where changes are looked for. If not given, it will be the directory of the calling script plus ``test-output/``.
78ffcb4c9548b27e2cb7bf15bf7a4cc0f8cc2c1a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8710/78ffcb4c9548b27e2cb7bf15bf7a4cc0f8cc2c1a/__init__.py
script = self._find_exe(script)
def run(self, script, *args, **kw): """ Run the command, with the given arguments. The ``script`` argument can have space-separated arguments, or you can use the positional arguments.
e243279c4b95090e8ae7dc785d0d4604555b848a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8710/e243279c4b95090e8ae7dc785d0d4604555b848a/__init__.py
def _find_exe(self, script_name): if self.script_path is None: script_name = os.path.join(self.cwd, script_name) if not os.path.exists(script_name): raise OSError( "Script %s does not exist" % script_name) return script_name for path in self.script_path: fn = os.path.join(path, script_name) if os.path.exists(fn): return fn raise OSError( "Script %s could not be found in %s" % (script_name, ':'.join(self.script_path)))
def run(self, script, *args, **kw): """ Run the command, with the given arguments. The ``script`` argument can have space-separated arguments, or you can use the positional arguments.
e243279c4b95090e8ae7dc785d0d4604555b848a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8710/e243279c4b95090e8ae7dc785d0d4604555b848a/__init__.py
proc = subprocess.Popen(all, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE, cwd=cwd, shell=(sys.platform=='win32'), env=clean_environ(self.environ)) stdout, stderr = proc.communicate(stdin)
if debug: proc = subprocess.Popen(all, cwd=cwd, shell=(sys.platform=='win32'), env=clean_environ(self.environ)) else: proc = subprocess.Popen(all, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE, cwd=cwd, shell=(sys.platform=='win32'), env=clean_environ(self.environ)) if debug: stdout,stderr = proc.communicate() else: stdout, stderr = proc.communicate(stdin)
def run(self, script, *args, **kw): """ Run the command, with the given arguments. The ``script`` argument can have space-separated arguments, or you can use the positional arguments.
fd6372480973c7f158f15aa967a6483a10f68925 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8710/fd6372480973c7f158f15aa967a6483a10f68925/__init__.py
capture_temp=False, assert_no_temp=False):
capture_temp=False, assert_no_temp=False, split_cmd=True):
def __init__(self, base_path=None, template_path=None, environ=None, cwd=None, start_clear=True, ignore_paths=None, ignore_hidden=True, capture_temp=False, assert_no_temp=False): """ Creates an environment. ``base_path`` is used as the current working directory, and generally where changes are looked for. If not given, it will be the directory of the calling script plus ``test-output/``.
f858820cb544ceddbfc6e8a8a20f52e4ad6c8a39 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8710/f858820cb544ceddbfc6e8a8a20f52e4ad6c8a39/__init__.py
if ' ' in script:
if self.split_cmd and ' ' in script:
def run(self, script, *args, **kw): """ Run the command, with the given arguments. The ``script`` argument can have space-separated arguments, or you can use the positional arguments.
f858820cb544ceddbfc6e8a8a20f52e4ad6c8a39 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8710/f858820cb544ceddbfc6e8a8a20f52e4ad6c8a39/__init__.py
assert not args, ( "You cannot give a multi-argument script (%r) " "and arguments (%s)" % (script, args)) script, args = script.split(None, 1) args = shlex.split(args)
if args: pass else: script, args = script.split(None, 1) args = shlex.split(args)
def run(self, script, *args, **kw): """ Run the command, with the given arguments. The ``script`` argument can have space-separated arguments, or you can use the positional arguments.
b5d1aa7f899dadd94df8242374849c97a4a425ad /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8710/b5d1aa7f899dadd94df8242374849c97a4a425ad/__init__.py
all_proc_results = [script] + args
environ=clean_environ(self.environ)
def run(self, script, *args, **kw): """ Run the command, with the given arguments. The ``script`` argument can have space-separated arguments, or you can use the positional arguments.
c39d56b5208d2509cb30fe1ab8fb1f4136b925f2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8710/c39d56b5208d2509cb30fe1ab8fb1f4136b925f2/__init__.py
proc = subprocess.Popen(all, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE, cwd=cwd, env=clean_environ(self.environ))
proc = Popen(all, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE, cwd=cwd, env=environ)
def run(self, script, *args, **kw): """ Run the command, with the given arguments. The ``script`` argument can have space-separated arguments, or you can use the positional arguments.
c39d56b5208d2509cb30fe1ab8fb1f4136b925f2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8710/c39d56b5208d2509cb30fe1ab8fb1f4136b925f2/__init__.py
self, all_proc_results, stdin, stdout, stderr,
self, all, stdin, stdout, stderr,
def run(self, script, *args, **kw): """ Run the command, with the given arguments. The ``script`` argument can have space-separated arguments, or you can use the positional arguments.
c39d56b5208d2509cb30fe1ab8fb1f4136b925f2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8710/c39d56b5208d2509cb30fe1ab8fb1f4136b925f2/__init__.py
capture_temp=False, assert_no_temp=False):
capture_temp=False, assert_no_temp=False, split_cmd=True):
def __init__(self, base_path=None, template_path=None, environ=None, cwd=None, start_clear=True, ignore_paths=None, ignore_hidden=True, capture_temp=False, assert_no_temp=False): """ Creates an environment. ``base_path`` is used as the current working directory, and generally where changes are looked for. If not given, it will be the directory of the calling script plus ``test-output/``.
1edb8b5be29dbec631d234d0f7427ff0e8b3b22d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8710/1edb8b5be29dbec631d234d0f7427ff0e8b3b22d/__init__.py
if ' ' in script:
if self.split_cmd and ' ' in script:
def run(self, script, *args, **kw): """ Run the command, with the given arguments. The ``script`` argument can have space-separated arguments, or you can use the positional arguments.
1edb8b5be29dbec631d234d0f7427ff0e8b3b22d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/8710/1edb8b5be29dbec631d234d0f7427ff0e8b3b22d/__init__.py
"""
def main(): try: fetch_threads = [] parser = OptionParser(usage="Usage: %prog [options] url") parser.add_option("-s", "--max-speed", dest="max_speed", help="Specifies maximum speed (bytes per second)." " Useful if you don't want the program to suck up" " all of your bandwidth", metavar="SPEED") parser.add_option("-q", "--quiet", action="store_false", dest="verbose", default=True, help="don't print status messages to stdout") parser.add_option("-n", "--num-connections", dest="num_connections", type="int", default=4, help="You can specify an alternative number of" " connections here.", metavar="NUM") parser.add_option("-o", "--output", dest="output_file", help="By default, data does to a local file of " "the same name. If this option is used, downloaded" " data will go to this file.") (options, args) = parser.parse_args() print "Options: ", options print "args: ", args if len(args) != 1: parser.print_help() sys.exit(1) # General configuration urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())) urllib2.install_opener(urllib2.build_opener( urllib2.HTTPCookieProcessor())) socket.setdefaulttimeout(120) # 2 minutes url = args[0] output_file = url.rsplit("/", 1)[1] # basename of the url if options.output_file != None: output_file = options.output_file if output_file == "": print "Invalid URL" sys.exit(1) print "Destination = ", output_file filesize = get_file_size(url) print "Need to fetch %s\n" % report_bytes(filesize) conn_state = ConnectionState(options.num_connections, filesize) pbar = ProgressBar(options.num_connections, conn_state) # Checking if we have a partial download available and resume state_file = output_file + ".st" try: os.stat(state_file) except OSError, o: #statefile is missing for all practical purposes pass else: state_fd = file(state_file, "r") conn_state.resume_state(state_fd) state_fd.close() #create output file out_fd = os.open(output_file, os.O_CREAT | os.O_WRONLY) start_offset = 0 start_time = time.time() for i in range(options.num_connections): # each iteration should spawn a thread. # print start_offset, len_list[i] current_thread = FetchData(i, url, output_file, state_file, start_offset + conn_state.progress[i], conn_state) fetch_threads.append(current_thread) current_thread.start() start_offset += conn_state.chunks[i] while threading.active_count() > 1: #print "\n",progress end_time = time.time() conn_state.update_time_taken(end_time - start_time) start_time = end_time dwnld_sofar = conn_state.download_sofar() if options.max_speed != None and \ (dwnld_sofar / conn_state.elapsed_time) > \ (options.max_speed * 1024): for th in fetch_threads: th.need_to_sleep = True th.sleep_timer = dwnld_sofar / options.max_speed * \ 1024 - conn_state.elapsed_time pbar.display_progress() time.sleep(1) # Blank spaces trail below to erase previous output. TODO: Need to # do this better. pbar.display_progress() # at this point we are sure dwnld completed and can delete the # state file os.remove(state_file) except KeyboardInterrupt, k: for thread in fetch_threads: thread.need_to_quit = True
2c30e6d0071d63539bdce377be819837470c713e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11998/2c30e6d0071d63539bdce377be819837470c713e/pyaxel.py
"""
def main(): try: fetch_threads = [] parser = OptionParser(usage="Usage: %prog [options] url") parser.add_option("-s", "--max-speed", dest="max_speed", help="Specifies maximum speed (bytes per second)." " Useful if you don't want the program to suck up" " all of your bandwidth", metavar="SPEED") parser.add_option("-q", "--quiet", action="store_false", dest="verbose", default=True, help="don't print status messages to stdout") parser.add_option("-n", "--num-connections", dest="num_connections", type="int", default=4, help="You can specify an alternative number of" " connections here.", metavar="NUM") parser.add_option("-o", "--output", dest="output_file", help="By default, data does to a local file of " "the same name. If this option is used, downloaded" " data will go to this file.") (options, args) = parser.parse_args() print "Options: ", options print "args: ", args if len(args) != 1: parser.print_help() sys.exit(1) # General configuration urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())) urllib2.install_opener(urllib2.build_opener( urllib2.HTTPCookieProcessor())) socket.setdefaulttimeout(120) # 2 minutes url = args[0] output_file = url.rsplit("/", 1)[1] # basename of the url if options.output_file != None: output_file = options.output_file if output_file == "": print "Invalid URL" sys.exit(1) print "Destination = ", output_file filesize = get_file_size(url) print "Need to fetch %s\n" % report_bytes(filesize) conn_state = ConnectionState(options.num_connections, filesize) pbar = ProgressBar(options.num_connections, conn_state) # Checking if we have a partial download available and resume state_file = output_file + ".st" try: os.stat(state_file) except OSError, o: #statefile is missing for all practical purposes pass else: state_fd = file(state_file, "r") conn_state.resume_state(state_fd) state_fd.close() #create output file out_fd = os.open(output_file, os.O_CREAT | os.O_WRONLY) start_offset = 0 start_time = time.time() for i in range(options.num_connections): # each iteration should spawn a thread. # print start_offset, len_list[i] current_thread = FetchData(i, url, output_file, state_file, start_offset + conn_state.progress[i], conn_state) fetch_threads.append(current_thread) current_thread.start() start_offset += conn_state.chunks[i] while threading.active_count() > 1: #print "\n",progress end_time = time.time() conn_state.update_time_taken(end_time - start_time) start_time = end_time dwnld_sofar = conn_state.download_sofar() if options.max_speed != None and \ (dwnld_sofar / conn_state.elapsed_time) > \ (options.max_speed * 1024): for th in fetch_threads: th.need_to_sleep = True th.sleep_timer = dwnld_sofar / options.max_speed * \ 1024 - conn_state.elapsed_time pbar.display_progress() time.sleep(1) # Blank spaces trail below to erase previous output. TODO: Need to # do this better. pbar.display_progress() # at this point we are sure dwnld completed and can delete the # state file os.remove(state_file) except KeyboardInterrupt, k: for thread in fetch_threads: thread.need_to_quit = True
2c30e6d0071d63539bdce377be819837470c713e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11998/2c30e6d0071d63539bdce377be819837470c713e/pyaxel.py
self.progress[int(self.name)] += fetch_size
self.progress[int(self.name)][0] += fetch_size self.progress[int(self.name)][1] += elapsed
def run(self): # Ready the url object # print "Running thread with %d-%d" % (self.start_offset, self.length) request = urllib2.Request(url, None, std_headers) request.add_header('Range','bytes=%d-%d' % (self.start_offset, self.start_offset+self.length)) data = urllib2.urlopen(request)
86f3a1e7085aaa2f4a90d4f71bc9df12c9b70b17 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11998/86f3a1e7085aaa2f4a90d4f71bc9df12c9b70b17/pyaxel.py
progress = [ 0 for i in len_list ]
progress = [ [0,0.0] for i in len_list ]
def run(self): # Ready the url object # print "Running thread with %d-%d" % (self.start_offset, self.length) request = urllib2.Request(url, None, std_headers) request.add_header('Range','bytes=%d-%d' % (self.start_offset, self.start_offset+self.length)) data = urllib2.urlopen(request)
86f3a1e7085aaa2f4a90d4f71bc9df12c9b70b17 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11998/86f3a1e7085aaa2f4a90d4f71bc9df12c9b70b17/pyaxel.py
print "\r",progress,
report_string = get_progress_report(progress) print "\r", report_string,
def run(self): # Ready the url object # print "Running thread with %d-%d" % (self.start_offset, self.length) request = urllib2.Request(url, None, std_headers) request.add_header('Range','bytes=%d-%d' % (self.start_offset, self.start_offset+self.length)) data = urllib2.urlopen(request)
86f3a1e7085aaa2f4a90d4f71bc9df12c9b70b17 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11998/86f3a1e7085aaa2f4a90d4f71bc9df12c9b70b17/pyaxel.py
print "\r",progress,
print "\r", get_progress_report(progress)
def run(self): # Ready the url object # print "Running thread with %d-%d" % (self.start_offset, self.length) request = urllib2.Request(url, None, std_headers) request.add_header('Range','bytes=%d-%d' % (self.start_offset, self.start_offset+self.length)) data = urllib2.urlopen(request)
86f3a1e7085aaa2f4a90d4f71bc9df12c9b70b17 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11998/86f3a1e7085aaa2f4a90d4f71bc9df12c9b70b17/pyaxel.py
parser.add_option("-n", "--num-connections", dest="num_connections", default=4,
parser.add_option("-n", "--num-connections", dest="num_connections", type="int", default=4,
def run(self): # Ready the url object # print "Running thread with %d-%d" % (self.start_offset, self.length) request = urllib2.Request(url, None, std_headers) request.add_header('Range','bytes=%d-%d' % (self.start_offset, self.start_offset+self.length)) data = urllib2.urlopen(request)
cc6cc8844ca1782ec8838a088205ea47bab77443 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11998/cc6cc8844ca1782ec8838a088205ea47bab77443/pyaxel.py
th.sleep_timer = dwnld_sofar / options.max_speed * \ 1024 - conn_state.elapsed_time
th.sleep_timer = dwnld_sofar / (options.max_speed * \ 1024 - conn_state.elapsed_time)
def download(url, options): fetch_threads = [] try: output_file = url.rsplit("/", 1)[1] # basename of the url if options.output_file != None: output_file = options.output_file if output_file == "": print "Invalid URL" sys.exit(1) print "Destination = ", output_file filesize = get_file_size(url) conn_state = ConnectionState(options.num_connections, filesize) pbar = ProgressBar(options.num_connections, conn_state) # Checking if we have a partial download available and resume state_file = output_file + ".st" try: os.stat(state_file) except OSError, o: #statefile is missing for all practical purposes pass else: state_fd = file(state_file, "r") conn_state.resume_state(state_fd) state_fd.close() print "Need to fetch %s\n" % report_bytes(conn_state.filesize - sum(conn_state.progress)) #create output file with a .part extension to indicate partial download out_fd = os.open(output_file+".part", os.O_CREAT | os.O_WRONLY) start_offset = 0 start_time = time.time() for i in range(options.num_connections): # each iteration should spawn a thread. # print start_offset, len_list[i] current_thread = FetchData(i, url, output_file, state_file, start_offset + conn_state.progress[i], conn_state) fetch_threads.append(current_thread) current_thread.start() start_offset += conn_state.chunks[i] while threading.active_count() > 1: #print "\n",progress end_time = time.time() conn_state.update_time_taken(end_time - start_time) start_time = end_time dwnld_sofar = conn_state.download_sofar() if options.max_speed != None and \ (dwnld_sofar / conn_state.elapsed_time) > \ (options.max_speed * 1024): for th in fetch_threads: th.need_to_sleep = True th.sleep_timer = dwnld_sofar / options.max_speed * \ 1024 - conn_state.elapsed_time pbar.display_progress() time.sleep(1) pbar.display_progress() # at this point we are sure dwnld completed and can delete the # state file and move the dwnld to output file from .part file os.remove(state_file) os.rename(output_file+".part", output_file) except KeyboardInterrupt, k: for thread in fetch_threads: thread.need_to_quit = True except Exception, e: # TODO: handle other types of errors too. print e for thread in fetch_threads: thread._need_to_quit = True
7da57f7a84e0f1f51cbca04f446e97e21977af2d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11998/7da57f7a84e0f1f51cbca04f446e97e21977af2d/pyaxel.py
help="Specifies maximum speed (bytes per second)."
type="int", help="Specifies maximum speed (Kbytes per second)."
def main(options, args): try: general_configuration() url = args[0] download(url, options) except KeyboardInterrupt, k: sys.exit(1) except Exception, e: # TODO: handle other types of errors too. print e pass
7da57f7a84e0f1f51cbca04f446e97e21977af2d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11998/7da57f7a84e0f1f51cbca04f446e97e21977af2d/pyaxel.py
start_offset += i
start_offset += len_list[i]
def run(self): # Ready the url object # print "Running thread with %d-%d" % (self.start_offset, self.length) request = urllib2.Request(url, None, std_headers) request.add_header('Range','bytes=%d-%d' % (self.start_offset, self.start_offset+self.length)) data = urllib2.urlopen(request)
5a9c6547d97118ce5be5b10f5a6e079a5e49d42b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/11998/5a9c6547d97118ce5be5b10f5a6e079a5e49d42b/pyaxel.py
return self.sys_log("HDF5_DIR=%s make -j%s" % (self.blddir, jobs(self.name)))
return self.sys_log("make -j%s" % (jobs(self.name)))
def _build(self): return self.sys_log("HDF5_DIR=%s make -j%s" % (self.blddir, jobs(self.name)))
60a95f1b9f4da7064785fd03aa51ce020e705b28 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/5963/60a95f1b9f4da7064785fd03aa51ce020e705b28/MEMOSA.py
f.close()
def find_cgal_vers(self, installed=False, in_build=False): v = '' f = self.find_cgal_inc(installed, in_build) if f: while True: line = f.readline() if not line: break v = re.findall(r'#define CGAL_VERSION ([^\r\n]*)', line) if v: v = v[0] break verbose(2, 'CGAL version=%s' % v) f.close() return v
1ab44cecc3b1fc32d1279128d0a943e3459fa76f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/5963/1ab44cecc3b1fc32d1279128d0a943e3459fa76f/Cgal.py
foptions['timeStep'] = 1E-8
foptions['timeStep'] = 1E-4
def usage(): print "Usage: %s filebase [outfilename]" % sys.argv[0] print "Where filebase.cas is a Fluent case file." print "Output will be in filebase-prism.dat if it is not specified." sys.exit(1)
144bd1215fb749eb8ec5cb82fd53f25bb38ef536 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/5963/144bd1215fb749eb8ec5cb82fd53f25bb38ef536/testKineticFlowModel.py
numIterations=1
numIterations=5
def usage(): print "Usage: %s filebase [outfilename]" % sys.argv[0] print "Where filebase.cas is a Fluent case file." print "Output will be in filebase-prism.dat if it is not specified." sys.exit(1)
144bd1215fb749eb8ec5cb82fd53f25bb38ef536 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/5963/144bd1215fb749eb8ec5cb82fd53f25bb38ef536/testKineticFlowModel.py
cwd = os.getcwd()
cwd = os.getcwd() topdir = os.path.abspath(topdir)
def __init__(self, cname, topdir, make_path): # create build directories cwd = os.getcwd() self.topdir = topdir self.blddir = os.path.join(os.getcwd(), "build-%s" % cname) self.logdir = os.path.join(self.blddir, "log") self.bindir = os.path.join(self.blddir, "bin") self.libdir = os.path.join(self.blddir, "lib") for p in [self.blddir, self.logdir, self.libdir, self.bindir ]: if not os.path.isdir(p): try: os.makedirs(p) except: fatal("error creating directory " + p)
d88220500b18005458adbc405fd9cfd1d498f8cb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/5963/d88220500b18005458adbc405fd9cfd1d498f8cb/build.py
sys.path = [path] + sys.path
sys.path = [path] + sys.path
def __init__(self, cname, topdir, make_path): # create build directories cwd = os.getcwd() self.topdir = topdir self.blddir = os.path.join(os.getcwd(), "build-%s" % cname) self.logdir = os.path.join(self.blddir, "log") self.bindir = os.path.join(self.blddir, "bin") self.libdir = os.path.join(self.blddir, "lib") for p in [self.blddir, self.logdir, self.libdir, self.bindir ]: if not os.path.isdir(p): try: os.makedirs(p) except: fatal("error creating directory " + p)
d88220500b18005458adbc405fd9cfd1d498f8cb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/5963/d88220500b18005458adbc405fd9cfd1d498f8cb/build.py
env['CXX'] = 'cxx'
env['CXX'] = 'c++'
def generate(env): cppTool.generate(env) if not env.get('CXXVERSION'): try: line = os.popen("/bin/bash -c 'gcc --version 2>&1'").readline() env['CXXVERSION'] = re.compile(r'[^(]*[^)]*\) ([^\n ]*)').findall(line)[0] except: env['CXXVERSION'] = '4.2.1' env['COMPILER'] = 'gcc-' + env['CXXVERSION'] env['CXXFLAGS'] = CLVar('-Wall -fno-strict-aliasing -Woverloaded-virtual -ftemplate-depth-200 -frounding-math') if is64Bit(): env.Append(CPPDEFINES=CLVar('OS_64BIT')) if env['DEBUG']: env.Append(CXXFLAGS=['-g', '-O0']) else: env.Append(CXXFLAGS=['-O3', '-finline-limit=500']) if env['OPENMP']: env.Append(CXXFLAGS=['-fopenmp']) if env['PARALLEL']: env['CXX'] = 'mpicxx' env.Append(CXXFLAGS=['-DFVM_PARALLEL']) #bug fix for mpich env.Append(CXXFLAGS=['-DMPICH_IGNORE_CXX_SEEK']) else: env['CXX'] = 'cxx' env['CCFLAGS'] = env['CXXFLAGS'] env['SHCXXFLAGS'] = CLVar('$CXXFLAGS -fPIC')
1dae15e0d33418629a399dcf9456967c284a9d3f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/5963/1dae15e0d33418629a399dcf9456967c284a9d3f/g++.py
return self.sys_log("make -j%s" % jobs(self.name))
return self.sys_log("HDF5_DIR=%s make -j%s" % (self.blddir, jobs(self.name)))
def _build(self): return self.sys_log("make -j%s" % jobs(self.name))
f1de6d16b300da6a1b5e6f55615b616cad5cde39 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/5963/f1de6d16b300da6a1b5e6f55615b616cad5cde39/MEMOSA.py
rr, wr, er = select.select(plist, [], plist)
rr, wr, er = select(plist, [], plist)
def sys_log(self, cmd, show=False): "Execute a system call and log the result." # get configuration variable e = config(self.name, self.state) e = e.replace('BUILDDIR', self.blddir) e = e.replace('SRCDIR', self.sdir) e = e.replace('TMPBDIR', self.bdir) e = e.replace('LOGDIR', self.logdir) cmd = cmd + " " + e debug(cmd) f = None if self.logfile != '': f = open(self.logfile, 'a') print >> f, "EXECUTING:", cmd p = Popen(cmd, shell=True, stderr=PIPE, stdout=PIPE) pid = p.pid plist = [p.stdout, p.stderr] done = 0 while not done: rr, wr, er = select.select(plist, [], plist) if er: print 'er=',er for fd in rr: data = os.read(fd.fileno(), 1024) if data == '': plist.remove(fd) if plist == []: done = 1 else: if fd == p.stderr: print >>f, data, if show: cprint('DYELLOW', data, False) else: if show: print data, print >>f, data, if f: f.close() try: return os.waitpid(pid, 0)[1] except: return 0
c81ee0ef389acbe5d55d545d36f214ddbfb3b6e5 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/5963/c81ee0ef389acbe5d55d545d36f214ddbfb3b6e5/build_packages.py
for cmd in config('ALL', 'before'): f.write('%s\n' % cmd)
for cmd in config('ALL', 'before'): exp = re.findall(r'export (\S+)=(\S+)', cmd) if exp: f.write('setenv %s %s\n' % (exp[0][0], exp[0][1])) else: f.write('%s\n' % cmd)
def write_env(bld, cwd, cname): # write out env.csh for people who haven't yet learned bash env_name = os.path.join(cwd, 'env.csh') f = open(env_name, 'w') for cmd in config('ALL', 'before'): f.write('%s\n' % cmd) print >> f, "setenv LD_LIBRARY_PATH " + bld.libdir + ":$LD_LIBRARY_PATH" try: if os.environ['PYTHONPATH']: print >> f, "setenv PYTHONPATH " + os.environ['PYTHONPATH'] except: pass print >> f, "setenv PATH %s:$PATH" % bld.bindir print >> f, "\n# Need this to recompile MPM in its directory." print >> f, "setenv MEMOSA_CONFNAME %s" % cname f.close() # write out env.sh env_name = os.path.join(cwd, 'env.sh') f = open(env_name, 'w') for cmd in config('ALL', 'before'): f.write('%s\n' % cmd) print >> f, "export LD_LIBRARY_PATH=" + bld.libdir + ":$LD_LIBRARY_PATH" try: if os.environ['PYTHONPATH']: print >> f, "export PYTHONPATH=" + os.environ['PYTHONPATH'] except: pass print >> f, "export PATH=%s:$PATH" % bld.bindir print >> f, "\n# Need this to recompile MPM in its directory." print >> f, "export MEMOSA_CONFNAME=%s" % cname f.close() return env_name
a5007a3ab5f62ac54c5e9c16690c8526cad323ba /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/5963/a5007a3ab5f62ac54c5e9c16690c8526cad323ba/build_utils.py