rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
reldir = os.path.relpath(dirpath, dirname) if reldir != ".":
reldir = dirpath[len(dirname)+1:] if reldir:
def scan_package(pkg_name, dirname, stderr=sys.stderr): manifest = [] has_problems = False for dirpath, dirnames, filenames in os.walk(dirname): for fn in [fn for fn in filenames if fn.endswith(".js")]: modname = os.path.splitext(fn)[0] reldir = os.path.relpath(dirpath, dirname) if reldir != ".": modname = "/".join(rel...
if not parts[0]:
if (not parts) or (not parts[0]):
def app(self, environ, start_response): self.environ = environ self.start_response = start_response
import shutil import tarfile
def generate_static_docs(env_root, tgz_filename): import shutil import tarfile server = Server(env_root=env_root, task_queue=None, expose_privileged_api=False) root_dir = os.path.join(server.root, 'packages') if os.path.exists(root_dir): shutil.rmtree(root_dir) pkg_cfg = server.build_pkg_cfg() os.mkdir(root_dir) i...
root_dir = os.path.join(server.root, 'packages') if os.path.exists(root_dir): shutil.rmtree(root_dir)
staging_dir = os.path.join(env_root, "jetpack-sdk-docs") if os.path.exists(staging_dir): shutil.rmtree(staging_dir) def _tempfiles(src, names): return [n for n in names if n.endswith("~")] shutil.copytree(server.root, staging_dir, ignore=_tempfiles) os.mkdir(os.path.join(staging_dir, "packages"))
def generate_static_docs(env_root, tgz_filename): import shutil import tarfile server = Server(env_root=env_root, task_queue=None, expose_privileged_api=False) root_dir = os.path.join(server.root, 'packages') if os.path.exists(root_dir): shutil.rmtree(root_dir) pkg_cfg = server.build_pkg_cfg() os.mkdir(root_dir) i...
os.mkdir(root_dir)
def generate_static_docs(env_root, tgz_filename): import shutil import tarfile server = Server(env_root=env_root, task_queue=None, expose_privileged_api=False) root_dir = os.path.join(server.root, 'packages') if os.path.exists(root_dir): shutil.rmtree(root_dir) pkg_cfg = server.build_pkg_cfg() os.mkdir(root_dir) i...
index_path = os.path.join(root_dir, 'index.json')
index_path = os.path.join(staging_dir, "packages", 'index.json')
def generate_static_docs(env_root, tgz_filename): import shutil import tarfile server = Server(env_root=env_root, task_queue=None, expose_privileged_api=False) root_dir = os.path.join(server.root, 'packages') if os.path.exists(root_dir): shutil.rmtree(root_dir) pkg_cfg = server.build_pkg_cfg() os.mkdir(root_dir) i...
dir_made = False
def generate_static_docs(env_root, tgz_filename): import shutil import tarfile server = Server(env_root=env_root, task_queue=None, expose_privileged_api=False) root_dir = os.path.join(server.root, 'packages') if os.path.exists(root_dir): shutil.rmtree(root_dir) pkg_cfg = server.build_pkg_cfg() os.mkdir(root_dir) i...
dest_dir = os.path.join(root_dir, pkg_name)
dest_dir = os.path.join(staging_dir, "packages", pkg_name) if not os.path.exists(dest_dir): os.mkdir(dest_dir)
def generate_static_docs(env_root, tgz_filename): import shutil import tarfile server = Server(env_root=env_root, task_queue=None, expose_privileged_api=False) root_dir = os.path.join(server.root, 'packages') if os.path.exists(root_dir): shutil.rmtree(root_dir) pkg_cfg = server.build_pkg_cfg() os.mkdir(root_dir) i...
default_items = ['README.md', 'docs'] for item in default_items: item_src = os.path.join(src_dir, item) item_dest = os.path.join(dest_dir, item) if os.path.exists(item_src): if not dir_made: os.mkdir(dest_dir) dir_made = True if os.path.isdir(item_src): shutil.copytree(item_src, item_dest) else: shutil.copyfile(item_s...
shutil.copyfile(os.path.join(src_dir, "README.md"), os.path.join(dest_dir, "README.md")) docs_src_dir = os.path.join(src_dir, "docs") docs_dest_dir = os.path.join(dest_dir, "docs") if not os.path.exists(docs_dest_dir): os.mkdir(docs_dest_dir) for (dirpath, dirnames, filenames) in os.walk(docs_src_dir): assert dirpath....
def generate_static_docs(env_root, tgz_filename): import shutil import tarfile server = Server(env_root=env_root, task_queue=None, expose_privileged_api=False) root_dir = os.path.join(server.root, 'packages') if os.path.exists(root_dir): shutil.rmtree(root_dir) pkg_cfg = server.build_pkg_cfg() os.mkdir(root_dir) i...
tgz.add(server.root, 'jetpack-sdk-docs')
tgz.add('jetpack-sdk-docs', 'jetpack-sdk-docs')
def generate_static_docs(env_root, tgz_filename): import shutil import tarfile server = Server(env_root=env_root, task_queue=None, expose_privileged_api=False) root_dir = os.path.join(server.root, 'packages') if os.path.exists(root_dir): shutil.rmtree(root_dir) pkg_cfg = server.build_pkg_cfg() os.mkdir(root_dir) i...
shutil.rmtree(root_dir)
shutil.rmtree(staging_dir)
def generate_static_docs(env_root, tgz_filename): import shutil import tarfile server = Server(env_root=env_root, task_queue=None, expose_privileged_api=False) root_dir = os.path.join(server.root, 'packages') if os.path.exists(root_dir): shutil.rmtree(root_dir) pkg_cfg = server.build_pkg_cfg() os.mkdir(root_dir) i...
if is_data: build.packageData[cfg.name] = resource_url if section == "lib":
def add_section_to_build(cfg, section, is_code=False, is_data=False): if section in cfg: dirnames = cfg[section] if isinstance(dirnames, basestring): # This is just for internal consistency within this # function, it has nothing to do w/ a non-canonical # configuration dict. dirnames = [dirnames] for dirname in resolve...
for dirname in os.listdir(examples_dir):
examples = [dirname for dirname in os.listdir(examples_dir) if os.path.isdir(os.path.join(examples_dir, dirname))] for dirname in examples:
def test_all_examples(env_root, defaults): examples_dir = os.path.join(env_root, "examples") for dirname in os.listdir(examples_dir): print "Testing %s..." % dirname run(arguments=["test", "--pkgdir", os.path.join(examples_dir, dirname)], defaults=defaults, env_root=env_root)
result = test_cfx(defaults['verbose'])
result = test_cfx(env_root, defaults['verbose'])
def test_all(env_root, defaults): retval = 0 print "Testing cfx..." result = test_cfx(defaults['verbose']) if result.failures or result.errors: retval = -1 try: test_all_examples(env_root, defaults) except SystemExit, e: retval = e try: test_all_packages(env_root, defaults) except SystemExit, e: retval = e if retva...
retval = e
retval = e.code
def test_all(env_root, defaults): retval = 0 print "Testing cfx..." result = test_cfx(defaults['verbose']) if result.failures or result.errors: retval = -1 try: test_all_examples(env_root, defaults) except SystemExit, e: retval = e try: test_all_packages(env_root, defaults) except SystemExit, e: retval = e if retva...
def test_cfx(verbose):
def test_cfx(env_root, verbose):
def test_cfx(verbose): import cuddlefish.tests return cuddlefish.tests.run(verbose)
return cuddlefish.tests.run(verbose)
olddir = os.getcwd() os.chdir(env_root) retval = cuddlefish.tests.run(verbose) os.chdir(olddir) return retval
def test_cfx(verbose): import cuddlefish.tests return cuddlefish.tests.run(verbose)
def _tempfiles(src, names): return [n for n in names if n.endswith("~")] shutil.copytree(server.root, staging_dir, ignore=_tempfiles)
shutil.copytree(server.root, staging_dir) for (dirpath, dirnames, filenames) in os.walk(staging_dir): for n in filenames: if n.endswith("~"): os.unlink(os.path.join(dirpath, n))
def _tempfiles(src, names): return [n for n in names if n.endswith("~")]
return [str(e)]
return [traceback.format_exc()]
def _respond_with_pkg_file(self, parts): if not parts: return self._respond('404 Not Found')
retval = 0
fail = False
def test_all(env_root, defaults): retval = 0 print "Testing cfx..." result = test_cfx(env_root, defaults['verbose']) if result.failures or result.errors: retval = -1 try: test_all_examples(env_root, defaults) except SystemExit, e: retval = e.code try: test_all_packages(env_root, defaults) except SystemExit, e: retva...
retval = -1
fail = True
def test_all(env_root, defaults): retval = 0 print "Testing cfx..." result = test_cfx(env_root, defaults['verbose']) if result.failures or result.errors: retval = -1 try: test_all_examples(env_root, defaults) except SystemExit, e: retval = e.code try: test_all_packages(env_root, defaults) except SystemExit, e: retva...
retval = e.code
fail = (e.code != 0) or fail
def test_all(env_root, defaults): retval = 0 print "Testing cfx..." result = test_cfx(env_root, defaults['verbose']) if result.failures or result.errors: retval = -1 try: test_all_examples(env_root, defaults) except SystemExit, e: retval = e.code try: test_all_packages(env_root, defaults) except SystemExit, e: retva...
retval = e.code if retval:
fail = (e.code != 0) or fail if fail:
def test_all(env_root, defaults): retval = 0 print "Testing cfx..." result = test_cfx(env_root, defaults['verbose']) if result.failures or result.errors: retval = -1 try: test_all_examples(env_root, defaults) except SystemExit, e: retval = e.code try: test_all_packages(env_root, defaults) except SystemExit, e: retva...
sys.exit(retval)
sys.exit(1) print "All tests were successful. Ship it!" sys.exit(0)
def test_all(env_root, defaults): retval = 0 print "Testing cfx..." result = test_cfx(env_root, defaults['verbose']) if result.failures or result.errors: retval = -1 try: test_all_examples(env_root, defaults) except SystemExit, e: retval = e.code try: test_all_packages(env_root, defaults) except SystemExit, e: retva...
if popen.returncode == 0 and output == 'OK':
if popen.poll() == 0 and output == 'OK':
def remove_xulrunner_profile(): try: shutil.rmtree(xulrunner_profile) except OSError: pass
deps_left = list(targets)
deps_left = [[dep, None] for dep in list(targets)]
def get_deps_for_targets(pkg_cfg, targets): visited = [] deps_left = list(targets) while deps_left: dep = deps_left.pop() if dep not in visited: visited.append(dep) if dep not in pkg_cfg.packages: raise PackageNotFoundError(dep) dep_cfg = pkg_cfg.packages[dep] deps_left.extend(dep_cfg.get('dependencies', [])) return ...
dep = deps_left.pop()
[dep, required_by] = deps_left.pop()
def get_deps_for_targets(pkg_cfg, targets): visited = [] deps_left = list(targets) while deps_left: dep = deps_left.pop() if dep not in visited: visited.append(dep) if dep not in pkg_cfg.packages: raise PackageNotFoundError(dep) dep_cfg = pkg_cfg.packages[dep] deps_left.extend(dep_cfg.get('dependencies', [])) return ...
raise PackageNotFoundError(dep)
required_reason = ("required by '%s'" % (required_by)) \ if required_by is not None \ else "specified as target" raise PackageNotFoundError(dep, required_reason)
def get_deps_for_targets(pkg_cfg, targets): visited = [] deps_left = list(targets) while deps_left: dep = deps_left.pop() if dep not in visited: visited.append(dep) if dep not in pkg_cfg.packages: raise PackageNotFoundError(dep) dep_cfg = pkg_cfg.packages[dep] deps_left.extend(dep_cfg.get('dependencies', [])) return ...
deps_left.extend(dep_cfg.get('dependencies', []))
deps_left.extend([[i, dep] for i in dep_cfg.get('dependencies', [])])
def get_deps_for_targets(pkg_cfg, targets): visited = [] deps_left = list(targets) while deps_left: dep = deps_left.pop() if dep not in visited: visited.append(dep) if dep not in pkg_cfg.packages: raise PackageNotFoundError(dep) dep_cfg = pkg_cfg.packages[dep] deps_left.extend(dep_cfg.get('dependencies', [])) return ...
shutil.copyfile(os.path.join(src_dir, "README.md"), os.path.join(dest_dir, "README.md"))
src_readme = os.path.join(src_dir, "README.md") if os.path.exists(src_readme): shutil.copyfile(src_readme, os.path.join(dest_dir, "README.md"))
def generate_static_docs(env_root, tgz_filename): server = Server(env_root=env_root, task_queue=None, expose_privileged_api=False) staging_dir = os.path.join(env_root, "jetpack-sdk-docs") if os.path.exists(staging_dir): shutil.rmtree(staging_dir) # first, copy static-files shutil.copytree(server.root, staging_dir) # p...
elif sys.platform == 'darwin':
elif sys.platform == 'darwin' and binary.find('Contents/MacOS/') == -1:
def __init__(self, binary=None, profile=None, cmdargs=[], env=None, aggressively_kill=['crashreporter'], kp_kwargs={}): if binary is None: self.binary = self.find_binary() elif sys.platform == 'darwin': self.binary = os.path.join(binary, 'Contents/MacOS/%s-bin' % self.names[0]) else: self.binary = binary
code = CODE_WRAP % (lang, self._escape(m.group('code')))
func = FUNCTION_TAG % m.group('lang') code = CODE_WRAP % (func, lang, self._escape(m.group('code')))
def run(self, lines): """ Match and store Fenced Code Blocks in the HtmlStash. """ text = "\n".join(lines) while 1: m = FENCED_BLOCK_RE.search(text) if m: lang = '' if m.group('lang'): lang = LANG_TAG % m.group('lang') code = CODE_WRAP % (lang, self._escape(m.group('code'))) placeholder = self.markdown.htmlStash.store(...
def forInterface(self, interface, check=True, omit=()): prefix = interface.__identifier__ + '.'
def forInterface(self, interface, check=True, omit=(), prefix=None): if prefix is None: prefix = interface.__identifier__ if not prefix.endswith("."): prefix += '.'
def forInterface(self, interface, check=True, omit=()): prefix = interface.__identifier__ + '.' if check: for name in getFieldNames(interface): if name not in omit and prefix + name not in self.records: raise KeyError("Interface `%s` defines a field `%s`, " "for which there is no record." % (interface.__identifier__, n...
def registerInterface(self, interface, omit=()): prefix = interface.__identifier__ + '.'
def registerInterface(self, interface, omit=(), prefix=None): if prefix is None: prefix = interface.__identifier__ if not prefix.endswith("."): prefix += '.'
def registerInterface(self, interface, omit=()): prefix = interface.__identifier__ + '.' for name, field in getFieldsInOrder(interface): if name in omit or field.readonly: continue record_name = prefix + name persistent_field = queryAdapter(field, IPersistentField) if persistent_field is None: raise TypeError("There is...
self.register_function(self.storage.suggest3, 'suggest3') self.register_function(self.storage.suggest2, 'suggest2') self.register_function(self.storage.suggest, 'suggest') self.register_function(self.storage.compare, 'compare') self.register_function(self.storage.words, 'words')
self.register_function(self.suggest3, 'suggest3') self.register_function(self.suggest2, 'suggest2') self.register_function(self.suggest, 'suggest') self.register_function(self.compare, 'compare') self.register_function(self.words, 'words')
def __init__(self, addr): PremiumServer.__init__(self, addr, TranRequestHandler) self.set_server_title('Open-Tran.eu') self.set_server_name('Open-Tran.eu XML-RPC API documentation') self.set_server_documentation('''
SELECT phrase, projectid, locationid, flags
SELECT DISTINCT phrase, projectid, locationid, flags
def move_phrases(oconn, ocur, lang): global project_names cnt = 0 lid = 0 phrase = "" icur.execute("""
if word[0] in vowels:
if word and word[0] in vowels:
def __r1_hungarian(self, word, vowels, digraphs): u""" Return the region R1 that is used by the Hungarian stemmer.
for l in SUGGESTIONS_TXT.keys():
lang = lang.lower() if lang in SUGGESTIONS_TXT: return lang for l in sorted(SUGGESTIONS_TXT.keys(), reverse = True):
def convert_iface_lang(self, lang): for l in SUGGESTIONS_TXT.keys(): i = l.find('_') if i < 0:
if isinstance(args[i], list): process_args(args[i]) if isinstance(args[i], tuple) \ and args[i][0] == 'to_location_warehouse':
if (isinstance(args[i], tuple) or \ (isinstance(args[i], list) and len(args[i]) > 2 and \ args[i][1] in OPERATORS)) and \ args[i][0] == 'to_location_warehouse':
def process_args(args): i = 0 while i < len(args): if isinstance(args[i], list): process_args(args[i]) if isinstance(args[i], tuple) \ and args[i][0] == 'to_location_warehouse': location_id = False if args[i][2]: location = location_obj.browse(cursor, user, args[i][2], context=context) if location.type == 'warehouse': ...
res = True for field, operator, operand in domain: value = line.get(field) if value == None: return False if operator not in ("=", ">=", "<=", ">", "<", "!="): return False if operator == "=": operator= "==" res = res and (eval(str(value) + operator + str(operand))) return res
field, operator, operand = domain value = line.get(field) if value == None: return False if operator not in ("=", ">=", "<=", ">", "<", "!="): return False if operator == "=": operator= "==" return (eval(str(value) + operator + str(operand)))
def _search_quantity_eval_domain(self, line, domain): res = True for field, operator, operand in domain: value = line.get(field) if value == None: return False if operator not in ("=", ">=", "<=", ">", "<", "!="): return False if operator == "=": operator= "==" res = res and (eval(str(value) + operator + str(operand)))...
quantity, uom_id = 0.0, product2uom[line.product.id]
def complete_lines(self, cursor, user, ids, context=None): ''' Complete or update the inventories
move_ids.append(act[1])
if isinstance(act[1], (int, long)): move_ids.append(act[1]) else: move_ids.extend(act[1])
def set_incoming_moves(self, cursor, user, packing_id, name, value, arg, context=None): move_obj = self.pool.get('stock.move')
move_ids.append(act[1])
if isinstance(act[1], (int, long)): move_ids.append(act[1]) else: move_ids.extend(act[1])
def set_inventory_moves(self, cursor, user, packing_id, name, value, arg, context=None): move_obj = self.pool.get('stock.move')
move_ids.append(act[1])
if isinstance(act[1], (int, long)): move_ids.append(act[1]) else: move_ids.extend(act[1])
def set_outgoing_moves(self, cursor, user, packing_id, name, value, arg, context=None): move_obj = self.pool.get('stock.move')
('uid', '=', user),
('uid', '=', Transaction().user),
def _choice(self, data): shipment_internal_obj = self.pool.get('stock.shipment.internal') user_group_obj = self.pool.get('res.user-res.group') model_data_obj = self.pool.get('ir.model.data') transition_obj = self.pool.get('workflow.transition')
('uid', '=', user),
('uid', '=', Transaction().user),
def _choice(self, data): shipment_internal_obj = self.pool.get('stock.shipment.in.return') user_group_obj = self.pool.get('res.user-res.group') model_data_obj = self.pool.get('ir.model.data') transition_obj = self.pool.get('workflow.transition')
return self.on_change_with_unit_price_required(cursor, user, [],
return self.on_change_with_unit_price_required(cursor, user,
def default_unit_price_required(self, cursor, user, context=None): from_location = self.default_from_location(cursor, user, context=context) to_location = self.default_to_location(cursor,user, context=context) vals = { 'from_location': from_location, 'to_location': to_location, } return self.on_change_with_unit_price_r...
move_ids.append(act[1])
if isinstance(act[1], (int, long)): move_ids.append(act[1]) else: move_ids.extend(act[1])
def set_incoming_moves(self, cursor, user, shipment_id, name, value, arg, context=None): move_obj = self.pool.get('stock.move')
move_ids.append(act[1])
if isinstance(act[1], (int, long)): move_ids.append(act[1]) else: move_ids.extend(act[1])
def set_inventory_moves(self, cursor, user, shipment_id, name, value, arg, context=None): move_obj = self.pool.get('stock.move')
move_ids.append(act[1])
if isinstance(act[1], (int, long)): move_ids.append(act[1]) else: move_ids.extend(act[1])
def set_outgoing_moves(self, cursor, user, shipment_id, name, value, arg, context=None): move_obj = self.pool.get('stock.move')
self.assertRaises(Exception, test_view('stock'))
test_view('stock')
def test0005views(self): ''' Test views. ''' self.assertRaises(Exception, test_view('stock'))
form = UploadForm(request.POST,request.FILES)
def profile_upload(request): form = UploadForm(request.POST,request.FILES) if request.method == "POST": if form.is_valid(): print form else: return render_to_response('passport/profile_upload.html',{'form':form}) else: return render_to_response('passport/profile_upload.html',{'form':form})
print form
reader = csv.reader(form.cleaned_data['file'], delimiter=',', quotechar='"') first = True for row in reader: if first: first = False else: tmp = DrexelProfile() tmp.drexel_id = row[0] tmp.firstname = row[2] tmp.lastname = row[1] tmp.drexel_username = row[4] tmp.save() return render_to_response('passport/profile_success...
def profile_upload(request): form = UploadForm(request.POST,request.FILES) if request.method == "POST": if form.is_valid(): print form else: return render_to_response('passport/profile_upload.html',{'form':form}) else: return render_to_response('passport/profile_upload.html',{'form':form})
debug("error creating PDF: %s" % exception)
widgets.debug("error creating PDF: %s" % exception)
def on_savepdf__clicked(button, widgets, state): if not state.downloaded_images or not state.pdf_filename: widgets.debug("Error creating PDF") return try: from reportlab.lib import pagesizes from reportlab.lib.units import cm except ImportError: widgets.debug("You need to install ReportLab (http://www.reportlab.com/)" ...
for filepath in ["data/main.glade", "/usr/share/pysheng/main.glade"]:
for filepath in ["data/main.glade", "../pysheng/main.glade"]:
def run(book_url=None): widget_names = [ "window", "url", "destdir", "check", "start", "cancel", "pause", "exit", "log", "page_start", "page_end", "title", "attribution", "npages", "browse_destdir", "progress_all", "progress_current", "savepdf", ] for filepath in ["data/main.glade", "/usr/share/pysheng/main.glade"]: if...
to_reinfroce_against.append(p) for p in to_reinfroce_against:
to_reinforce_against.append(p) for p in to_reinforce_against:
def CommitReinforcements(self): if L.DEBUG: l.debug('in CommitReinforcements (PW3)') if L.DEBUG: l.debug('reinforcing against currenty enemy threats') to_reinforce_against = [] for p in self.EnemyPlanets(): if p.GetNumShips()>=4*p.GrowthRate(): to_reinfroce_against.append(p)
_GetTempPathW.argtypes = [DWORD, LPSTR]
_GetTempPathW.argtypes = [DWORD, LPWSTR]
def GetTempPathW(): _GetTempPathW = windll.kernel32.GetTempPathW _GetTempPathW.argtypes = [DWORD, LPSTR] _GetTempPathW.restype = DWORD nBufferLength = _GetTempPathW(0, None) if nBufferLength <= 0: raise ctypes.WinError() lpBuffer = ctypes.create_unicode_buffer(u'', nBufferLength) nCopied = _GetTempPathW(nBufferLength...
_GetTempFileNameW.argtypes = [LPSTR, LPSTR, UINT, LPSTR]
_GetTempFileNameW.argtypes = [LPWSTR, LPWSTR, UINT, LPWSTR]
def GetTempFileNameW(lpPathName = None, lpPrefixString = u"TMP", uUnique = 0): _GetTempFileNameW = windll.kernel32.GetTempFileNameW _GetTempFileNameW.argtypes = [LPSTR, LPSTR, UINT, LPSTR] _GetTempFileNameW.restype = UINT if lpPathName is None: lpPathName = GetTempPathW() lpTempFileName = ctypes.create_unicode_buffer...
" %prog [options] -e <executable> [parameters for the target]\n"
" %prog [options] -w <executable> [parameters for the target]\n"
def parse_cmdline(self, argv): 'Parse the command line.'
def __init__(self, binaryKeys = False, initialKeys = None): """ @type binaryKeys: bool @param binaryKeys: C{True} to marshall keys to binary format, C{False} to use plaintext marshalled keys.
optimizeKeys = False optimizeValues = False compressKeys = False compressValues = False escapeKeys = False escapeValues = False binaryKeys = False binaryValues = False def __init__(self, initialKeys = None): """
def __init__(self, binaryKeys = False, initialKeys = None): """ @type binaryKeys: bool @param binaryKeys: C{True} to marshall keys to binary format, C{False} to use plaintext marshalled keys.
self.binaryKeys = binaryKeys
def __init__(self, binaryKeys = False, initialKeys = None): """ @type binaryKeys: bool @param binaryKeys: C{True} to marshall keys to binary format, C{False} to use plaintext marshalled keys.
if self.binaryKeys:
if self.optimizeKeys:
def marshall_key(self, key): """ Marshalls a Crash key to be used in the database.
skey = zlib.compress(skey, zlib.Z_BEST_COMPRESSION) skey = buffer(skey)
def marshall_key(self, key): """ Marshalls a Crash key to be used in the database.
try:
if self.escapeKeys: key = key.decode('hex') if self.compressKeys:
def unmarshall_key(self, key): """ Unmarshalls a Crash key read from the database.
except Exception: pass
def unmarshall_key(self, key): """ Unmarshalls a Crash key read from the database.
value = pickle.dumps(crash, protocol = pickle.HIGHEST_PROTOCOL)
if self.optimizeValues: value = pickle.dumps(crash, protocol = pickle.HIGHEST_PROTOCOL) value = optimize(value) else: value = pickle.dumps(crash, protocol = 0)
def marshall_value(self, value, storeMemoryMap = False): """ Marshalls a Crash object to be used in the database. The C{memoryMap} member is B{NOT} stored here.
value = optimize(value) value = zlib.compress(value, zlib.Z_BEST_COMPRESSION) value = buffer(value)
if self.compressValues: value = zlib.compress(value, zlib.Z_BEST_COMPRESSION) if self.escapeValues: value = value.encode('hex') if self.binaryValues: value = buffer(value)
def marshall_value(self, value, storeMemoryMap = False): """ Marshalls a Crash object to be used in the database. The C{memoryMap} member is B{NOT} stored here.
value = zlib.decompress(value)
if self.escapeValues: value = value.decode('hex') if self.compressValues: value = zlib.decompress(value)
def unmarshall_value(self, value): """ Unmarshalls a Crash object read from the database.
ContainerBase.__init__(self, False, keys)
ContainerBase.__init__(self, keys)
def __init__(self, filename = None, allowRepeatedKeys = False): """ @type filename: str @param filename: (Optional) File name for crash database. If no filename is specified, the container is volatile.
ContainerBase.__init__(self, False)
ContainerBase.__init__(self)
def __init__(self, filename = None, allowRepeatedKeys = False): """ @type filename: str @param filename: (Optional) File name for crash database. If no filename is specified, the container is volatile.
__table_definition = (
_table_definition = (
def get(self, key): """ Retrieves a crash from the container.
"timeStamp TIMESTAMP,"
"timeStamp TEXT,"
def get(self, key): """ Retrieves a crash from the container.
__insert_row = ( "INSERT INTO Crashes VALUES (null%s)" % (',?' * (len(__table_definition.split(',')) - 1))
_insert_row = ( "INSERT INTO Crashes VALUES (null, %s)" % ','.join(['?'] * (len(_table_definition.split(',')) - 1))
def get(self, key): """ Retrieves a crash from the container.
__select_pickle = "SELECT pickle FROM Crashes" __select_key = "SELECT key FROM Crashes" __select_count = "SELECT COUNT(*) FROM Crashes" __memory_table_definition = (
_select_pickle = "SELECT pickle FROM Crashes" _select_key = "SELECT key FROM Crashes" _select_count = "SELECT COUNT(*) FROM Crashes" _memory_table_definition = (
def get(self, key): """ Retrieves a crash from the container.
__memory_insert_row = ( "INSERT INTO Memory VALUES " "(null, ?, ?, ?, ?, ?, ?, ?, ?)"
_memory_insert_row = ( "INSERT INTO Memory VALUES (null, %s)" % ','.join(['?'] * (len(_memory_table_definition.split(',')) - 1))
def get(self, key): """ Retrieves a crash from the container.
def __get_row_values(self, crash):
def _get_row_values(self, crash):
def __get_row_values(self, crash): timeStamp = time.asctime( time.gmtime( crash.timeStamp ) ) key = self.marshall_key( crash.key() ) pickle = self.marshall_value(crash) isExploitable, isExploitableRule, _ = crash.isExploitable() eventCode = crash.eventCode pid ...
def __memory_get_row_values(self, CrashID, mbi):
def _memory_get_row_values(self, CrashID, mbi):
def __memory_get_row_values(self, CrashID, mbi):
self.__location = location self.__dbtype = dbtype self.__db = db self.__cursor = cursor
self._location = location self._dbtype = dbtype self._db = db self._cursor = cursor
def __init__(self, location = None, allowRepeatedKeys = True): """ @type location: str @param location: (Optional) Location of the crash database. If the location is a filename, it's an SQLite database file.
self.__cursor.execute(self.__table_definition) self.__cursor.execute(self.__memory_table_definition) self.__db.commit()
self._cursor.execute(self._table_definition) self._cursor.execute(self._memory_table_definition) self._db.commit()
def __init__(self, location = None, allowRepeatedKeys = True): """ @type location: str @param location: (Optional) Location of the crash database. If the location is a filename, it's an SQLite database file.
self.__allowRepeatedKeys = allowRepeatedKeys
self._allowRepeatedKeys = allowRepeatedKeys
def __init__(self, location = None, allowRepeatedKeys = True): """ @type location: str @param location: (Optional) Location of the crash database. If the location is a filename, it's an SQLite database file.
self.__cursor.execute(self.__select_key) for row in self.__cursor:
self._cursor.execute(self._select_key) for row in self._cursor:
def __init__(self, location = None, allowRepeatedKeys = True): """ @type location: str @param location: (Optional) Location of the crash database. If the location is a filename, it's an SQLite database file.
ContainerBase.__init__(self, True, keys)
ContainerBase.__init__(self, keys)
def __init__(self, location = None, allowRepeatedKeys = True): """ @type location: str @param location: (Optional) Location of the crash database. If the location is a filename, it's an SQLite database file.
self.__cursor.execute(self.__select_count)
self._cursor.execute(self._select_count)
def __init__(self, location = None, allowRepeatedKeys = True): """ @type location: str @param location: (Optional) Location of the crash database. If the location is a filename, it's an SQLite database file.
for row in self.__cursor:
for row in self._cursor:
def __init__(self, location = None, allowRepeatedKeys = True): """ @type location: str @param location: (Optional) Location of the crash database. If the location is a filename, it's an SQLite database file.
self.__count = count
self._count = count
def __init__(self, location = None, allowRepeatedKeys = True): """ @type location: str @param location: (Optional) Location of the crash database. If the location is a filename, it's an SQLite database file.
if self.__allowRepeatedKeys or crash not in self:
if self._allowRepeatedKeys or crash not in self:
def add(self, crash): """ Adds a new crash to the container.
row_values = self.__get_row_values(crash) self.__cursor.execute(self.__insert_row, row_values)
row_values = self._get_row_values(crash) self._cursor.execute(self._insert_row, row_values)
def add(self, crash): """ Adds a new crash to the container.
cid = self.__cursor.lastrowid
cid = self._cursor.lastrowid
def add(self, crash): """ Adds a new crash to the container.
row_values = self.__memory_get_row_values(cid, mbi) self.__cursor.execute(self.__memory_insert_row, row_values)
row_values = self._memory_get_row_values(cid, mbi) self._cursor.execute(self._memory_insert_row, row_values)
def add(self, crash): """ Adds a new crash to the container.
self.__db.commit()
self._db.commit()
def add(self, crash): """ Adds a new crash to the container.
self.__db.rollback()
self._db.rollback()
def add(self, crash): """ Adds a new crash to the container.
self.__count += 1
self._count += 1
def add(self, crash): """ Adds a new crash to the container.
self.__cursor.execute(self.__select_pickle) for row in self.__cursor:
self._cursor.execute(self._select_pickle) for row in self._cursor:
def __iter__(self): """ @rtype: iterator @return: Iterator of the contained L{Crash} objects. """ self.__cursor.execute(self.__select_pickle) for row in self.__cursor: crash = row[0] crash = self.unmarshall_value(crash) yield crash
return self.__count
return self._count
def __len__(self): """ @rtype: int @return: Count of L{Crash} elements in the container. """ return self.__count
return location, 'odbc', db, cursor
return connectionString, 'odbc', db, cursor
def _connect(self, connectionString): """ Connect to a remote SQL database using the given connection string.
return self.__dict.has_key( crash.key() )
return self._dict.has_key( crash.key() )
def __contains__(self, crash): """ @type crash: L{Crash} @param crash: Crash object.
is_address_executable_and_writeable
is_address_executable_and_writeable, is_buffer_mapped, is_buffer_readable, is_buffer_writeable, is_buffer_executable, is_buffer_executable_and_writeable
def notify_exit_process(self, event): """ Notify the termination of a process.
if not self.mquery(lpBaseAddress).has_content():
if not self.is_buffer(lpBaseAddress, nSize):
def read(self, lpBaseAddress, nSize): """ Reads from the memory of the process.
data = win32.ReadProcessMemory(self.get_handle(),
for mbi in self.get_memory_map(lpBaseAddress, lpBaseAddress + nSize): if not mbi.is_readable(): nSize = mbi.BaseAddress - lpBaseAddress break if nSize > 0: data = win32.ReadProcessMemory(self.get_handle(),
def peek(self, lpBaseAddress, nSize): """ Reads the memory of the process.
if not lpBaseAddress or dwMaxSize == 0: if fUnicode: return u'' return '' if not dwMaxSize: dwMaxSize = 0x1000
def peek_string(self, lpBaseAddress, fUnicode = False, dwMaxSize = 0x1000): """ Tries to read an ASCII or Unicode string from the address space of the process.