rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
if section.VirtualAddress > 0x10000000:
if adjust_VirtualAddress( section.VirtualAddress, self.OPTIONAL_HEADER.SectionAlignment ) > 0x10000000:
def parse_sections(self, offset): """Fetch the PE file sections. The sections will be readily available in the "sections" attribute. Its attributes will contain all the section information plus "data" a buffer containing the section's data. The "Characteristics" member will be processed and attributes representing th...
'Error parsing the Import directory at RVA: 0x%x' % ( rva ) )
'Error parsing the import directory at RVA: 0x%x' % ( rva ) )
def parse_import_directory(self, rva, size): """Walk and parse the import directory.""" import_descs = [] while True: try: # If the RVA is invalid all would blow up. Some EXEs seem to be # specially nasty and have an invalid RVA. data = self.get_data(rva, Structure(self.__IMAGE_IMPORT_DESCRIPTOR_format__).sizeof() ) ...
'Error parsing the Import directory. ' +
'Error parsing the import directory. ' +
def parse_import_directory(self, rva, size): """Walk and parse the import directory.""" import_descs = [] while True: try: # If the RVA is invalid all would blow up. Some EXEs seem to be # specially nasty and have an invalid RVA. data = self.get_data(rva, Structure(self.__IMAGE_IMPORT_DESCRIPTOR_format__).sizeof() ) ...
imports_section = self.get_section_by_rva(first_thunk) if not imports_section: raise PEFormatError, 'Invalid/corrupt imports.'
def parse_imports(self, original_first_thunk, first_thunk, forwarder_chain): """Parse the imported symbols. It will fill a list, which will be available as the dictionary attribute "imports". Its keys will be the DLL names and the values all the symbols imported from that object. """ imported_symbols = [] imports_sec...
if self.PE_TYPE == OPTIONAL_HEADER_MAGIC_PE: format = self.__IMAGE_THUNK_DATA_format__ elif self.PE_TYPE == OPTIONAL_HEADER_MAGIC_PE_PLUS: format = self.__IMAGE_THUNK_DATA64_format__
def get_import_table(self, rva): table = []
mapped_data = ''+self.__data__
mapped_data = ''+ self.__data__[:]
def get_memory_mapped_image(self, max_virtual_address=0x10000000, ImageBase=None): """Returns the data corresponding to the memory layout of the PE file. The data includes the PE header and the sections loaded at offsets corresponding to their relative virtual addresses. (the VirtualAddress section header member). Any...
if section.PointerToRawData > len(self.__data__):
if adjust_PointerToRawData( section.PointerToRawData ) > len(self.__data__):
def get_memory_mapped_image(self, max_virtual_address=0x10000000, ImageBase=None): """Returns the data corresponding to the memory layout of the PE file. The data includes the PE header and the sections loaded at offsets corresponding to their relative virtual addresses. (the VirtualAddress section header member). Any...
if section.VirtualAddress >= max_virtual_address:
VirtualAddress_adj = adjust_VirtualAddress( section.VirtualAddress, self.OPTIONAL_HEADER.SectionAlignment ) if VirtualAddress_adj >= max_virtual_address:
def get_memory_mapped_image(self, max_virtual_address=0x10000000, ImageBase=None): """Returns the data corresponding to the memory layout of the PE file. The data includes the PE header and the sections loaded at offsets corresponding to their relative virtual addresses. (the VirtualAddress section header member). Any...
padding_length = section.VirtualAddress - len(mapped_data)
padding_length = VirtualAddress_adj - len(mapped_data)
def get_memory_mapped_image(self, max_virtual_address=0x10000000, ImageBase=None): """Returns the data corresponding to the memory layout of the PE file. The data includes the PE header and the sections loaded at offsets corresponding to their relative virtual addresses. (the VirtualAddress section header member). Any...
self.update_all_section_data()
def get_memory_mapped_image(self, max_virtual_address=0x10000000, ImageBase=None): """Returns the data corresponding to the memory layout of the PE file. The data includes the PE header and the sections loaded at offsets corresponding to their relative virtual addresses. (the VirtualAddress section header member). Any...
raise PEFormatError("specified offset (0x%x) doesn't belong to any section." % offset)
if self.sections: lowest_rva = min( [adjust_VirtualAddress( s.VirtualAddress, self.OPTIONAL_HEADER.SectionAlignment ) for s in self.sections] ) if offset < lowest_rva: return offset else: return offset
def get_rva_from_offset(self, offset): """Get the RVA corresponding to this file offset. """ s = self.get_section_by_offset(offset) if not s: raise PEFormatError("specified offset (0x%x) doesn't belong to any section." % offset) return s.get_rva_from_offset(offset)
if rva<len(self.header): return self.get_string_from_data(rva, self.header)
if rva < len(self.header): return self.get_string_from_data(0, self.__data__[rva:rva+MAX_STRING_LENGTH])
def get_string_at_rva(self, rva): """Get an ASCII string located at the given address.""" s = self.get_section_by_rva(rva) if not s: if rva<len(self.header): return self.get_string_from_data(rva, self.header) return None return self.get_string_from_data( 0, s.get_data(rva, length=MAX_STRING_LENGTH) )
self.update_all_section_data()
def set_bytes_at_offset(self, offset, data): """Overwrite the bytes at the given file offset with the given string. Return True if successful, False otherwise. It can fail if the offset is outside the file's boundaries. """ if not isinstance(data, str): raise TypeError('data should be of type: str') if offset >= 0 a...
section_data_start = section.PointerToRawData
section_data_start = adjust_PointerToRawData( section.PointerToRawData )
def merge_modified_section_data(self): """Update the PE image content with any individual section data that has been modified.""" for section in self.sections: section_data_start = section.PointerToRawData section_data_end = section_data_start+section.SizeOfRawData if section_data_start < len(self.__data__) and sectio...
if not iat and not ilt:
if (not iat or len(iat)==0) and (not ilt or len(ilt)==0):
def parse_imports(self, original_first_thunk, first_thunk, forwarder_chain): """Parse the imported symbols. It will fill a list, which will be available as the dictionary attribute "imports". Its keys will be the DLL names and the values all the symbols imported from that object. """ imported_symbols = [] imports_sec...
This will return true only if the ImageBase field of the OptionalHeader is above or equal to 0x80000000 (that is, whether it lies in the upper 2GB of the address space, normally belonging to the kernel) and if it imports symbols from "ntoskrnl.exe".
This will return true only if there are reliable indicators of the image being a driver.
def is_driver(self): """Check whether the file is a Windows driver. This will return true only if the ImageBase field of the OptionalHeader is above or equal to 0x80000000 (that is, whether it lies in the upper 2GB of the address space, normally belonging to the kernel) and if it imports symbols from "ntoskrnl.exe". "...
if self.OPTIONAL_HEADER.ImageBase >= 0x80000000L: return True
def is_driver(self): """Check whether the file is a Windows driver. This will return true only if the ImageBase field of the OptionalHeader is above or equal to 0x80000000 (that is, whether it lies in the upper 2GB of the address space, normally belonging to the kernel) and if it imports symbols from "ntoskrnl.exe". "...
if 'ntoskrnl' in [ imp.dll.lower() for imp in self.DIRECTORY_ENTRY_IMPORT ]:
if set( ('ntoskrnl.exe', 'hal.dll', 'ndis.sys', 'bootvid.dll', 'kdcom.dll' ) ).intersection( [ imp.dll.lower() for imp in self.DIRECTORY_ENTRY_IMPORT ] ):
def is_driver(self): """Check whether the file is a Windows driver. This will return true only if the ImageBase field of the OptionalHeader is above or equal to 0x80000000 (that is, whether it lies in the upper 2GB of the address space, normally belonging to the kernel) and if it imports symbols from "ntoskrnl.exe". "...
lang_name = LANG[lang_value] for sublang_name in SUBLANG[sublang_value]:
lang_name = LANG.get(lang_value, '*unknown*') for sublang_name in SUBLANG.get(sublang_value, list()):
def get_sublang_name_for_lang( lang_value, sublang_value ): lang_name = LANG[lang_value] for sublang_name in SUBLANG[sublang_value]: # if the main language is a substring of sublang's name, then # return that if lang_name in sublang_name: return sublang_name # otherwise return the first sublang name return SUBLANG[subl...
return SUBLANG[sublang_value][0]
return SUBLANG.get(sublang_value, ['*unknown*'])[0]
def get_sublang_name_for_lang( lang_value, sublang_value ): lang_name = LANG[lang_value] for sublang_name in SUBLANG[sublang_value]: # if the main language is a substring of sublang's name, then # return that if lang_name in sublang_name: return sublang_name # otherwise return the first sublang name return SUBLANG[subl...
if stringfileinfo_string.startswith(u'StringFileInfo'):
if stringfileinfo_string and stringfileinfo_string.startswith(u'StringFileInfo'):
def parse_version_information(self, version_struct): """Parse version information structure. The date will be made available in three attributes of the PE object. VS_VERSIONINFO will contain the first three fields of the main structure: 'Length', 'ValueLength', and 'Type' VS_FIXEDFILEINFO will hold the rest o...
elif stringfileinfo_string.startswith( u'VarFileInfo' ):
elif stringfileinfo_string and stringfileinfo_string.startswith( u'VarFileInfo' ):
def parse_version_information(self, version_struct): """Parse version information structure. The date will be made available in three attributes of the PE object. VS_VERSIONINFO will contain the first three fields of the main structure: 'Length', 'ValueLength', and 'Type' VS_FIXEDFILEINFO will hold the rest o...
LANG[resource_lang.data.lang], get_sublang_name_for_lang( resource_lang.data.lang, resource_lang.data.sublang ) ), 8)
LANG.get(resource_lang.data.lang, '*unknown*'), get_sublang_name_for_lang( resource_lang.data.lang, resource_lang.data.sublang ) ), 8)
def convert_to_printable(s): return ''.join([convert_char(c) for c in s])
dos_header_data = self.__data__[:64] if len(dos_header_data) != 64: raise PEFormatError('Unable to read the DOS Header, possibly a truncated file.')
def __parse__(self, fname, data, fast_load): """Parse a Portable Executable file. Loads a PE file, parsing all its structures and making them available through the instance's attributes. """ if fname: fd = file(fname, 'rb') self.fileno = fd.fileno() self.__data__ = mmap.mmap( self.fileno, 0, access = mmap.ACCESS_READ...
self.__data__, file_offset=0)
dos_header_data, file_offset=0)
def __parse__(self, fname, data, fast_load): """Parse a Portable Executable file. Loads a PE file, parsing all its structures and making them available through the instance's attributes. """ if fname: fd = file(fname, 'rb') self.fileno = fd.fileno() self.__data__ = mmap.mmap( self.fileno, 0, access = mmap.ACCESS_READ...
name_offset = self.get_offset_from_rva( symbol_name_address ),
name_offset = symbol_name_offset,
def length_until_eof(rva): return len(self.__data__) - self.get_offset_from_rva(rva)
forwarder_offset = self.get_offset_from_rva( symbol_address ) ))
forwarder_offset = forwarder_offset ))
def length_until_eof(rva): return len(self.__data__) - self.get_offset_from_rva(rva)
symbol_address = self.get_dword_from_data( address_of_functions, idx) if symbol_address is None or symbol_address == 0:
try: symbol_address = self.get_dword_from_data( address_of_functions, idx) except PEFormatError: symbol_address = None if symbol_address is None: max_failed_entries_before_giving_up -= 1 if max_failed_entries_before_giving_up <= 0: break if symbol_address == 0:
def length_until_eof(rva): return len(self.__data__) - self.get_offset_from_rva(rva)
def get_data(self, rva, length=None):
def get_data(self, rva=0, length=None):
def get_data(self, rva, length=None): """Get data regardless of the section where it lies on. Given a RVA and the size of the chunk to retrieve, this method will find the section where the data lies and return the data. """ s = self.get_section_by_rva(rva) if length: end = rva + length else: end = None
dump.add('%-10d 0x%08Xh %s' % ( export.ordinal, export.address, export.name)) if export.forwarder: dump.add_line(' forwarder: %s' % export.forwarder) else: dump.add_newline()
if export.address is not None: dump.add('%-10d 0x%08Xh %s' % ( export.ordinal, export.address, export.name)) if export.forwarder: dump.add_line(' forwarder: %s' % export.forwarder) else: dump.add_newline()
def convert_to_printable(s): return ''.join([convert_char(c) for c in s])
overlay_data_offset = self.get_overlay_data_start_offset() if overlay_data_offset is not None: return self.__data__[ overlay_data_offset : ] return None
def get_overlay(self): """Get data not contained within the areas described in the headers."""
thunk_offset = table[idx].get_file_offset() thunk_rva = self.get_rva_from_offset(thunk_offset)
def parse_imports(self, original_first_thunk, first_thunk, forwarder_chain): """Parse the imported symbols. It will fill a list, which will be available as the dictionary attribute "imports". Its keys will be the DLL names and the values all the symbols imported from that object. """ imported_symbols = [] imports_sec...
hint_name_table_rva = hint_name_table_rva))
hint_name_table_rva = hint_name_table_rva, thunk_offset = thunk_offset, thunk_rva = thunk_rva ))
def parse_imports(self, original_first_thunk, first_thunk, forwarder_chain): """Parse the imported symbols. It will fill a list, which will be available as the dictionary attribute "imports". Its keys will be the DLL names and the values all the symbols imported from that object. """ imported_symbols = [] imports_sec...
if rva < len(self.header): return self.get_string_from_data(0, self.__data__[rva:rva+MAX_STRING_LENGTH]) return None
return self.get_string_from_data(0, self.__data__[rva:rva+MAX_STRING_LENGTH])
def get_string_at_rva(self, rva): """Get an ASCII string located at the given address."""
dump.append('%-30s %s' % (key+':', val_str))
dump.append('0x%-8X 0x%-3X %-30s %s' % ( self.__field_offsets__[key] + self.__file_offset__, self.__field_offsets__[key], key+':', val_str))
def dump(self, indentation=0): """Returns a string representation of the structure.""" dump = [] dump.append('[%s]' % self.name) # Refer to the __set_format__ method for an explanation # of the following construct. for keys in self.__keys__: for key in keys: val = getattr(self, key) if isinstance(val, int) or isins...
command = '%s -classpath ../../build/classes/java:../../build/classes/demo:../../build/contrib/highlighter/classes/java:lib/commons-digester-1.7.jar:lib/commons-collections-3.1.jar:lib/commons-compress-1.0.jar:lib/commons-logging-1.0.4.jar:lib/commons-beanutils-1.7.0.jar:lib/xerces-2.9.0.jar:lib/xml-apis-2.9.0.jar:../....
command = '%s -classpath ../../build/classes/java:../../build/classes/demo:../../build/contrib/highlighter/classes/java:lib/commons-digester-1.7.jar:lib/commons-collections-3.1.jar:lib/commons-compress-1.0.jar:lib/commons-logging-1.0.4.jar:lib/commons-beanutils-1.7.0.jar:lib/xerces-2.10.0.jar:lib/xml-apis-2.10.0.jar:.....
def runOne(self, dir, alg, logFileName, expectedMaxDocs=None, expectedNumDocs=None, queries=None, verify=False, isIndex=False):
if 0 <= pos.e and pos.e <= n - 1: if i <= (w - 2): if profil[i] is 1: return [fsc.StandardPosition(i + 1, e)] k = fsc.positiveK(profil[i:min(n - e + 1, len(profil) - i)]) if k is not None: return [fsc.StandardPosition(i, e + 1), fsc.StandardPosition(i + 1, e + 1), fsc.StandardPosition(i + k, e + k - 1)] else: return [f...
if i < w and profil[i] is 1: return [fsc.StandardPosition(i + 1, e)] positions = [fsc.StandardPosition(i, e + 1), fsc.StandardPosition(i + 1, e + 1)] if i < w: k = fsc.positiveK(profil[i:i + min(n - e + 1, len(profil) - i)]) if k is not None: positions.append(fsc.StandardPosition(i + k, e + k - 1)) positions = filt...
def transition(n, profil, pos): i = pos.i e = pos.e w = len(profil) if 0 <= pos.e and pos.e <= n - 1: if i <= (w - 2): if profil[i] is 1: return [fsc.StandardPosition(i + 1, e)] k = fsc.positiveK(profil[i:min(n - e + 1, len(profil) - i)]) if k is not None: return [fsc.StandardPosition(i, e + 1), fsc.StandardPosition(i ...
w = len(profil)
def getNextState(n, profil, state): w = len(profil) nState = [] for pos in state: nState += transition(n, profil, pos) return nState
if str(state) == str([(2,1), (0,1)]) and \ str(newLhs) == str([(2,1), (3,1)]): set_trace()
def getSimilarState(lhs, states): """lhs and all states items must be a reduced state""" foundState = None if lhs == []: foundState = ([], 0) i = 0 while i < len(states) and foundState is None: state = copy(states[i]) if state != []: state.sort() newLhs = copy(lhs) newLhs.sort() difference = newLhs[0].i - state[0].i i...
set_trace()
raise "Didn't found state"
def getSimilarState(lhs, states): """lhs and all states items must be a reduced state""" foundState = None if lhs == []: foundState = ([], 0) i = 0 while i < len(states) and foundState is None: state = copy(states[i]) if state != []: state.sort() newLhs = copy(lhs) newLhs.sort() difference = newLhs[0].i - state[0].i i...
objectInfo=entry,
objectInfo=entry.copy(),
def _retrieveSingleFeed(self, feedContainer, url): # feedparser doesn't understand proper file: url's if url.startswith('file://'): url = url[7:] if not os.path.exists(url): raise IOError("Couldn't locate %r" % url) # urllib does not support the 'feed' scheme -- replace with 'http' if url.startswith('feed://'): url = u...
>>> view1.redirect_url() 'http://somewhere'
>>> bool(view1.redirect_url()) False
... def checkEditPermission(self):
>>> bool(view1.redirect_url()) False
>>> view1.redirect_url() 'http://somewhere'
... def checkEditPermission(self):
return ViewPageTemplateFile('feed-item.pt')(self)
return self.index()
def __call__(self): redirect_url = self.redirect_url() if redirect_url: return self.request.response.redirect(redirect_url) return ViewPageTemplateFile('feed-item.pt')(self)
__call__ = PageTemplateFile('feed-item.pt')
def __call__(self): redirect_url = self.redirect_url() if redirect_url: return self.request.response.redirect(redirect_url) return ViewPageTemplateFile('feed-item.pt')(self)
... def checkEditPermission(self):
if parent.getRedirect() and self.checkEditPermission():
if parent.getRedirect() and not self.checkEditPermission():
def redirect_url(self): object_info = self.context.getObjectInfo() parent = self.parent() if parent.getRedirect() and self.checkEditPermission(): return object_info.get('link') else: return ''
try: sig = md5.new(entry.id) except AttributeError: sig = md5.new(entry.link) id = sig.hexdigest()
id = get_uid_from_entry(entry) if not id: logger.warn("Ignored unidentifiable entry without id or link.") continue
def _retrieveSingleFeed(self, feedContainer, url): # feedparser doesn't understand proper file: url's if url.startswith('file://'): url = url[7:] if not os.path.exists(url): raise IOError("Couldn't locate %r" % url) # urllib does not support the 'feed' scheme -- replace with 'http' if url.startswith('feed://'): url = u...
Returns an empty string if redirect is not enabled or if you don't have modify
Returns an empty string if redirect is not enabled or if you have modify
def redirect_url(): """ Returns empty string or the url to be redirected, depending on the configuration of the feed folder. Returns an empty string if redirect is not enabled or if you don't have modify permissions """
print "main dispatcher"
def dispatch( self ): print "main dispatcher" theme_pos = self.path.find( "theme=" ) if theme_pos > 0: #print "Theme found at: " + theme_pos.__str__() theme = self.path[theme_pos + 6:] #print "New theme: " + theme self.config.staticTheme = theme self.path = self.config.staticTheme + "/index.html" StaticDispatcher.dispa...
except ParseError:
except etree.ParseError:
def _extract_and_return_icon(self, status): if status.code != 200: return status try: xml = StringIO(status.data) tree = etree.parse(xml) root = tree.getroot() ns = root.nsmap[None] icon = None except ParseError: return StatusResponse(500) else: for element in root: if element.tag == "{%s}data" % ns: try: icon = base64...
if sub_handling is not None and sub_handling.text != 'allow' and rule.find(transformations_tag) is not None:
transformations = rule.find(transformations_tag) if sub_handling is not None and sub_handling.text != 'allow' and transformations is not None and transformations.getchildren():
def _validate_rules(self, document, node_uri): common_policy_namespace = 'urn:ietf:params:xml:ns:common-policy' oma_namespace = 'urn:oma:xml:xdm:common-policy'
__all__ = [applications, public_get_applications, getApplicationForURI, ApplicationUsage, Backend]
__all__ = ['applications', 'namespaces', 'public_get_applications', 'getApplicationForURI', 'ApplicationUsage', 'Backend']
def getApplicationForURI(xcap_uri): return applications.get(xcap_uri.application_id, None)
if msg:
if msg and response.stream.length < 5000:
def log_access(request, response, reason=None): if getattr(request, '_logged', False): return msg = format_log_message(request, response, reason) request._logged = True if msg: log.msg(AccessLog(msg))
log_error_to_file = False
def __repr__(self): return "AnyErrorCode"
if Logging.log_error_to_file: error_file = LogFile('error.log', directory, **self.params) self.error = FileLogObserver(error_file) else: self.error = log.SyslogObserver('openxcap')
error_file = LogFile('error.log', directory, **self.params) self.error = FileLogObserver(error_file)
def __init__(self, directory): access_file = LogFile('access.log', directory, **self.params) self.access = FileLogObserver(access_file) if Logging.log_error_to_file: error_file = LogFile('error.log', directory, **self.params) self.error = FileLogObserver(error_file) else: self.error = log.SyslogObserver('openxcap')
def testNonVisibilityAffected(self):
def test_nonVisibilityAffected(self):
def testNonVisibilityAffected(self): """ L{LocationLightning} blocks out non-IVisible stuff from L{findProviders} by default. """ self.assertEquals( list(self.observer.findProviders(iimaginary.IThing, 3)), []) # XXX need another test: not blocked out from ...
L{findProviders} by default.
L{Thing.findProviders} by default.
def testNonVisibilityAffected(self): """ L{LocationLightning} blocks out non-IVisible stuff from L{findProviders} by default. """ self.assertEquals( list(self.observer.findProviders(iimaginary.IThing, 3)), []) # XXX need another test: not blocked out from ...
def testNonVisibilityUnaffected(self):
def test_nonVisibilityUnaffected(self):
def testNonVisibilityUnaffected(self): """ L{LocationLightning} should not block out non-IVisible stuff from a plain L{Idea.obtain} query. """ self.assertEquals( list(self.observer.idea.obtain( idea.Proximity(3, idea.ProviderOf(iimaginary.IThing)))), [self.observer, self.location, self.rock] )
build = buildfarm.get_build(tree, host.name.encode("utf-8"), compiler)
build = self.buildfarm.get_build(tree, host.name, compiler)
def render(self, myself, output_type): """view build summary""" i = 0 cols = 2 broken = 0 broken_count = {} panic_count = {} host_count = {}
yield "<html>" yield " <head>" yield " <title>samba.org build farm</title>" yield " <script language='javascript' src='/build_farm.js'></script>" yield " <meta name='keywords' contents='Samba SMB CIFS Build Farm'/>" yield " <meta name='description' contents='Home of the Samba Build Farm, the automated test...
yield "<html>\n" yield " <head>\n" yield " <title>samba.org build farm</title>\n" yield " <script language='javascript' src='/build_farm.js'></script>\n" yield " <meta name='keywords' contents='Samba SMB CIFS Build Farm'/>\n" yield " <meta name='description' contents='Home of the Samba Build Farm, the auto...
def __call__(self, environ, start_response): form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) fn_name = get_param(form, 'function') or '' myself = wsgiref.util.application_uri(environ)
parser.add_option("--standalone", help="Run as standalone server (useful for debugging)", action="store_true")
def __call__(self, environ, start_response): form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) fn_name = get_param(form, 'function') or '' myself = wsgiref.util.application_uri(environ)
parser.add_option("--port", help="Port to listen on (in standalone mode) [localhost:8000]", default="localhost:8000", type=str)
parser.add_option("--port", help="Port to listen on [localhost:8000]", default="localhost:8000", type=str)
def __call__(self, environ, start_response): form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) fn_name = get_param(form, 'function') or '' myself = wsgiref.util.application_uri(environ)
if opts.standalone: from wsgiref.simple_server import make_server def standaloneApp(environ, start_response): if environ['PATH_INFO']: dir = os.path.join(os.path.dirname(__file__)) if re.match("^/[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)?", environ['PATH_INFO']): static_file = "%s/%s" % (dir, environ['PATH_INFO']) if os.path.e...
from wsgiref.simple_server import make_server def standaloneApp(environ, start_response): if environ['PATH_INFO']: dir = os.path.join(os.path.dirname(__file__)) if re.match("^/[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)?", environ['PATH_INFO']): static_file = "%s/%s" % (dir, environ['PATH_INFO']) if os.path.exists(static_file): ...
def __call__(self, environ, start_response): form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) fn_name = get_param(form, 'function') or '' myself = wsgiref.util.application_uri(environ)
myself, tree, host, compiler, opt_rev, status)
myself, host, tree, compiler, opt_rev, status)
def build_link(myself, tree, host, compiler, rev, status): if rev: opt_rev = ';revision=%s' % rev else: opt_rev = '' return "<a href='%s?function=View+Build;host=%s;tree=%s;compiler=%s%s'>%s</a>" % ( myself, tree, host, compiler, opt_rev, status)
for host in hosts:
for host in hosts.keys():
def view_summary(myself, output_type): """view build summary""" i = 0 cols = 2 broken = 0 broken_count = {} panic_count = {} host_count = {} # zero broken and panic counters for tree in trees: broken_count[tree] = 0 panic_count[tree] = 0 host_count[tree] = 0 # set up a variable to store the broken builds table's code...
for host in hosts:
for host in hosts.keys():
def status_cmp(a, b): bstat = build_status_vals(b) astat = build_status_vals(a)
assert host in hosts, "unknown host %s" % host
assert host in hosts.keys(), "unknown host %s" % host
def view_build(myself, tree, host, compiler, rev, plain_logs=False): """view one build in detail""" # ensure the params are valid before using them assert host in hosts, "unknown host %s" % host assert compiler in compilers, "unknown compiler %s" % compiler assert tree in trees, "not a build tree %s" % tree uname = ""...
assert host in hosts, "unknown host"
assert host in hosts.keys(), "unknown host"
def view_host(myself, output_type, *requested_hosts): """print the host's table of information""" if output_type == 'text': yield "Host summary:\n" else: yield "<div class='build-section' id='build-summary'>" yield '<h2>Host summary:</h2>' for host in requested_hosts: assert host in hosts, "unknown host" for host in...
yield "<option value='%s'>%s -- %s</option>" % (host, hosts[host], host)
yield "<option value='%s'>%s -- %s</option>\n" % (host, hosts[host], host)
def main_menu(): """main page""" yield "<form method='GET'>" yield "<div id='build-menu'>" yield "<select name='host'>" for host in hosts: yield "<option value='%s'>%s -- %s</option>" % (host, hosts[host], host) yield "</select>" yield "<select name='tree'>" for tree, t in trees.iteritems(): yield "<option value='%s'>...
yield "<option value='%s'>%s:%s</option>" % (tree, tree, t.branch)
yield "<option value='%s'>%s:%s</option>\n" % (tree, tree, t.branch)
def main_menu(): """main page""" yield "<form method='GET'>" yield "<div id='build-menu'>" yield "<select name='host'>" for host in hosts: yield "<option value='%s'>%s -- %s</option>" % (host, hosts[host], host) yield "</select>" yield "<select name='tree'>" for tree, t in trees.iteritems(): yield "<option value='%s'>...
yield "<option>%s</option>" % compiler
yield "<option>%s</option>\n" % compiler
def main_menu(): """main page""" yield "<form method='GET'>" yield "<div id='build-menu'>" yield "<select name='host'>" for host in hosts: yield "<option value='%s'>%s -- %s</option>" % (host, hosts[host], host) yield "</select>" yield "<select name='tree'>" for tree, t in trees.iteritems(): yield "<option value='%s'>...
diff = cgi.escape(diff)
def render(self, myself, tree, revision): t = self.buildfarm.trees[tree] branch = t.get_branch() (entry, diff) = branch.diff(revision) # get information about the current diff title = "GIT Diff in %s:%s for revision %s" % ( tree, t.branch, revision) yield "<h2>%s</h2>" % title changes = branch.changes_summary(revision)...
yield "<pre>%s</pre>\n" % diff
yield "<pre>%s</pre>\n" % diff.encode("utf-8")
def render(self, myself, tree, revision): t = self.buildfarm.trees[tree] branch = t.get_branch() (entry, diff) = branch.diff(revision) # get information about the current diff title = "GIT Diff in %s:%s for revision %s" % ( tree, t.branch, revision) yield "<h2>%s</h2>" % title changes = branch.changes_summary(revision)...
all_builds.append([age_ctime, hosts[host], "<a href='%s?function=View+Host;host=%s;tree=%s;compiler=%s
if revision: all_builds.append([age_ctime, hosts[host], "<a href='%s?function=View+Host;host=%s;tree=%s;compiler=%s
def status_cmp(a, b): bstat = build_status_vals(b) astat = build_status_vals(a)
assert re.match("^[0-9a-fA-F]*$", rev)
if rev: assert re.match("^[0-9a-fA-F]*$", rev)
def view_build(myself, tree, host, compiler, rev, plain_logs=False): """view one build in detail""" # ensure the params are valid before using them assert host in hosts, "unknown host %s" % host assert compiler in compilers, "unknown compiler %s" % compiler assert tree in trees, "not a build tree %s" % tree uname = ""...
yield util.FileLoad("../web/%s.html" % host) yield "<table clas='real'>"
host_web_file = "../web/%s.html" % host if os.path.exists(host_web_file): yield util.FileLoad(host_web_file) yield "<table class='real'>"
def view_build(myself, tree, host, compiler, rev, plain_logs=False): """view one build in detail""" # ensure the params are valid before using them assert host in hosts, "unknown host %s" % host assert compiler in compilers, "unknown compiler %s" % compiler assert tree in trees, "not a build tree %s" % tree uname = ""...
yield show_oldrevs(tree, host, compiler)
yield show_oldrevs(myself, tree, host, compiler) or ""
def view_build(myself, tree, host, compiler, rev, plain_logs=False): """view one build in detail""" # ensure the params are valid before using them assert host in hosts, "unknown host %s" % host assert compiler in compilers, "unknown compiler %s" % compiler assert tree in trees, "not a build tree %s" % tree uname = ""...
id+=1 make_collapsible_html('action', actionName, output, id, status)
indice +=1 make_collapsible_html('action', actionName, output, indice, status)
def pretty_print(m): output = m.group(1) actionName = m.group(2) status = m.group(3) # handle pretty-printing of static-analysis tools if actionName == 'cc_checker': output = print_log_cc_checker(output)
id = 1
def pretty_print(m): output = m.group(1) actionName = m.group(2) status = m.group(3) # handle pretty-printing of static-analysis tools if actionName == 'cc_checker': output = print_log_cc_checker(output)
id += 1 return make_collapsible_html('test', m.group(1), m.group(2), id, m.group(3))
indice += 1 return make_collapsible_html('test', m.group(1), m.group(2), indice, m.group(3))
def format_stage(m): id += 1 return make_collapsible_html('test', m.group(1), m.group(2), id, m.group(3))
id += 1 return make_collapsible_html('test', m.group(1), '', id, 'skipped'),
global indice indice += 1 return make_collapsible_html('test', m.group(1), '', indice, 'skipped')
def format_skip_testsuite(m): id += 1 return make_collapsible_html('test', m.group(1), '', id, 'skipped'),
get_param(form, "compiler"), get_param(form, 'revision'), plain_logs))
get_param(form, "compiler"), get_param(form, "revision"), plain_logs))
def buildApp(environ, start_response): form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) fn_name = get_param(form, 'function') or '' myself = wsgiref.util.application_uri(environ) if standalone and environ['PATH_INFO']: dir = os.path.join(os.path.dirname(__file__)) static_file = "%s/%s" % (dir, enviro...
('Content-type', 'text/x-subunit; charset=utf-8')])
('Content-type', 'text/x-subunit; charset=utf-8'), ('Content-Disposition', 'attachment; filename="%s.%s.%s-%s.subunit"' % (build.tree, build.host, build.compiler, build.revision))])
def __call__(self, environ, start_response): form = cgi.FieldStorage(fp=environ['wsgi.input'], environ=environ) fn_name = get_param(form, 'function') or '' myself = wsgiref.util.application_uri(environ)
host_web_file = "../web/%s.html" % host
host_web_file = "../web/%s.html" % build.host
def render(self, myself, build, plain_logs=False): """view one build in detail"""
(myself, host, tree, compiler, host, self.buildfarm.hostdb[host].platform.encode("utf-8"))
(myself, build.host, build.tree, build.compiler, build.host, self.buildfarm.hostdb[build.host].platform.encode("utf-8"))
def render(self, myself, build, plain_logs=False): """view one build in detail"""
yield "<tr><td>Tree:</td><td>%s</td></tr>\n" % self.tree_link(myself, tree) yield "<tr><td>Build Revision:</td><td>%s</td></tr>\n" % revision_link(myself, build.revision, tree)
yield "<tr><td>Tree:</td><td>%s</td></tr>\n" % self.tree_link(myself, build.tree) yield "<tr><td>Build Revision:</td><td>%s</td></tr>\n" % revision_link(myself, build.revision, build.tree)
def render(self, myself, build, plain_logs=False): """view one build in detail"""
yield "<tr><td>Compiler:</td><td>%s</td></tr>\n" % compiler
yield "<tr><td>Compiler:</td><td>%s</td></tr>\n" % build.compiler
def render(self, myself, build, plain_logs=False): """view one build in detail"""
yield "".join(self.show_oldrevs(myself, tree, host, compiler))
yield "".join(self.show_oldrevs(myself, build.tree, build.host, build.compiler))
def render(self, myself, build, plain_logs=False): """view one build in detail"""
if rev: rev_var = ";revision=%s" % rev
if build.revision: rev_var = ";revision=%s" % build.revision
def render(self, myself, build, plain_logs=False): """view one build in detail"""
" unstyled view'>Plain View</a></p>" % (myself, host, tree, compiler, rev_var)
" unstyled view'>Plain View</a></p>" % (myself, build.host, build.tree, build.compiler, rev_var)
def render(self, myself, build, plain_logs=False): """view one build in detail"""
" view'>Enhanced View</a></p>" % (myself, host, tree, compiler, rev_var)
" view'>Enhanced View</a></p>" % (myself, build.host, build.tree, build.compiler, rev_var)
def render(self, myself, build, plain_logs=False): """view one build in detail"""
build = buildfarm.get_build(tree, host, compiler, rev)
build = self.buildfarm.get_build(tree, host, compiler, rev)
def render(self, myself, tree, host, compiler, rev, plain_logs=False): """view one build in detail""" # ensure the params are valid before using them self.buildfarm.hostdb.host(host) assert compiler in self.buildfarm.compilers, "unknown compiler %s" % compiler assert tree in self.buildfarm.trees, "not a build tree %s" ...
build = buildfarm.get_build(tree, host.name.encode("utf-8"), compiler)
build = self.buildfarm.get_build(tree, host.name.encode("utf-8"), compiler)
def render(self, myself, tree, sort_by): """Draw the "recent builds" view""" last_host = "" all_builds = []
buildfarm.LCOVHOST, tree, lcov_status)
self.buildfarm.LCOVHOST, tree, lcov_status)
def render_html(self, myself): """view build summary"""
for l in f: m = re.search('\<td class="headerItem".*?\>Code\&nbsp\;covered\:\<\/td\>.*?\n.*?\<td class="headerValue".*?\>([0-9.]+) \%', l) if m: return m.group(1) return None
m = re.search('\<td class="headerItem".*?\>Code\&nbsp\;covered\:\<\/td\>.*?\n.*?\<td class="headerValue".*?\>([0-9.]+) \%', f.read()) if m: return m.group(1) else: return None
def lcov_extract_percentage(f): """Extract the coverage percentage from the lcov file.""" for l in f: m = re.search('\<td class="headerItem".*?\>Code\&nbsp\;covered\:\<\/td\>.*?\n.*?\<td class="headerValue".*?\>([0-9.]+) \%', l) if m: return m.group(1) return None
yield "<h2>Older builds:</h2>" yield "<table class='real'>" yield "<thead><tr><th>Revision</th><th>Status</th></tr></thead>" yield "<tbody>"
yield "<h2>Older builds:</h2>\n" yield "<table class='real'>\n" yield "<thead><tr><th>Revision</th><th>Status</th></tr></thead>\n" yield "<tbody>\n"
def show_oldrevs(self, myself, tree, host, compiler): """show the available old revisions, if any""" old_rev_builds = self.buildfarm.builds.get_old_revs(tree, host, compiler)
yield "<tr><td>%s</td><td>%s</td></tr>" % (
yield "<tr><td>%s</td><td>%s</td></tr>\n" % (
def show_oldrevs(self, myself, tree, host, compiler): """show the available old revisions, if any""" old_rev_builds = self.buildfarm.builds.get_old_revs(tree, host, compiler)
build_link(myself, tree, host, compiler, build.revision, html_build_status(build.status()))) yield "</tbody></table>"
build_status_html(myself, build)) yield "</tbody></table>\n"
def show_oldrevs(self, myself, tree, host, compiler): """show the available old revisions, if any""" old_rev_builds = self.buildfarm.builds.get_old_revs(tree, host, compiler)
icon = 'icon_hide_16.png'
icon = '/icon_hide_16.png'
def make_collapsible_html(type, title, output, id, status=""): """generate html for a collapsible section :param type: the logical type of it. e.g. "test" or "action" :param title: the title to be displayed """ if status.lower() in ("", "failed"): icon = 'icon_hide_16.png' else: icon = 'icon_unhide_16.png' # trim lea...
icon = 'icon_unhide_16.png'
icon = '/icon_unhide_16.png'
def make_collapsible_html(type, title, output, id, status=""): """generate html for a collapsible section :param type: the logical type of it. e.g. "test" or "action" :param title: the title to be displayed """ if status.lower() in ("", "failed"): icon = 'icon_hide_16.png' else: icon = 'icon_unhide_16.png' # trim lea...