bugged
stringlengths 4
228k
| fixed
stringlengths 0
96.3M
| __index_level_0__
int64 0
481k
|
|---|---|---|
def get_absolute_url(self): return ("grid", [self.slug])
|
defget_absolute_url(self):return("grid",[self.slug])
| 473,600
|
def __unicode__(self): return '%s : %s' % (self.grid.slug, self.title)
|
def __unicode__(self): return '%s : %s' % (self.grid.slug, self.title)
| 473,601
|
def handle(self, *args, **options):
|
def handle(self, *args, **options):
| 473,602
|
def handle(self, *args, **options):
|
def handle(self, *args, **options):
| 473,603
|
def handle(self, *args, **options): print >> stdout, "Commencing package updating now" github = Github()
|
def handle(self, *args, **options): print >> stdout, "Commencing package updating now" github = Github()
| 473,604
|
def save(self, *args, **kwargs): # Get the downloads from pypi if self.pypi_url: page = urlopen(self.pypi_url).read() # If the target page is an Index of packages if 'Index of Packages' in page: if self.pypi_url.endswith('/'): project_name = self.pypi_url[:-1] else: project_name = self.pypi_url project_name = os.path.split(project_name)[1] logging.debug(project_name) page_re = re.compile(r'<a href="/pypi/%s/([a-zA-Z0-9\.\-\_]{1,})">' % project_name) match = page_re.search(page).group() if match: url = match.replace('<a href="', 'http://pypi.python.org') url = url.replace('">', '') page = urlopen(url).read() else: raise NoPyPiVersionFound('self.pypi_url') # We have a working page so grab the package info match = downloads_re.search(page).group() if match: self.pypi_downloads = match.replace('<td style="text-align: right;">', '') self.pypi_downloads = self.pypi_downloads.replace('</td>', '') self.pypi_downloads = int(self.pypi_downloads) else: self.pypi_downloads = 0 # get the version off of Pypi doap match = doap_re.search(page).group() if match: url = 'http://pypi.python.org%s' % match doap = urlopen(url).read() match = version_re.search(doap).group() self.pypi_version = match.replace('<revision>','').replace('</revision>','') # Get the repo watchers number # TODO - make this abstracted so we can plug in other repos if self.repo.is_supported and 'Github' in self.repo.title and self.repo_url: github = Github() repo_name = self.repo_name() repo = github.repos.show(repo_name) self.repo_watchers = repo.watchers self.repo_forks = repo.forks self.repo_description = repo.description # TODO find out why repo commits limit on github to the first 35 #self.repo_commits = len(github.commits.list(repo_name, "master"))
|
def save(self, *args, **kwargs): # Get the downloads from pypi if self.pypi_url: page = urlopen(self.pypi_url).read() # If the target page is an Index of packages if 'Index of Packages' in page: if self.pypi_url.endswith('/'): project_name = self.pypi_url[:-1] else: project_name = self.pypi_url project_name = os.path.split(project_name)[1] logging.debug(project_name) page_re = re.compile(r'<a href="/pypi/%s/([a-zA-Z0-9\.\-\_]{1,})">' % project_name) match = page_re.search(page).group() if match: url = match.replace('<a href="', 'http://pypi.python.org') url = url.replace('">', '') page = urlopen(url).read() else: raise NoPyPiVersionFound('self.pypi_url') # We have a working page so grab the package info match = downloads_re.search(page) if match: self.pypi_downloads = match.replace('<td style="text-align: right;">', '') self.pypi_downloads = self.pypi_downloads.replace('</td>', '') self.pypi_downloads = int(self.pypi_downloads) else: self.pypi_downloads = 0 # get the version off of Pypi doap match = doap_re.search(page).group() if match: url = 'http://pypi.python.org%s' % match doap = urlopen(url).read() match = version_re.search(doap).group() self.pypi_version = match.replace('<revision>','').replace('</revision>','') # Get the repo watchers number # TODO - make this abstracted so we can plug in other repos if self.repo.is_supported and 'Github' in self.repo.title and self.repo_url: github = Github() repo_name = self.repo_name() repo = github.repos.show(repo_name) self.repo_watchers = repo.watchers self.repo_forks = repo.forks self.repo_description = repo.description # TODO find out why repo commits limit on github to the first 35 #self.repo_commits = len(github.commits.list(repo_name, "master"))
| 473,605
|
def __init__(self): """ Setup the serial system. """ super(GameButtons, self).__init__()
|
def __init__(self): """ Setup the serial system. """ super(GameButtons, self).__init__()
| 473,606
|
def __init__(self): super(GUI, self).__init__()
|
def __init__(self): super(GUI, self).__init__()
| 473,607
|
def on_allocation_changed(self, stage, box, flags): """ """ logging.debug("self size %d x %d and stage size %d x %d" % (self.get_width(), self.get_height(), stage.get_width(), stage.get_height())) self.clue_overlay.set_size(self.get_width(), self.get_height()) self.daily_double_overlay(self.get_width(), self.get_height()) self.game_board.set_size(self.get_width() * 0.9, self.get_height()) self.board_box.set_size(self.get_width(), self.get_height()) self.category_overlay.set_size(self.get_width(), self.get_height()) self.player_buzz_overlay.set_size(self.get_width(), self.get_height())
|
def on_allocation_changed(self, stage, box, flags): """ """ logging.debug("self size %d x %d and stage size %d x %d" % (self.get_width(), self.get_height(), stage.get_width(), stage.get_height())) self.clue_overlay.set_size(self.get_width(), self.get_height()) self.daily_double_overlay.set_size(self.get_width(), self.get_height()) self.game_board.set_size(self.get_width() * 0.9, self.get_height()) self.board_box.set_size(self.get_width(), self.get_height()) self.category_overlay.set_size(self.get_width(), self.get_height()) self.player_buzz_overlay.set_size(self.get_width(), self.get_height())
| 473,608
|
def set_text(self, font, text): """ """ logging.debug('called set text.') self.remove(self.text) self.text = Text(font, text) self.text.set_size(self.get_width(), self.get_height()) scale_x, scale_y = self.get_scale() print scale_x self.text.set_scale(scale_x, scale_y) self.add(self.text)
|
def set_text(self, font, text): """ """ self.remove(self.text) self.text = Text(font, text) self.text.set_size(self.get_width(), self.get_height()) scale_x, scale_y = self.get_scale() print scale_x self.text.set_scale(scale_x, scale_y) self.add(self.text)
| 473,609
|
def on_paint(self, actor): logging.debug("Entered clue square on_paint.") if self.clue.state == 'unanswered': self.set_text(config.clue_value_font, self.clue.get_value()) self.set_color(config.clue_value_color) elif self.clue.state == 'selected': self.set_text(config.clue_font, self.clue.answer) elif self.clue.state == 'question': self.set_text(config.clue_font, self.clue.question) elif self.clue.state == 'answered': self.set_text(config.clue_font, '')
|
def on_paint(self, actor): if self.clue.state == 'unanswered': self.set_text(config.clue_value_font, self.clue.get_value()) self.set_color(config.clue_value_color) elif self.clue.state == 'selected': self.set_text(config.clue_font, self.clue.answer) elif self.clue.state == 'question': self.set_text(config.clue_font, self.clue.question) elif self.clue.state == 'answered': self.set_text(config.clue_font, '')
| 473,610
|
def _find_config_file(self): absolute_path = None for location in CONFIG_LOCATIONS: if os.path.isfile(location): absolute_path = path return absolute_path
|
def _find_config_file(self): absolute_path = None for location in CONFIG_LOCATIONS: if os.path.isfile(location): absolute_path = location return absolute_path
| 473,611
|
def on_click(self, actor, event): """ """ logging.debug("Clue square click! state = %s" % self.clue.state) if self.clue.state == 'unanswered': self.clue.state = 'selected' logging.debug("Clue answer = %s" % self.clue.get_answer()) self.set_text('')
|
def on_click(self, actor, event): """ """ logging.debug("Clue square click! state = %s" % self.clue.state) if self.clue.state == 'unanswered': self.clue.state = 'selected' logging.debug("Clue answer = %s" % self.clue.get_answer()) self.set_text('')
| 473,612
|
def __init__(self): super(IdleBox, self).__init__(clutter.FlowLayout(clutter.FLOW_VERTICAL))
|
def __init__(self): super(IdleBox, self).__init__(clutter.FlowLayout(clutter.FLOW_VERTICAL))
| 473,613
|
def set_size(self, width, height): super(IdleBox, self).set_size(width, height) self.game_board.set_size(width, height) self.game_board.set_scale(0.6, 0.6)
|
def set_size(self, width, height): super(IdleBox, self).set_size(width, height) self.game_board.set_size(width, height) self.game_board.set_scale(0.6, 0.6)
| 473,614
|
def set_text(self, text): """ """ self.remove(self.text) self.text = Text(config.player_overlay_font, text) self.add(self.text)
|
def set_text(self, text): """ """ self.remove(self.text) self.text = Text(config.player_overlay_font, text) self.add(self.text)
| 473,615
|
def __init__(self): super(GUI, self).__init__()
|
def __init__(self): super(GUI, self).__init__()
| 473,616
|
def __init__(self): super(GUI, self).__init__()
|
def __init__(self): super(GUI, self).__init__()
| 473,617
|
def on_allocation_changed(self, stage, box, flags): """ """ logging.debug("self size %d x %d and stage size %d x %d" % (self.get_width(), self.get_height(), stage.get_width(), stage.get_height())) self.clue_overlay.set_size(self.get_width(), self.get_height()) self.daily_double_overlay.set_size(self.get_width(), self.get_height()) self.game_board.set_size(self.get_width() * 0.9, self.get_height()) self.board_box.set_size(self.get_width(), self.get_height()) self.category_overlay.set_size(self.get_width(), self.get_height()) self.player_buzz_overlay.set_size(self.get_width(), self.get_height()) self.daily_double_overlay.set_size(self.get_width(), self.get_height())
|
def on_allocation_changed(self, stage, box, flags): """ """ logging.debug("self size %d x %d and stage size %d x %d" % (self.get_width(), self.get_height(), stage.get_width(), stage.get_height())) self.clue_overlay.set_size(self.get_width(), self.get_height()) self.daily_double_overlay.set_size(self.get_width(), self.get_height()) self.board_box.set_size(self.get_width(), self.get_height()) if config.display_player_scores: self.player_score_box.set_size(0.1 * self.get_width(), self.get_height()) self.game_board.set_size(0.9 * self.get_width(), self.get_height()) else: self.game_board.set_size(self.get_width, self.get_height()) self.board_box.set_size(self.get_width(), self.get_height()) self.category_overlay.set_size(self.get_width(), self.get_height()) self.player_buzz_overlay.set_size(self.get_width(), self.get_height()) self.daily_double_overlay.set_size(self.get_width(), self.get_height())
| 473,618
|
def update(self): """ Update the GUI based on the current state of the game. """ if game.check_update_game_board(): self.remove(self.game_board) self.game_board = GameBoard() self.game_board.set_size(self.get_width(), self.get_height()) self.add(self.game_board) self.game_board.lower_bottom() if game.check_timeout_beep(): logging.debug("****************** BZZZZZT! ******************") tex = cluttergst.VideoTexture() tex.set_filename(config.sound_timeout) tex.set_playing(True) if game.check_flash_player_name(): player_name = game.players[game.buzzed_player].name self.player_buzz_overlay.set_opacity(255) self.player_buzz_overlay.set_text(player_name) self.player_buzz_overlay.animate(clutter.EASE_IN_CUBIC, 1000, 'opacity', 0) if game.check_flash_player_score(): player = game.players[game.buzzed_player] text = '%s\n$%d' % (player.name, player.score) self.player_buzz_overlay.set_opacity(255) self.player_buzz_overlay.set_text(text) self.player_buzz_overlay.animate(clutter.EASE_IN_CUBIC, 1000, 'opacity', 0) if game.check_flash_daily_double(): self.daily_double_overlay.set_opacity(255) tex = cluttergst.VideoTexture() tex.set_filename(config.sound_daily_double) tex.set_playing(True) if game.check_clear_daily_double(): self.daily_double_overlay.animate(clutter.EASE_IN_CUBIC, 1000, 'opacity', 0)
|
def update(self): """ Update the GUI based on the current state of the game. """ if game.check_update_game_board(): self.board_box.remove(self.game_board) self.game_board = GameBoard() self.game_board.set_size(self.get_width(), self.get_height()) self.add(self.game_board) self.game_board.lower_bottom() if game.check_timeout_beep(): logging.debug("****************** BZZZZZT! ******************") tex = cluttergst.VideoTexture() tex.set_filename(config.sound_timeout) tex.set_playing(True) if game.check_flash_player_name(): player_name = game.players[game.buzzed_player].name self.player_buzz_overlay.set_opacity(255) self.player_buzz_overlay.set_text(player_name) self.player_buzz_overlay.animate(clutter.EASE_IN_CUBIC, 1000, 'opacity', 0) if game.check_flash_player_score(): player = game.players[game.buzzed_player] text = '%s\n$%d' % (player.name, player.score) self.player_buzz_overlay.set_opacity(255) self.player_buzz_overlay.set_text(text) self.player_buzz_overlay.animate(clutter.EASE_IN_CUBIC, 1000, 'opacity', 0) if game.check_flash_daily_double(): self.daily_double_overlay.set_opacity(255) tex = cluttergst.VideoTexture() tex.set_filename(config.sound_daily_double) tex.set_playing(True) if game.check_clear_daily_double(): self.daily_double_overlay.animate(clutter.EASE_IN_CUBIC, 1000, 'opacity', 0)
| 473,619
|
def update(self): """ Update the GUI based on the current state of the game. """ if game.check_update_game_board(): self.remove(self.game_board) self.game_board = GameBoard() self.game_board.set_size(self.get_width(), self.get_height()) self.add(self.game_board) self.game_board.lower_bottom() if game.check_timeout_beep(): logging.debug("****************** BZZZZZT! ******************") tex = cluttergst.VideoTexture() tex.set_filename(config.sound_timeout) tex.set_playing(True) if game.check_flash_player_name(): player_name = game.players[game.buzzed_player].name self.player_buzz_overlay.set_opacity(255) self.player_buzz_overlay.set_text(player_name) self.player_buzz_overlay.animate(clutter.EASE_IN_CUBIC, 1000, 'opacity', 0) if game.check_flash_player_score(): player = game.players[game.buzzed_player] text = '%s\n$%d' % (player.name, player.score) self.player_buzz_overlay.set_opacity(255) self.player_buzz_overlay.set_text(text) self.player_buzz_overlay.animate(clutter.EASE_IN_CUBIC, 1000, 'opacity', 0) if game.check_flash_daily_double(): self.daily_double_overlay.set_opacity(255) tex = cluttergst.VideoTexture() tex.set_filename(config.sound_daily_double) tex.set_playing(True) if game.check_clear_daily_double(): self.daily_double_overlay.animate(clutter.EASE_IN_CUBIC, 1000, 'opacity', 0)
|
def update(self): """ Update the GUI based on the current state of the game. """ if game.check_update_game_board(): self.remove(self.game_board) self.game_board = GameBoard() self.board_box.add(self.game_board) if config.display_player_scores: self.game_board.set_size(0.9 * self.get_width(), self.get_height()) else: self.game_board.set_size(self.get_width, self.get_height()) self.game_board.lower_bottom() if game.check_timeout_beep(): logging.debug("****************** BZZZZZT! ******************") tex = cluttergst.VideoTexture() tex.set_filename(config.sound_timeout) tex.set_playing(True) if game.check_flash_player_name(): player_name = game.players[game.buzzed_player].name self.player_buzz_overlay.set_opacity(255) self.player_buzz_overlay.set_text(player_name) self.player_buzz_overlay.animate(clutter.EASE_IN_CUBIC, 1000, 'opacity', 0) if game.check_flash_player_score(): player = game.players[game.buzzed_player] text = '%s\n$%d' % (player.name, player.score) self.player_buzz_overlay.set_opacity(255) self.player_buzz_overlay.set_text(text) self.player_buzz_overlay.animate(clutter.EASE_IN_CUBIC, 1000, 'opacity', 0) if game.check_flash_daily_double(): self.daily_double_overlay.set_opacity(255) tex = cluttergst.VideoTexture() tex.set_filename(config.sound_daily_double) tex.set_playing(True) if game.check_clear_daily_double(): self.daily_double_overlay.animate(clutter.EASE_IN_CUBIC, 1000, 'opacity', 0)
| 473,620
|
def __init__(self, model): super(GameBoard, self).__init__(clutter.BoxLayout())
|
def __init__(self, model): super(GameBoard, self).__init__(clutter.BoxLayout())
| 473,621
|
def set_click_handler(self, click_handler): """ """ for category in self.categories: category.set_click_handler(click_handler)
|
def set_click_handler(self, click_handler): """ """ for category in self.categories: category.set_click_handler(click_handler)
| 473,622
|
def get_player_index(self, player): """ Given a player return that player's index. """ self.players.index(player)
|
def get_player_index(self, player): """ Given a player return that player's index. """ self.players.index(player)
| 473,623
|
def nextInt(self, n = None): """ Return a random int in [0, `n`).
|
def nextInt(self, n = None): """ Return a random int in [0, `n`).
| 473,624
|
def nextInt(self, n = None): """ Return a random int in [0, `n`).
|
def nextInt(self, n = None): """ Return a random int in [0, `n`).
| 473,625
|
def nextBoolean(self): """ Return a random bool. """
|
def nextBoolean(self): """ Return a random bool. """
| 473,626
|
def nextFloat(self): """ Return a random float in (0, 1).
|
def nextFloat(self): """ Return a random float in (0, 1).
| 473,627
|
def nextDouble(self): """ Return a random float in (0, 1). """
|
def nextDouble(self): """ Return a random float in (0, 1). """
| 473,628
|
def nextLong(self): """ Return a random long.
|
def nextLong(self): """ Return a random long.
| 473,629
|
def _getPartyStatus(self, now, nextEvents): firstEvent = self.context.getFirstEvent(self.request) lastEvent = self.context.getLastEvent(self.request)
|
def _getPartyStatus(self, now, nextEvents): firstEvent = self.context.getFirstEvent(self.request) lastEvent = self.context.getLastEvent(self.request)
| 473,630
|
def _initialize(config): cls = NoneLocation_cls cls.priority = config.defaultLocationPriority clshideUntil = datetime.timedelta(seconds=config.defaultHideTime)
|
def _initialize(config): cls = NoneLocation_cls cls.priority = config.defaultLocationPriority clshideUntil = datetime.timedelta(seconds=config.defaultHideTime)
| 473,631
|
def reinit (self) : """Restart scheduler from 0 """ self._scheduler._tasks = list(self._initial_state) #TODO hack pabo self._current_step = 0 self._gen = scheduler.run() if self._init_func is not None : self._init_func()
|
def reinit (self) : """Restart scheduler from 0 """ self._scheduler._tasks = list(self._initial_state) #TODO hack pabo self._current_step = 0 self._gen = self._scheduler.run() if self._init_func is not None : self._init_func()
| 473,632
|
def __call__(self, inputs): """ inputs is the list of input values """ import copy return (copy.copy(inputs[0]), )
|
def __call__(self, inputs): """ inputs is the list of input values """ import copy return (copy.copy(inputs[0]), )
| 473,633
|
def bounding_box (mask) : """Compute the bounding box of a mask :Parameters: - `mask` (array of bool) - a nd array of booleans :Returns: a slice (ind_min,ind_max) for each dimension of the mask or None if the mask do not contain any True value. Where ind_min correspond to the first slice that contains a True value and ind_max correspond to the first slice that contains only False after slices that contain at least one True value :Returns Type: list of (int,int) """ loc_mask = mask bb = [slice(0,m) for m in mask.shape] for ind in range(len(mask.shape) ) : #find bounding box along ind axis imax = mask.shape[ind] #find imin bb[ind] = 0 while (not loc_mask[bb].any() ) and (bb[ind] < imax) : bb[ind] += 1 if bb[ind] == imax : return None bbimin = bb[ind] #find imax bb[ind] += 1 while mask[bb].any() and (bb[ind] < imax) : bb[ind] += 1 bbimax = bb[ind] #restore slice bb[ind] = slice(bbimin,bbimax) return bb
|
def bounding_box (mask) : """Compute the bounding box of a mask :Parameters: - `mask` (array of bool) - a nd array of booleans :Returns: a slice (ind_min,ind_max) for each dimension of the mask or None if the mask do not contain any True value. Where ind_min correspond to the first slice that contains a True value and ind_max correspond to the first slice that contains only False after slices that contain at least one True value :Returns Type: list of (int,int) """ loc_mask = mask bb = [slice(0,m) for m in mask.shape] for ind in range(len(mask.shape) ) : #find bounding box along ind axis imax = mask.shape[ind] #find imin bb[ind] = 0 while (bb[ind] < imax) and (not loc_mask[bb].any() ) : bb[ind] += 1 if bb[ind] == imax : return None bbimin = bb[ind] #find imax bb[ind] += 1 while mask[bb].any() and (bb[ind] < imax) : bb[ind] += 1 bbimax = bb[ind] #restore slice bb[ind] = slice(bbimin,bbimax) return bb
| 473,634
|
def bounding_box (mask) : """Compute the bounding box of a mask :Parameters: - `mask` (array of bool) - a nd array of booleans :Returns: a slice (ind_min,ind_max) for each dimension of the mask or None if the mask do not contain any True value. Where ind_min correspond to the first slice that contains a True value and ind_max correspond to the first slice that contains only False after slices that contain at least one True value :Returns Type: list of (int,int) """ loc_mask = mask bb = [slice(0,m) for m in mask.shape] for ind in range(len(mask.shape) ) : #find bounding box along ind axis imax = mask.shape[ind] #find imin bb[ind] = 0 while (not loc_mask[bb].any() ) and (bb[ind] < imax) : bb[ind] += 1 if bb[ind] == imax : return None bbimin = bb[ind] #find imax bb[ind] += 1 while mask[bb].any() and (bb[ind] < imax) : bb[ind] += 1 bbimax = bb[ind] #restore slice bb[ind] = slice(bbimin,bbimax) return bb
|
def bounding_box (mask) : """Compute the bounding box of a mask :Parameters: - `mask` (array of bool) - a nd array of booleans :Returns: a slice (ind_min,ind_max) for each dimension of the mask or None if the mask do not contain any True value. Where ind_min correspond to the first slice that contains a True value and ind_max correspond to the first slice that contains only False after slices that contain at least one True value :Returns Type: list of (int,int) """ loc_mask = mask bb = [slice(0,m) for m in mask.shape] for ind in range(len(mask.shape) ) : #find bounding box along ind axis imax = mask.shape[ind] #find imin bb[ind] = 0 while (not loc_mask[bb].any() ) and (bb[ind] < imax) : bb[ind] += 1 if bb[ind] == imax : return None bbimin = bb[ind] #find imax bb[ind] += 1 while (bb[ind] < imax) and mask[bb].any() : bb[ind] += 1 bbimax = bb[ind] #restore slice bb[ind] = slice(bbimin,bbimax) return bb
| 473,635
|
def flatten (img_list) : """Concatenate all images into a single image Use alpha to blend images one on top of each other .. warning:: all images must have the same shape either 2D or 3D and an alpha channel .. warning:: the resulting image has no alpha channel :Parameters: - `img_list` (list of NxM(xP)x4 array of uint8) :Returns Type: NxM(xP)x3 array of uint8 """ R = img_list[0][...,0] G = img_list[0][...,1] B = img_list[0][...,2] for lay in img_list[1:] : alpha = lay[...,3] / 255. ialpha = 1. - alpha R = R * ialpha + lay[...,0] * alpha G = G * ialpha + lay[...,1] * alpha B = B * ialpha + lay[...,2] * alpha return rollaxis(array([R,G,B],img_list[0].dtype),0,len(img_list[0].shape) )
|
def flatten (img_list, alpha = False) : """Concatenate all images into a single image Use alpha to blend images one on top of each other .. warning:: all images must have the same shape either 2D or 3D and an alpha channel .. warning:: the resulting image has no alpha channel :Parameters: - `img_list` (list of NxM(xP)x4 array of uint8) :Returns Type: NxM(xP)x3 array of uint8 """ R = img_list[0][...,0] G = img_list[0][...,1] B = img_list[0][...,2] for lay in img_list[1:] : alpha = lay[...,3] / 255. ialpha = 1. - alpha R = R * ialpha + lay[...,0] * alpha G = G * ialpha + lay[...,1] * alpha B = B * ialpha + lay[...,2] * alpha return rollaxis(array([R,G,B],img_list[0].dtype),0,len(img_list[0].shape) )
| 473,636
|
def flatten (img_list) : """Concatenate all images into a single image Use alpha to blend images one on top of each other .. warning:: all images must have the same shape either 2D or 3D and an alpha channel .. warning:: the resulting image has no alpha channel :Parameters: - `img_list` (list of NxM(xP)x4 array of uint8) :Returns Type: NxM(xP)x3 array of uint8 """ R = img_list[0][...,0] G = img_list[0][...,1] B = img_list[0][...,2] for lay in img_list[1:] : alpha = lay[...,3] / 255. ialpha = 1. - alpha R = R * ialpha + lay[...,0] * alpha G = G * ialpha + lay[...,1] * alpha B = B * ialpha + lay[...,2] * alpha return rollaxis(array([R,G,B],img_list[0].dtype),0,len(img_list[0].shape) )
|
def flatten (img_list) : """Concatenate all images into a single image Use alpha to blend images one on top of each other .. warning:: all images must have the same nD shape and an alpha channel (except maybe for the first one) If alpha is True, the resulting image will use the max of all alpha channels as an alpha channel. .. warning:: if the first image is a SpatialImage, the resulting image will also be a SpatialImage but no test is made to ensure consistency in the resolution of the layers :Parameters: - `img_list` (list of NxM(xP)x4 array of uint8) :Returns Type: NxM(xP)x3 array of uint8 """ R = img_list[0][...,0] G = img_list[0][...,1] B = img_list[0][...,2] for lay in img_list[1:] : alpha = lay[...,3] / 255. ialpha = 1. - alpha R = R * ialpha + lay[...,0] * alpha G = G * ialpha + lay[...,1] * alpha B = B * ialpha + lay[...,2] * alpha return rollaxis(array([R,G,B],img_list[0].dtype),0,len(img_list[0].shape) )
| 473,637
|
def flatten (img_list) : """Concatenate all images into a single image Use alpha to blend images one on top of each other .. warning:: all images must have the same shape either 2D or 3D and an alpha channel .. warning:: the resulting image has no alpha channel :Parameters: - `img_list` (list of NxM(xP)x4 array of uint8) :Returns Type: NxM(xP)x3 array of uint8 """ R = img_list[0][...,0] G = img_list[0][...,1] B = img_list[0][...,2] for lay in img_list[1:] : alpha = lay[...,3] / 255. ialpha = 1. - alpha R = R * ialpha + lay[...,0] * alpha G = G * ialpha + lay[...,1] * alpha B = B * ialpha + lay[...,2] * alpha return rollaxis(array([R,G,B],img_list[0].dtype),0,len(img_list[0].shape) )
|
def flatten (img_list) : """Concatenate all images into a single image Use alpha to blend images one on top of each other .. warning:: all images must have the same shape either 2D or 3D and an alpha channel .. warning:: the resulting image has no alpha channel :Parameters: - `img_list` (list of NxM(xP)x4 array of uint8) - `alpha` (bool) - the resulting image will have an alpha channel or not :Returns Type: NxM(xP)x3(4) array of uint8 """ bg = img_list[0] R = bg[...,0] G = bg[...,1] B = bg[...,2] if bg.shape[-1] == 4 : alpha_list = [bg[...,3] ] else : alpha_list = [] for lay in img_list[1:] : alpha = lay[...,3] / 255. ialpha = 1. - alpha R = R * ialpha + lay[...,0] * alpha G = G * ialpha + lay[...,1] * alpha B = B * ialpha + lay[...,2] * alpha return rollaxis(array([R,G,B],img_list[0].dtype),0,len(img_list[0].shape) )
| 473,638
|
def flatten (img_list) : """Concatenate all images into a single image Use alpha to blend images one on top of each other .. warning:: all images must have the same shape either 2D or 3D and an alpha channel .. warning:: the resulting image has no alpha channel :Parameters: - `img_list` (list of NxM(xP)x4 array of uint8) :Returns Type: NxM(xP)x3 array of uint8 """ R = img_list[0][...,0] G = img_list[0][...,1] B = img_list[0][...,2] for lay in img_list[1:] : alpha = lay[...,3] / 255. ialpha = 1. - alpha R = R * ialpha + lay[...,0] * alpha G = G * ialpha + lay[...,1] * alpha B = B * ialpha + lay[...,2] * alpha return rollaxis(array([R,G,B],img_list[0].dtype),0,len(img_list[0].shape) )
|
def flatten (img_list) : """Concatenate all images into a single image Use alpha to blend images one on top of each other .. warning:: all images must have the same shape either 2D or 3D and an alpha channel .. warning:: the resulting image has no alpha channel :Parameters: - `img_list` (list of NxM(xP)x4 array of uint8) :Returns Type: NxM(xP)x3 array of uint8 """ R = img_list[0][...,0] G = img_list[0][...,1] B = img_list[0][...,2] for lay in img_list[1:] : A = lay[...,3] alpha_list.append(A) A = A / 255. iA = 1. - A R = R * iA + lay[...,0] * A G = G * iA + lay[...,1] * A B = B * iA + lay[...,2] * A if alpha : A = array(alpha_list).max(axis = 0) ret = rollaxis(array([R,G,B,A],bg.dtype),0,len(bg.shape) ) else : ret = rollaxis(array([R,G,B],bg.dtype),0,len(bg.shape) ) if isinstance(bg,SpatialImage) : return SpatialImage(ret,bg.resolution,4,bg.info) else : return ret
| 473,639
|
def set_method_name(self, name): instance = self.get_input(0) if instance and name: meth = getattr(instance, name, None) if meth: sig = Signature(meth) inputs = sig.get_all_parameters() prefix = str(instance) if len(prefix)>15: prefix = prefix[:5]+"..."+prefix[-5:] self.set_caption(prefix+" : "+name) self.internal_data["methodName"] = name self.internal_data["methodSig"] = sig self.__doc__ = sig.get_doc() self.build_ports(inputs)
|
def set_method_name(self, name): instance = self.get_input(0) if instance is not None and name is not None: meth = getattr(instance, name, None) if meth: sig = Signature(meth) inputs = sig.get_all_parameters() prefix = str(instance) if len(prefix)>15: prefix = prefix[:5]+"..."+prefix[-5:] self.set_caption(prefix+" : "+name) self.internal_data["methodName"] = name self.internal_data["methodSig"] = sig self.__doc__ = sig.get_doc() self.build_ports(inputs)
| 473,640
|
def set_method_name(self, name): instance = self.get_input(0) if instance and name: meth = getattr(instance, name, None) if meth: sig = Signature(meth) inputs = sig.get_all_parameters() prefix = str(instance) if len(prefix)>15: prefix = prefix[:5]+"..."+prefix[-5:] self.set_caption(prefix+" : "+name) self.internal_data["methodName"] = name self.internal_data["methodSig"] = sig self.__doc__ = sig.get_doc() self.build_ports(inputs)
|
def set_method_name(self, name): instance = self.get_input(0) if instance and name: meth = getattr(instance, name, None) if meth: sig = Signature(meth) inputs = sig.get_all_parameters() prefix = type(instance).__name__ if not hasattr(instance, "__name__") \ else instance.__name__ if len(prefix)>15: prefix = prefix[:5]+"..."+prefix[-5:] self.set_caption(prefix+" : "+name) self.internal_data["methodName"] = name self.internal_data["methodSig"] = sig self.__doc__ = sig.get_doc() self.build_ports(inputs)
| 473,641
|
def transform (self, transfo) : """Combine a transformation with the actual transformation of this element. :Parameters: - `transfo` (:class:`SVGTransform`) """ self._transform = self._transform * transfo
|
def transform (self, transfo) : """Combine a transformation with the actual transformation of this element. :Parameters: - `transfo` (:class:`SVGTransform`) """ self._transform = transfo * self._transform
| 473,642
|
def translate (self, dx, dy) : """Combine a translation with the actual transformation of this element. :Parameters: - `dx` (float) - x displacement - `dy` (float) - y displacement """ self._transform = self._transform * translation(dx,dy)
|
def translate (self, dx, dy) : """Combine a translation with the actual transformation of this element. :Parameters: - `dx` (float) - x displacement - `dy` (float) - y displacement """ self._transform = translation(dx,dy) * self._transform
| 473,643
|
def rotate (self, angle) : """Combine a rotation with the actual transformation of this element. :Parameters: - `angle` (float) - angle of the rotation around Oz in direct orientation. """ self._transform = self._transform * rotation(angle)
|
def rotate (self, angle) : """Combine a rotation with the actual transformation of this element. :Parameters: - `angle` (float) - angle of the rotation around Oz in direct orientation. """ self._transform = rotation(angle) * self._transform
| 473,644
|
def scale (self, sx, sy) : """Combine a scaling with the actual transformation of this element. :Parameters: - `sx` (float) - x scaling - `sy` (float) - y scaling """ self._transform = self._transform * scaling(sx,sy)
|
def scale (self, sx, sy) : """Combine a scaling with the actual transformation of this element. :Parameters: - `sx` (float) - x scaling - `sy` (float) - y scaling """ self._transform = scaling(sx,sy) * self._transform
| 473,645
|
def _validate_md5(egg_name, data): if egg_name in md5_data: digest = md5(data).hexdigest() if digest != md5_data[egg_name]: print >>sys.stderr, ( "md5 validation of %s failed! (Possible download problem?)" % egg_name ) sys.exit(2) return data
|
def _validate_md5(egg_name, data): if egg_name in md5_data: digest = md5(data).hexdigest() if digest != md5_data[egg_name]: print >>sys.stderr, ( "md5 validation of %s failed! (Possible download problem?)" % egg_name ) sys.exit(2) return data
| 473,646
|
def __init__(self): """init docstring""" from pylab import plot Node.__init__(self) YLabel.__init__(self) XLabel.__init__(self) Title.__init__(self) #self.__doc__+=plot.__doc__
|
def __init__(self): """init docstring""" from pylab import plot Node.__init__(self) YLabel.__init__(self) XLabel.__init__(self) Title.__init__(self) #self.__doc__+=plot.__doc__
| 473,647
|
def __call__(self, inputs): from pylab import figure, plot, show, clf, xlabel, ylabel, hold, title, grid, Line2D, legend, axes xinputs = self.get_input("x") yinputs = self.get_input("y") clf() #figure(**self.get_input('figure')) kwds = {} kwds['markersize']=self.get_input("markersize") kwds['marker']=markers[self.get_input("marker")] kwds['linestyle']=linestyles[self.get_input("linestyle")] kwds['color']=colors[self.get_input("color")] kwds['label']=self.get_input("label") print self.get_input("axes") #kwds['figure'] = figure(**self.get_input("figure")) figure(**self.get_input("figure")) #kwds['axes'] = axes(**self.get_input("axes")) axes(**self.get_input("axes")) print kwds #kwds['axes']=self.get_input("axes") #print self.get_input("axes")
|
def __call__(self, inputs): from pylab import figure, plot, show, clf, xlabel, ylabel, hold, title, grid, Line2D, legend, axes xinputs = self.get_input("x") yinputs = self.get_input("y") clf() #figure(**self.get_input('figure')) kwds = {} kwds['markersize']=self.get_input("markersize") kwds['marker']=markers[self.get_input("marker")] kwds['linestyle']=linestyles[self.get_input("linestyle")] kwds['color']=colors[self.get_input("color")] kwds['label']=self.get_input("label") print self.get_input("axes") #kwds['figure'] = figure(**self.get_input("figure")) figure(**self.get_input("figure")) #kwds['axes'] = axes(**self.get_input("axes")) axes(**self.get_input("axes")) print kwds #kwds['axes']=self.get_input("axes") #print self.get_input("axes")
| 473,648
|
def __call__(self, inputs): from pylab import figure, plot, show, clf, xlabel, ylabel, hold, title, grid, Line2D, legend, axes xinputs = self.get_input("x") yinputs = self.get_input("y") clf() #figure(**self.get_input('figure')) kwds = {} kwds['markersize']=self.get_input("markersize") kwds['marker']=markers[self.get_input("marker")] kwds['linestyle']=linestyles[self.get_input("linestyle")] kwds['color']=colors[self.get_input("color")] kwds['label']=self.get_input("label") print self.get_input("axes") #kwds['figure'] = figure(**self.get_input("figure")) figure(**self.get_input("figure")) #kwds['axes'] = axes(**self.get_input("axes")) axes(**self.get_input("axes")) print kwds #kwds['axes']=self.get_input("axes") #print self.get_input("axes")
|
def __call__(self, inputs): from pylab import figure, plot, show, clf, xlabel, ylabel, hold, title, grid, Line2D, legend, axes xinputs = self.get_input("x") yinputs = self.get_input("y") clf() #figure(**self.get_input('figure')) kwds = {} kwds['markersize']=self.get_input("markersize") kwds['marker']=markers[self.get_input("marker")] kwds['linestyle']=linestyles[self.get_input("linestyle")] kwds['color']=colors[self.get_input("color")] kwds['label']=self.get_input("label") print self.get_input("axes") #kwds['figure'] = figure(**self.get_input("figure")) figure(**self.get_input("figure")) #kwds['axes'] = axes(**self.get_input("axes")) axes(**self.get_input("axes")) print kwds #kwds['axes']=self.get_input("axes") #print self.get_input("axes")
| 473,649
|
def __call__(self, inputs): from pylab import figure, plot, show, clf, xlabel, ylabel, hold, title, grid, Line2D, legend, axes xinputs = self.get_input("x") yinputs = self.get_input("y") clf() #figure(**self.get_input('figure')) kwds = {} kwds['markersize']=self.get_input("markersize") kwds['marker']=markers[self.get_input("marker")] kwds['linestyle']=linestyles[self.get_input("linestyle")] kwds['color']=colors[self.get_input("color")] kwds['label']=self.get_input("label") print self.get_input("axes") #kwds['figure'] = figure(**self.get_input("figure")) figure(**self.get_input("figure")) #kwds['axes'] = axes(**self.get_input("axes")) axes(**self.get_input("axes")) print kwds #kwds['axes']=self.get_input("axes") #print self.get_input("axes")
|
def __call__(self, inputs): from pylab import figure, plot, show, clf, xlabel, ylabel, hold, title, grid, Line2D, legend, axes xinputs = self.get_input("x") yinputs = self.get_input("y") clf() #figure(**self.get_input('figure')) kwds = {} kwds['markersize']=self.get_input("markersize") kwds['marker']=markers[self.get_input("marker")] kwds['linestyle']=linestyles[self.get_input("linestyle")] kwds['color']=colors[self.get_input("color")] kwds['label']=self.get_input("label") print self.get_input("axes") #kwds['figure'] = figure(**self.get_input("figure")) figure(**self.get_input("figure")) #kwds['axes'] = axes(**self.get_input("axes")) axes(**self.get_input("axes")) print kwds #kwds['axes']=self.get_input("axes") #print self.get_input("axes")
| 473,650
|
def __call__(self, inputs): from pylab import figure, plot, show, clf, xlabel, ylabel, hold, title, grid, Line2D, legend, axes xinputs = self.get_input("x") yinputs = self.get_input("y") clf() #figure(**self.get_input('figure')) kwds = {} kwds['markersize']=self.get_input("markersize") kwds['marker']=markers[self.get_input("marker")] kwds['linestyle']=linestyles[self.get_input("linestyle")] kwds['color']=colors[self.get_input("color")] kwds['label']=self.get_input("label") print self.get_input("axes") #kwds['figure'] = figure(**self.get_input("figure")) figure(**self.get_input("figure")) #kwds['axes'] = axes(**self.get_input("axes")) axes(**self.get_input("axes")) print kwds #kwds['axes']=self.get_input("axes") #print self.get_input("axes")
|
def __call__(self, inputs): from pylab import figure, plot, show, clf, xlabel, ylabel, hold, title, grid, Line2D, legend, axes xinputs = self.get_input("x") yinputs = self.get_input("y") clf() #figure(**self.get_input('figure')) kwds = {} kwds['markersize']=self.get_input("markersize") kwds['marker']=markers[self.get_input("marker")] kwds['linestyle']=linestyles[self.get_input("linestyle")] kwds['color']=colors[self.get_input("color")] kwds['label']=self.get_input("label") print self.get_input("axes") #kwds['figure'] = figure(**self.get_input("figure")) figure(**self.get_input("figure")) #kwds['axes'] = axes(**self.get_input("axes")) axes(**self.get_input("axes")) print kwds #kwds['axes']=self.get_input("axes") #print self.get_input("axes")
| 473,651
|
def __init__(self): Node.__init__(self) self.add_input(name="legend on", interface=IBool, value=False) self.add_input(name="legend", interface=IStr, value=None)
|
def __init__(self): Node.__init__(self) self.add_input(name="legend on", interface=IBool, value=False) self.add_input(name="legend", interface=IStr, value=None)
| 473,652
|
def __call__(self, inputs): from pylab import legend if self.get_input('legend') is None: legend(loc='best') else: legend(self.get_input('legend'), loc='best')
|
def __call__(self, inputs): from pylab import legend if self.get_input('legend') is None: legend(loc='best') else: legend(self.get_input('legend'), loc='best')
| 473,653
|
def __init__(self): #from pylab import figure #self.__doc__+=figure.__doc__ Node.__init__(self) self.add_input(name="num", interface=IInt, value=1) self.add_input(name="figsize", interface=ITuple3, value=(8, 6)) self.add_input(name="dpi", interface=IFloat, value=80.) self.add_input(name="facecolor", interface=IEnumStr(colors.keys()), value='white') self.add_input(name="edgecolor", interface=IEnumStr(colors.keys()), value='black')
|
def __init__(self): #from pylab import figure #self.__doc__+=figure.__doc__ Node.__init__(self) self.add_input(name="num", interface=IInt, value=1) self.add_input(name="figsize", interface=ITuple3, value=(8, 6)) self.add_input(name="dpi", interface=IFloat, value=80.) self.add_input(name="facecolor", interface=IEnumStr(colors.keys()), value='white') self.add_input(name="edgecolor", interface=IEnumStr(colors.keys()), value='black')
| 473,654
|
def __init__(self): #from pylab import figure #self.__doc__+=figure.__doc__ Node.__init__(self) self.add_input(name="num", interface=IInt, value=1) self.add_input(name="figsize", interface=ITuple3, value=(8, 6)) self.add_input(name="dpi", interface=IFloat, value=80.) self.add_input(name="facecolor", interface=IEnumStr(colors.keys()), value='white') self.add_input(name="edgecolor", interface=IEnumStr(colors.keys()), value='black')
|
def __init__(self): #from pylab import figure #self.__doc__+=figure.__doc__ Node.__init__(self) self.add_input(name="num", interface=IInt, value=1) self.add_input(name="figsize", interface=ITuple3, value=(8, 6)) self.add_input(name="dpi", interface=IFloat, value=80.) self.add_input(name="facecolor", interface=IEnumStr(colors.keys()), value='white') self.add_input(name="edgecolor", interface=IEnumStr(colors.keys()), value='black')
| 473,655
|
def __call__(self, inputs): from pylab import figure kwds={} kwds['num']=self.get_input('num') kwds['figsize']=self.get_input('figsize') kwds['facecolor']=self.get_input('facecolor') kwds['edgecolor']=self.get_input('edgecolor') kwds['dpi']=self.get_input('dpi')
|
def __call__(self, inputs): from pylab import figure kwds={} kwds['num']=self.get_input('num') kwds['figsize']=self.get_input('figsize') kwds['facecolor']=self.get_input('facecolor') kwds['edgecolor']=self.get_input('edgecolor') kwds['dpi']=self.get_input('dpi')
| 473,656
|
def welcome_setup(): revision = __revision__.strip().split() if len(revision) > 2: revision = revision[2] else: revision = '0.8' print "Running ez_alea_setup version %s" % revision print """
|
def welcome_setup(): try: revision = __revision__.strip().split() if len(revision) > 2: revision = revision[2] else: revision = '0.8' print "Running ez_alea_setup version %s" % revision except: pass print """
| 473,657
|
def welcome_setup(): print "Running ez_alea_setup version %s" % __revision__.split()[2] print """
|
def welcome_setup(): revision = __revision__.strip().split() if len(revision) > 2: revision = revision[2] else: revision = '0.8' print "Running ez_alea_setup version %s" % revision print """
| 473,658
|
def check_policy(flicense, llicense, library, static, issue): # is the lib dynamic or static? ltype = 'Dynamic' if static: ltype = 'Static' # it's possible that the license assigned to the target or library is one of # the aliases, in which case we need the 'official' name for the policy check pllicense = llicense # we want to display both names in the report, if present pflicense = flicense llicenseset = Aliases.objects.filter(alias = llicense) if llicenseset: # can only be one match pllicense = llicenseset[0].license if llicense != pllicense: # plug in the alias (real name) llicense = llicense + ' (' + pllicense + ')' flicenseset = Aliases.objects.filter(alias = flicense) if flicenseset: # can only be one match pflicense = flicenseset[0].license if flicense != pflicense: flicense = flicense + ' (' + pflicense + ')' policyset = Policy.objects.filter(tlicense = pflicense, dlicense = pllicense) policyset = policyset.filter(Q(relationship = ltype) | Q(relationship = 'Both')) # if we got multiple matches, just return - bad policies if policyset and policyset.count() < 2: status = policyset[0].status # only set the issue flag for the target coloring for the disallowed case if status == 'D': issue = issue or True llicense = flag_policy_issue(llicense, status) # highlight if there is no policy defined if not policyset and flicense != 'TBD': llicense = flag_policy_issue(llicense, 'U') # modify the target when there's been a problem somewhere in the whole license set if issue: flicense = flag_policy_issue(flicense, 'D') return issue, llicense, flicense
|
def check_policy(flicense, llicense, library, static, issue): # is the lib dynamic or static? ltype = 'Dynamic' if static: ltype = 'Static' # it's possible that the license assigned to the target or library is one of # the aliases, in which case we need the 'official' name for the policy check pllicense = llicense # we want to display both names in the report, if present pflicense = flicense llicenseset = Aliases.objects.filter(alias = llicense) if llicenseset: # can only be one match pllicense = llicenseset[0].license if llicense != pllicense: # plug in the alias (real name) llicense = llicense + ' (' + pllicense + ')' flicenseset = Aliases.objects.filter(alias = flicense) if flicenseset: # can only be one match pflicense = flicenseset[0].license if flicense != pflicense: flicense = flicense + ' (' + pflicense + ')' policyset = Policy.objects.filter(tlicense = pflicense, dlicense = pllicense) policyset = policyset.filter(Q(relationship = ltype) | Q(relationship = 'Both')) # if we got multiple matches, just return - bad policies if policyset and policyset.count() < 2: status = policyset[0].status # only set the issue flag for the target coloring for the disallowed case if status == 'D': issue = issue or True llicense = flag_policy_issue(llicense, status) # highlight if there is no policy defined if not policyset and flicense != 'TBD': llicense = flag_policy_issue(llicense, 'U') # modify the target when there's been a problem somewhere in the whole license set if issue: flicense = flag_policy_issue(flicense, 'D') return issue, llicense, flicense
| 473,659
|
def flag_policy_issue(value, status): # to highlight the issues tag_start = '<span class="' tag_mid = '">' tag_end = '</span>' tcolor = "yellow" if status == 'A': tcolor = "green" if status == 'D': tcolor = "red" tag_end += '<img src="/site_media/images/red_flag.png" width="16" height="16" alt="red_flag.png">' value = tag_start + tcolor + tag_mid + value + tag_end return value
|
def flag_policy_issue(value, status): # to highlight the issues tag_start = '<span class="' tag_mid = '">' tag_end = '</span>' tcolor = '' if status == 'U': tcolor = 'orange' tag_end += '<img src="/site_media/images/orange_flag.png" width="16" height="16" alt="orange_flag.png">' if status == 'D': tcolor = "red" tag_end += '<img src="/site_media/images/red_flag.png" width="16" height="16" alt="red_flag.png">' value = tag_start + tcolor + tag_mid + value + tag_end return value
| 473,660
|
def flag_policy_issue(value, status): # to highlight the issues tag_start = '<span class="' tag_mid = '">' tag_end = '</span>' tcolor = "yellow" if status == 'A': tcolor = "green" if status == 'D': tcolor = "red" tag_end += '<img src="/site_media/images/red_flag.png" width="16" height="16" alt="red_flag.png">' value = tag_start + tcolor + tag_mid + value + tag_end return value
|
def flag_policy_issue(value, status): # to highlight the issues tag_start = '<span class="' tag_mid = '">' tag_end = '</span>' tcolor = "yellow" if status == 'A': tcolor = "green" if status == 'D': tcolor = 'red' tag_end += '<img src="/site_media/images/red_flag.png" width="16" height="16" alt="red_flag.png">' value = tag_start + tcolor + tag_mid + value + tag_end return value
| 473,661
|
def check_policy(flicense, llicense, library, static, issue): # is the lib dynamic or static? ltype = 'Dynamic' if static: ltype = 'Static' # it's possible that the license assigned to the target or library is one of # the aliases, in which case we need the 'official' name for the policy check pllicense = llicense # we want to display both names in the report, if present pflicense = flicense llicenseset = Aliases.objects.filter(alias = llicense) if llicenseset: # can only be one match pllicense = llicenseset[0].license flicenseset = Aliases.objects.filter(alias = flicense) if flicenseset: # can only be one match pflicense = flicenseset[0].license policyset = Policy.objects.filter(tlicense = pflicense, dlicense = pllicense) policyset = policyset.filter(Q(relationship = ltype) | Q(relationship = 'Both')) # if we got multiple matches, just return - bad policies if policyset and policyset.count() < 2: status = policyset[0].status # only set the issue flag for the target coloring for the disallowed case if status == 'D': issue = issue or True if llicense != pllicense: # plug in the alias (real name) llicense = llicense + ' (' + pllicense + ')' llicense = flag_policy_issue(llicense, status) if flicense != pflicense: flicense = flicense + ' (' + pflicense + ')' # modify the target when there's been a problem somewhere in the whole license set if issue: flicense = flag_policy_issue(flicense, 'D') return issue, llicense, flicense
|
def check_policy(flicense, llicense, library, static, issue): # is the lib dynamic or static? ltype = 'Dynamic' if static: ltype = 'Static' # it's possible that the license assigned to the target or library is one of # the aliases, in which case we need the 'official' name for the policy check pllicense = llicense # we want to display both names in the report, if present pflicense = flicense llicenseset = Aliases.objects.filter(alias = llicense) if llicenseset: # can only be one match pllicense = llicenseset[0].license if llicense != pllicense: llicense = llicense + ' (' + pllicense + ')' flicenseset = Aliases.objects.filter(alias = flicense) if flicenseset: # can only be one match pflicense = flicenseset[0].license policyset = Policy.objects.filter(tlicense = pflicense, dlicense = pllicense) policyset = policyset.filter(Q(relationship = ltype) | Q(relationship = 'Both')) # if we got multiple matches, just return - bad policies if policyset and policyset.count() < 2: status = policyset[0].status # only set the issue flag for the target coloring for the disallowed case if status == 'D': issue = issue or True if llicense != pllicense: # plug in the alias (real name) llicense = llicense + ' (' + pllicense + ')' llicense = flag_policy_issue(llicense, status) if flicense != pflicense: flicense = flicense + ' (' + pflicense + ')' # modify the target when there's been a problem somewhere in the whole license set if issue: flicense = flag_policy_issue(flicense, 'D') return issue, llicense, flicense
| 473,662
|
def check_policy(flicense, llicense, library, static, issue): # is the lib dynamic or static? ltype = 'Dynamic' if static: ltype = 'Static' # it's possible that the license assigned to the target or library is one of # the aliases, in which case we need the 'official' name for the policy check pllicense = llicense # we want to display both names in the report, if present pflicense = flicense llicenseset = Aliases.objects.filter(alias = llicense) if llicenseset: # can only be one match pllicense = llicenseset[0].license flicenseset = Aliases.objects.filter(alias = flicense) if flicenseset: # can only be one match pflicense = flicenseset[0].license policyset = Policy.objects.filter(tlicense = pflicense, dlicense = pllicense) policyset = policyset.filter(Q(relationship = ltype) | Q(relationship = 'Both')) # if we got multiple matches, just return - bad policies if policyset and policyset.count() < 2: status = policyset[0].status # only set the issue flag for the target coloring for the disallowed case if status == 'D': issue = issue or True if llicense != pllicense: # plug in the alias (real name) llicense = llicense + ' (' + pllicense + ')' llicense = flag_policy_issue(llicense, status) if flicense != pflicense: flicense = flicense + ' (' + pflicense + ')' # modify the target when there's been a problem somewhere in the whole license set if issue: flicense = flag_policy_issue(flicense, 'D') return issue, llicense, flicense
|
def check_policy(flicense, llicense, library, static, issue): # is the lib dynamic or static? ltype = 'Dynamic' if static: ltype = 'Static' # it's possible that the license assigned to the target or library is one of # the aliases, in which case we need the 'official' name for the policy check pllicense = llicense # we want to display both names in the report, if present pflicense = flicense llicenseset = Aliases.objects.filter(alias = llicense) if llicenseset: # can only be one match pllicense = llicenseset[0].license flicenseset = Aliases.objects.filter(alias = flicense) if flicenseset: # can only be one match pflicense = flicenseset[0].license if flicense != pflicense: flicense = flicense + ' (' + pflicense + ')' policyset = Policy.objects.filter(tlicense = pflicense, dlicense = pllicense) policyset = policyset.filter(Q(relationship = ltype) | Q(relationship = 'Both')) # if we got multiple matches, just return - bad policies if policyset and policyset.count() < 2: status = policyset[0].status # only set the issue flag for the target coloring for the disallowed case if status == 'D': issue = issue or True if llicense != pllicense: # plug in the alias (real name) llicense = llicense + ' (' + pllicense + ')' llicense = flag_policy_issue(llicense, status) if flicense != pflicense: flicense = flicense + ' (' + pflicense + ')' # modify the target when there's been a problem somewhere in the whole license set if issue: flicense = flag_policy_issue(flicense, 'D') return issue, llicense, flicense
| 473,663
|
def check_policy(flicense, llicense, library, static, issue): # is the lib dynamic or static? ltype = 'Dynamic' if static: ltype = 'Static' # it's possible that the license assigned to the target or library is one of # the aliases, in which case we need the 'official' name for the policy check pllicense = llicense # we want to display both names in the report, if present pflicense = flicense llicenseset = Aliases.objects.filter(alias = llicense) if llicenseset: # can only be one match pllicense = llicenseset[0].license flicenseset = Aliases.objects.filter(alias = flicense) if flicenseset: # can only be one match pflicense = flicenseset[0].license policyset = Policy.objects.filter(tlicense = pflicense, dlicense = pllicense) policyset = policyset.filter(Q(relationship = ltype) | Q(relationship = 'Both')) # if we got multiple matches, just return - bad policies if policyset and policyset.count() < 2: status = policyset[0].status # only set the issue flag for the target coloring for the disallowed case if status == 'D': issue = issue or True if llicense != pllicense: # plug in the alias (real name) llicense = llicense + ' (' + pllicense + ')' llicense = flag_policy_issue(llicense, status) if flicense != pflicense: flicense = flicense + ' (' + pflicense + ')' # modify the target when there's been a problem somewhere in the whole license set if issue: flicense = flag_policy_issue(flicense, 'D') return issue, llicense, flicense
|
def check_policy(flicense, llicense, library, static, issue): # is the lib dynamic or static? ltype = 'Dynamic' if static: ltype = 'Static' # it's possible that the license assigned to the target or library is one of # the aliases, in which case we need the 'official' name for the policy check pllicense = llicense # we want to display both names in the report, if present pflicense = flicense llicenseset = Aliases.objects.filter(alias = llicense) if llicenseset: # can only be one match pllicense = llicenseset[0].license flicenseset = Aliases.objects.filter(alias = flicense) if flicenseset: # can only be one match pflicense = flicenseset[0].license policyset = Policy.objects.filter(tlicense = pflicense, dlicense = pllicense) policyset = policyset.filter(Q(relationship = ltype) | Q(relationship = 'Both')) # if we got multiple matches, just return - bad policies if policyset and policyset.count() < 2: status = policyset[0].status # only set the issue flag for the target coloring for the disallowed case if status == 'D': issue = issue or True if llicense != pllicense: # plug in the alias (real name) llicense = llicense + ' (' + pllicense + ')' llicense = flag_policy_issue(llicense, status) if flicense != pflicense: flicense = flicense + ' (' + pflicense + ')' # modify the target when there's been a problem somewhere in the whole license set if issue: flicense = flag_policy_issue(flicense, 'D') return issue, llicense, flicense
| 473,664
|
def check_policy(flicense, llicense, library, static, issue): # is the lib dynamic or static? ltype = 'Dynamic' if static: ltype = 'Static' # it's possible that the license assigned to the target or library is one of # the aliases, in which case we need the 'official' name for the policy check pllicense = llicense # we want to display both names in the report, if present pflicense = flicense llicenseset = Aliases.objects.filter(alias = llicense) if llicenseset: # can only be one match pllicense = llicenseset[0].license flicenseset = Aliases.objects.filter(alias = flicense) if flicenseset: # can only be one match pflicense = flicenseset[0].license policyset = Policy.objects.filter(tlicense = pflicense, dlicense = pllicense) policyset = policyset.filter(Q(relationship = ltype) | Q(relationship = 'Both')) # if we got multiple matches, just return - bad policies if policyset and policyset.count() < 2: status = policyset[0].status # only set the issue flag for the target coloring for the disallowed case if status == 'D': issue = issue or True if llicense != pllicense: # plug in the alias (real name) llicense = llicense + ' (' + pllicense + ')' llicense = flag_policy_issue(llicense, status) if flicense != pflicense: flicense = flicense + ' (' + pflicense + ')' # modify the target when there's been a problem somewhere in the whole license set if issue: flicense = flag_policy_issue(flicense, 'D') return issue, llicense, flicense
|
def check_policy(flicense, llicense, library, static, issue): # is the lib dynamic or static? ltype = 'Dynamic' if static: ltype = 'Static' # it's possible that the license assigned to the target or library is one of # the aliases, in which case we need the 'official' name for the policy check pllicense = llicense # we want to display both names in the report, if present pflicense = flicense llicenseset = Aliases.objects.filter(alias = llicense) if llicenseset: # can only be one match pllicense = llicenseset[0].license flicenseset = Aliases.objects.filter(alias = flicense) if flicenseset: # can only be one match pflicense = flicenseset[0].license policyset = Policy.objects.filter(tlicense = pflicense, dlicense = pllicense) policyset = policyset.filter(Q(relationship = ltype) | Q(relationship = 'Both')) # if we got multiple matches, just return - bad policies if policyset and policyset.count() < 2: status = policyset[0].status # only set the issue flag for the target coloring for the disallowed case if status == 'D': issue = issue or True if llicense != pllicense: # plug in the alias (real name) llicense = llicense + ' (' + pllicense + ')' llicense = flag_policy_issue(llicense, status) if not policyset and flicense != 'TBD': llicense = flag_policy_issue(llicense, 'U') # modify the target when there's been a problem somewhere in the whole license set if issue: flicense = flag_policy_issue(flicense, 'D') return issue, llicense, flicense
| 473,665
|
def flag_policy_issue(value, status): # to highlight the issues tag_start = '<font color="' tag_mid = '">' tag_end = '</font>' tcolor = "yellow" if status == 'A': tcolor = "green" if status == 'D': tcolor = "red" tag_end += '<img src="/site_media/images/red_flag.png" width="16" height="16" alt="red_flag.png">' value = tag_start + tcolor + tag_mid + value + tag_end return value
|
def flag_policy_issue(value, status): # to highlight the issues tag_start = '<span class="' tag_mid = '">' tag_end = '</font>' tcolor = "yellow" if status == 'A': tcolor = "green" if status == 'D': tcolor = "red" tag_end += '<img src="/site_media/images/red_flag.png" width="16" height="16" alt="red_flag.png">' value = tag_start + tcolor + tag_mid + value + tag_end return value
| 473,666
|
def flag_policy_issue(value, status): # to highlight the issues tag_start = '<font color="' tag_mid = '">' tag_end = '</font>' tcolor = "yellow" if status == 'A': tcolor = "green" if status == 'D': tcolor = "red" tag_end += '<img src="/site_media/images/red_flag.png" width="16" height="16" alt="red_flag.png">' value = tag_start + tcolor + tag_mid + value + tag_end return value
|
def flag_policy_issue(value, status): # to highlight the issues tag_start = '<font color="' tag_mid = '">' tag_end = '</span>' tcolor = "yellow" if status == 'A': tcolor = "green" if status == 'D': tcolor = "red" tag_end += '<img src="/site_media/images/red_flag.png" width="16" height="16" alt="red_flag.png">' value = tag_start + tcolor + tag_mid + value + tag_end return value
| 473,667
|
def dep_loop(parent, soname, dep, level): if level > depth: return if level == 1: print_path_dep(parent, soname, dep, level) print_dep(dep, level) else: print_path_dep(parent, soname, dep, level) print_dep(dep, level) target = dep_path(parent, dep) childdeps = deps_check(target) if len(childdeps) > 0: for childdep in childdeps: dep_loop(target, dep, childdep, level + 1)
|
def dep_loop(parent, soname, dep, level): if level > depth: return if level == 1: print_path_dep(parent, soname, dep, level) print_dep(dep, level) else: print_path_dep(parent, soname, dep, level) print_dep(dep, level) if not re.search('(static)', dep): target = dep_path(parent, dep) childdeps = deps_check(target) else: childdeps = [] if len(childdeps) > 0: for childdep in childdeps: dep_loop(target, dep, childdep, level + 1)
| 473,668
|
def static_deps_check(target): "Look for statically linked dependencies." # State enumeration for debug parser. FIND_NEXT = 1 FIND_NAME = 2 # The algorithm here is pretty basic. We grab a complete symbol list # and debug information. Any symbols that aren't covered by debug # information are considered to be source from static libraries. # Read the functions from the symbol list. symlist = [ x.split() for x in os.popen("readelf -s " + target) ] symlist = [ x for x in symlist if len(x) == 8 ] sym_funcs = set([ x[7] for x in symlist if x[3] == "FUNC" ]) # Read the functions from the debug information. debuginfo = os.popen("readelf -wi " + target) debug_funcs = set() debugstate = FIND_NEXT for line in debuginfo: if len(line) < 2: continue if debugstate == FIND_NAME: if line[1] == "<": debugstate = FIND_NEXT else: match = re.match(r'\s+<.+>\s+(.+?)\s+:\s+\(.+\):\s+(.+)$', line) if match: (field, value) = match.group(1, 2) if field == "DW_AT_name": debug_funcs.add(value.strip()) debugstate = FIND_NEXT if debugstate == FIND_NEXT and line[1] == "<": match = re.search(r'\((.+)\)$', line) if match and match.group(1) == "DW_TAG_subprogram": found_name = None debugstate = FIND_NAME # Get the functions in the symbol list that have no debug info. staticsym_funcs = sym_funcs - debug_funcs # For each function, figure out where it came from. staticlib_list = [] for func in staticsym_funcs: libs = find_static_library(func) for lib in libs: if lib not in staticlib_list: staticlib_list.append(lib) # Format and return the list. staticlib_list.sort() staticlib_results = [ x + " (static)" for x in staticlib_list ] return staticlib_results
|
def static_deps_check(target): "Look for statically linked dependencies." # State enumeration for debug parser. FIND_NEXT = 1 FIND_NAME = 2 # The algorithm here is pretty basic. We grab a complete symbol list # and debug information. Any symbols that aren't covered by debug # information are considered to be source from static libraries. # Read the functions from the symbol list. symlist = [ x.split() for x in os.popen("readelf -s " + target) ] symlist = [ x for x in symlist if len(x) == 8 ] sym_funcs = set([ x[7] for x in symlist if x[3] == "FUNC" ]) # Read the functions from the debug information. debuginfo = os.popen("readelf -wi " + target) debug_funcs = set() debugstate = FIND_NEXT for line in debuginfo: if len(line) < 2: continue if debugstate == FIND_NAME: if line[1] == "<": debugstate = FIND_NEXT else: match = re.match(r'\s+<.+>\s+(.+?)\s+:\s+\(.+\):\s+(.+)$', line) if match: (field, value) = match.group(1, 2) if field == "DW_AT_name": debug_funcs.add(value.strip()) debugstate = FIND_NEXT if debugstate == FIND_NEXT and line[1] == "<": match = re.search(r'\((.+)\)$', line) if match and match.group(1) == "DW_TAG_subprogram": found_name = None debugstate = FIND_NAME # Get the functions in the symbol list that have no debug info. staticsym_funcs = sym_funcs - debug_funcs # For each function, figure out where it came from. staticlib_list = [] for func in staticsym_funcs: libs = find_static_library(func) if len(libs) == 1: if libs[0] not in staticlib_list: staticlib_list.append(libs[0]) elif len(libs) > 1: staticlib_multiples[func] = libs for func in staticlib_multiples: found = False for lib in staticlib_multiples[func]: if lib in staticlib_list: found = True break if not found: staticlib_list.append(staticlib_multiples[func][0]) # Format and return the list. staticlib_list.sort() staticlib_results = [ x + " (static)" for x in staticlib_list ] return staticlib_results
| 473,669
|
def dep_path(target, dep): #print target, dep # readelf gives us the lib, but not the path to check during recursion ldcall = "ldd " + target for lddata in os.popen(ldcall).readlines(): if re.search("statically linked", lddata): return "NONE" elif re.search(dep, lddata): ldlist = string.split(lddata) if len(ldlist) > 2: # path is the 3rd field, usually... dpath = ldlist[2] else: dpath = ldlist[0] # but this may be a symlink dpath = os.path.realpath(dpath) break return dpath
|
defdep_path(target,dep):#printtarget,dep#readelfgivesusthelib,butnotthepathtocheckduringrecursionldcall="ldd"+targetforlddatainos.popen(ldcall).readlines():ifre.search("staticallylinked",lddata):return"NONE"elifre.search(dep,lddata):ldlist=string.split(lddata)iflen(ldlist)>2:#pathisthe3rdfield,usually...dpath=ldlist[2]else:dpath=ldlist[0]#butthismaybeasymlinkdpath=os.path.realpath(dpath)breakreturndpath
| 473,670
|
def deps_check(target): deps = [] # run the "file" command and see if it's ELF filetype = os.popen("file " + target).read() if re.search("ELF", filetype): if not re.search("statically linked", filetype): elfcall = "readelf -d " + target for elfdata in os.popen(elfcall).readlines(): # lines we want all have "NEEDED" if re.search("NEEDED", elfdata): # library is the 5th field dep = string.split(elfdata)[4] dep = dep.replace("[","") dep = dep.replace("]","") deps.append(dep) if do_static: deps.extend(static_deps_check(target)) else: raise NotELFError, "not an ELF file" return deps
|
def deps_check(target): deps = [] # run the "file" command and see if it's ELF filetype = os.popen("file " + target).read() if re.search("ELF", filetype): if not re.search("statically linked", filetype): elfcall = "readelf -d " + target for elfdata in os.popen(elfcall).readlines(): # lines we want all have "NEEDED" if re.search("NEEDED", elfdata): # library is the 5th field dep = string.split(elfdata)[4] dep = dep.strip("[]") deps.append(dep) if do_static: deps.extend(static_deps_check(target)) else: raise NotELFError, "not an ELF file" return deps
| 473,671
|
def deps_check(target): deps = [] # run the "file" command and see if it's ELF filetype = os.popen("file " + target).read() if re.search("ELF", filetype): if not re.search("statically linked", filetype): elfcall = "readelf -d " + target for elfdata in os.popen(elfcall).readlines(): # lines we want all have "NEEDED" if re.search("NEEDED", elfdata): # library is the 5th field dep = string.split(elfdata)[4] dep = dep.replace("[","") dep = dep.replace("]","") deps.append(dep) if do_static: deps.extend(static_deps_check(target)) else: raise NotELFError, "not an ELF file" return deps
|
def deps_check(target): deps = [] # run the "file" command and see if it's ELF filetype = os.popen("file " + target).read() if re.search("ELF", filetype): if not re.search("statically linked", filetype): elfcall = "readelf -d " + target for elfdata in os.popen(elfcall).readlines(): # lines we want all have "NEEDED" if re.search("NEEDED", elfdata): # library is the 5th field dep = string.split(elfdata)[4] dep = dep.replace("[","") dep = dep.replace("]","") deps.append(dep) if do_static: deps.extend(static_deps_check(target)) else: raise NotELFError, "not an ELF file" return deps
| 473,672
|
def deps_print(title, parent, target, level, deps): csvstring = '' spacer = '' nospace = '' if level > 0: nospace += spacer for space in range(0, level): spacer += " " if len(deps) < 1: # FIXME - this blows up the recursion, just drop it? #deps.append("NONE") # at ld-linux - just suppress the output return if do_csv: if depth == 1: csvstring += str(level + 1) + "," + target else: csvstring += str(level + 1) + "," + target + "," + title if level > 0 or depth < 2: for dep in deps: csvstring += "," + dep print csvstring else: if level == 1: print spacer + title print spacer + "[" + str(level + 1) + "]" + target + ":" spacer += " " if level > 0 or depth < 2: for dep in deps: print spacer + dep
|
def print_deps(target, deps): csvstring = '' spacer = '' nospace = '' if level > 0: nospace += spacer for space in range(0, level): spacer += " " if len(deps) < 1: # FIXME - this blows up the recursion, just drop it? #deps.append("NONE") # at ld-linux - just suppress the output return if do_csv: if depth == 1: csvstring += str(level + 1) + "," + target else: csvstring += str(level + 1) + "," + target + "," + title if level > 0 or depth < 2: for dep in deps: csvstring += "," + dep print csvstring else: if level == 1: print spacer + title print spacer + "[" + str(level + 1) + "]" + target + ":" spacer += " " if level > 0 or depth < 2: for dep in deps: print spacer + dep
| 473,673
|
def deps_print(title, parent, target, level, deps): csvstring = '' spacer = '' nospace = '' if level > 0: nospace += spacer for space in range(0, level): spacer += " " if len(deps) < 1: # FIXME - this blows up the recursion, just drop it? #deps.append("NONE") # at ld-linux - just suppress the output return if do_csv: if depth == 1: csvstring += str(level + 1) + "," + target else: csvstring += str(level + 1) + "," + target + "," + title if level > 0 or depth < 2: for dep in deps: csvstring += "," + dep print csvstring else: if level == 1: print spacer + title print spacer + "[" + str(level + 1) + "]" + target + ":" spacer += " " if level > 0 or depth < 2: for dep in deps: print spacer + dep
|
def deps_print(title, parent, target, level, deps): csvstring = '' spacer = '' if len(deps) < 1: return if do_csv: csvstring += str(1) + "," + target for dep in deps: csvstring += "," + dep print csvstring else: print spacer + "[" + str(1) + "]" + target + ":" spacer += " " if len(deps) < 1: # FIXME - this blows up the recursion, just drop it? #deps.append("NONE") # at ld-linux - just suppress the output return if do_csv: if depth == 1: csvstring += str(level + 1) + "," + target else: csvstring += str(level + 1) + "," + target + "," + title if level > 0 or depth < 2: for dep in deps: csvstring += "," + dep print csvstring else: if level == 1: print spacer + title print spacer + "[" + str(level + 1) + "]" + target + ":" spacer += " " if level > 0 or depth < 2: for dep in deps: print spacer + dep
| 473,674
|
def deps_print(title, parent, target, level, deps): csvstring = '' spacer = '' nospace = '' if level > 0: nospace += spacer for space in range(0, level): spacer += " " if len(deps) < 1: # FIXME - this blows up the recursion, just drop it? #deps.append("NONE") # at ld-linux - just suppress the output return if do_csv: if depth == 1: csvstring += str(level + 1) + "," + target else: csvstring += str(level + 1) + "," + target + "," + title if level > 0 or depth < 2: for dep in deps: csvstring += "," + dep print csvstring else: if level == 1: print spacer + title print spacer + "[" + str(level + 1) + "]" + target + ":" spacer += " " if level > 0 or depth < 2: for dep in deps: print spacer + dep
|
def deps_print(title, parent, target, level, deps): csvstring = '' spacer = '' nospace = '' if level > 0: nospace += spacer for space in range(0, level): spacer += " " if len(deps) < 1: # FIXME - this blows up the recursion, just drop it? #deps.append("NONE") # at ld-linux - just suppress the output return if do_csv: if depth == 1: csvstring += str(level + 1) + "," + target else: csvstring += str(level + 1) + "," + target + "," + title if level > 0 or depth < 2: for dep in deps: csvstring += "," + dep print csvstring else: if level == 1: print spacer + title print spacer + "[" + str(level + 1) + "]" + target + ":" spacer += " " if level > 0 or depth < 2: for dep in deps: print spacer + dep
| 473,675
|
def deps_print(title, parent, target, level, deps): csvstring = '' spacer = '' nospace = '' if level > 0: nospace += spacer for space in range(0, level): spacer += " " if len(deps) < 1: # FIXME - this blows up the recursion, just drop it? #deps.append("NONE") # at ld-linux - just suppress the output return if do_csv: if depth == 1: csvstring += str(level + 1) + "," + target else: csvstring += str(level + 1) + "," + target + "," + title if level > 0 or depth < 2: for dep in deps: csvstring += "," + dep print csvstring else: if level == 1: print spacer + title print spacer + "[" + str(level + 1) + "]" + target + ":" spacer += " " if level > 0 or depth < 2: for dep in deps: print spacer + dep
|
def deps_print(title, parent, target, level, deps): csvstring = '' spacer = '' nospace = '' if level > 0: nospace += spacer for space in range(0, level): spacer += " " if len(deps) < 1: # FIXME - this blows up the recursion, just drop it? #deps.append("NONE") # at ld-linux - just suppress the output return if do_csv: if depth == 1: csvstring += str(level + 1) + "," + target else: csvstring += str(level + 1) + "," + target + "," + title if level > 0 or depth < 2: for dep in deps: csvstring += "," + dep print csvstring else: if level == 1: print spacer + title print spacer + "[" + str(level + 1) + "]" + target + ":" spacer += " " if level > 0 or depth < 2: for dep in deps: print spacer + dep
| 473,676
|
def main(): opt_parser = optparse.OptionParser(usage=usage_line, version="%prog version " + version, option_list=command_line_options) (options, args) = opt_parser.parse_args() if len(args) == 0 or len(args) > 2: opt_parser.error("improper number of non-option arguments") # prog_ndx_start is the offset in argv for the file/dir and recursion prog_ndx_start = 1 found = 0 parent = "" global do_csv, depth, do_static do_static = options.do_static do_csv = options.do_csv if options.target: do_search = True target = options.target target_file = args[0] if not os.path.isdir(target): print target + " does not appear to be a directory..." sys.exit(1) else: do_search = False target = args[0] if not(os.path.isdir(target) or os.path.isfile(target)): print target + " does not appear to be a directory or file..." sys.exit(1) # sanity check on recursion level if len(args) == 1: depth = 1 else: try: recursion_arg = args[1] depth = int(recursion_arg) except: bad_depth() if depth < 1: bad_depth() if os.path.isdir(target): # walk the directory tree and find ELF files to process for path, dirs, files in os.walk(target): for filename in files: if (do_search and (filename == target_file)) or not(do_search): candidate = os.path.join(path, filename) if os.path.isfile(candidate): try: deps = deps_check(candidate) except NotELFError: deps = [] if len(deps) > 0: if depth == 1: deps_print(parent, parent, candidate, 0, deps) # do recursion if called for else: dep_loop(candidate, deps) if do_search and (filename == target_file): found = 1 break if do_search and not found: print target_file + " was not found in " + target + " ..." sys.exit(1) else: # single file, just check it and exit # top level deps parent = target try: deps = deps_check(target) except NotELFError: print "not an ELF file..." sys.exit(1) # FIXME: for now, if no deps were found, assume the file # is statically linked. Should rework the recursion so # we don't need this. if not deps: deps.append("STATIC") if depth == 1: deps_print(parent, parent, target, 0, deps) # do recursion if called for else: dep_loop(parent, deps) sys.exit(0)
|
def main(): opt_parser = optparse.OptionParser(usage=usage_line, version="%prog version " + version, option_list=command_line_options) (options, args) = opt_parser.parse_args() if len(args) == 0 or len(args) > 2: opt_parser.error("improper number of non-option arguments") # prog_ndx_start is the offset in argv for the file/dir and recursion prog_ndx_start = 1 found = 0 parent = "" global do_csv, depth, do_static do_static = options.do_static do_csv = options.do_csv if options.target: do_search = True target = options.target target_file = args[0] if not os.path.isdir(target): print target + " does not appear to be a directory..." sys.exit(1) else: do_search = False target = args[0] if not(os.path.isdir(target) or os.path.isfile(target)): print target + " does not appear to be a directory or file..." sys.exit(1) # sanity check on recursion level if len(args) == 1: depth = 1 else: try: recursion_arg = args[1] depth = int(recursion_arg) except: bad_depth() if depth < 1: bad_depth() if os.path.isdir(target): # walk the directory tree and find ELF files to process for path, dirs, files in os.walk(target): for filename in files: if (do_search and (filename == target_file)) or not(do_search): candidate = os.path.join(path, filename) if os.path.isfile(candidate): try: deps = deps_check(candidate) except NotELFError: deps = [] if len(deps) > 0: if depth == 1: print_deps(candidate, deps) # do recursion if called for else: dep_loop(candidate, deps) if do_search and (filename == target_file): found = 1 break if do_search and not found: print target_file + " was not found in " + target + " ..." sys.exit(1) else: # single file, just check it and exit # top level deps parent = target try: deps = deps_check(target) except NotELFError: print "not an ELF file..." sys.exit(1) # FIXME: for now, if no deps were found, assume the file # is statically linked. Should rework the recursion so # we don't need this. if not deps: deps.append("STATIC") if depth == 1: deps_print(parent, parent, target, 0, deps) # do recursion if called for else: dep_loop(parent, deps) sys.exit(0)
| 473,677
|
def main(): opt_parser = optparse.OptionParser(usage=usage_line, version="%prog version " + version, option_list=command_line_options) (options, args) = opt_parser.parse_args() if len(args) == 0 or len(args) > 2: opt_parser.error("improper number of non-option arguments") # prog_ndx_start is the offset in argv for the file/dir and recursion prog_ndx_start = 1 found = 0 parent = "" global do_csv, depth, do_static do_static = options.do_static do_csv = options.do_csv if options.target: do_search = True target = options.target target_file = args[0] if not os.path.isdir(target): print target + " does not appear to be a directory..." sys.exit(1) else: do_search = False target = args[0] if not(os.path.isdir(target) or os.path.isfile(target)): print target + " does not appear to be a directory or file..." sys.exit(1) # sanity check on recursion level if len(args) == 1: depth = 1 else: try: recursion_arg = args[1] depth = int(recursion_arg) except: bad_depth() if depth < 1: bad_depth() if os.path.isdir(target): # walk the directory tree and find ELF files to process for path, dirs, files in os.walk(target): for filename in files: if (do_search and (filename == target_file)) or not(do_search): candidate = os.path.join(path, filename) if os.path.isfile(candidate): try: deps = deps_check(candidate) except NotELFError: deps = [] if len(deps) > 0: if depth == 1: deps_print(parent, parent, candidate, 0, deps) # do recursion if called for else: dep_loop(candidate, deps) if do_search and (filename == target_file): found = 1 break if do_search and not found: print target_file + " was not found in " + target + " ..." sys.exit(1) else: # single file, just check it and exit # top level deps parent = target try: deps = deps_check(target) except NotELFError: print "not an ELF file..." sys.exit(1) # FIXME: for now, if no deps were found, assume the file # is statically linked. Should rework the recursion so # we don't need this. if not deps: deps.append("STATIC") if depth == 1: deps_print(parent, parent, target, 0, deps) # do recursion if called for else: dep_loop(parent, deps) sys.exit(0)
|
def main(): opt_parser = optparse.OptionParser(usage=usage_line, version="%prog version " + version, option_list=command_line_options) (options, args) = opt_parser.parse_args() if len(args) == 0 or len(args) > 2: opt_parser.error("improper number of non-option arguments") # prog_ndx_start is the offset in argv for the file/dir and recursion prog_ndx_start = 1 found = 0 parent = "" global do_csv, depth, do_static do_static = options.do_static do_csv = options.do_csv if options.target: do_search = True target = options.target target_file = args[0] if not os.path.isdir(target): print target + " does not appear to be a directory..." sys.exit(1) else: do_search = False target = args[0] if not(os.path.isdir(target) or os.path.isfile(target)): print target + " does not appear to be a directory or file..." sys.exit(1) # sanity check on recursion level if len(args) == 1: depth = 1 else: try: recursion_arg = args[1] depth = int(recursion_arg) except: bad_depth() if depth < 1: bad_depth() if os.path.isdir(target): # walk the directory tree and find ELF files to process for path, dirs, files in os.walk(target): for filename in files: if (do_search and (filename == target_file)) or not(do_search): candidate = os.path.join(path, filename) if os.path.isfile(candidate): try: deps = deps_check(candidate) except NotELFError: deps = [] if len(deps) > 0: if depth == 1: deps_print(parent, parent, candidate, 0, deps) # do recursion if called for else: for dep in deps: dep_loop(candidate, None, dep, 1) if do_search and (filename == target_file): found = 1 break if do_search and not found: print target_file + " was not found in " + target + " ..." sys.exit(1) else: # single file, just check it and exit # top level deps parent = target try: deps = deps_check(target) except NotELFError: print "not an ELF file..." sys.exit(1) # FIXME: for now, if no deps were found, assume the file # is statically linked. Should rework the recursion so # we don't need this. if not deps: deps.append("STATIC") if depth == 1: deps_print(parent, parent, target, 0, deps) # do recursion if called for else: dep_loop(parent, deps) sys.exit(0)
| 473,678
|
def main(): opt_parser = optparse.OptionParser(usage=usage_line, version="%prog version " + version, option_list=command_line_options) (options, args) = opt_parser.parse_args() if len(args) == 0 or len(args) > 2: opt_parser.error("improper number of non-option arguments") # prog_ndx_start is the offset in argv for the file/dir and recursion prog_ndx_start = 1 found = 0 parent = "" global do_csv, depth, do_static do_static = options.do_static do_csv = options.do_csv if options.target: do_search = True target = options.target target_file = args[0] if not os.path.isdir(target): print target + " does not appear to be a directory..." sys.exit(1) else: do_search = False target = args[0] if not(os.path.isdir(target) or os.path.isfile(target)): print target + " does not appear to be a directory or file..." sys.exit(1) # sanity check on recursion level if len(args) == 1: depth = 1 else: try: recursion_arg = args[1] depth = int(recursion_arg) except: bad_depth() if depth < 1: bad_depth() if os.path.isdir(target): # walk the directory tree and find ELF files to process for path, dirs, files in os.walk(target): for filename in files: if (do_search and (filename == target_file)) or not(do_search): candidate = os.path.join(path, filename) if os.path.isfile(candidate): try: deps = deps_check(candidate) except NotELFError: deps = [] if len(deps) > 0: if depth == 1: deps_print(parent, parent, candidate, 0, deps) # do recursion if called for else: dep_loop(candidate, deps) if do_search and (filename == target_file): found = 1 break if do_search and not found: print target_file + " was not found in " + target + " ..." sys.exit(1) else: # single file, just check it and exit # top level deps parent = target try: deps = deps_check(target) except NotELFError: print "not an ELF file..." sys.exit(1) # FIXME: for now, if no deps were found, assume the file # is statically linked. Should rework the recursion so # we don't need this. if not deps: deps.append("STATIC") if depth == 1: deps_print(parent, parent, target, 0, deps) # do recursion if called for else: dep_loop(parent, deps) sys.exit(0)
|
def main(): opt_parser = optparse.OptionParser(usage=usage_line, version="%prog version " + version, option_list=command_line_options) (options, args) = opt_parser.parse_args() if len(args) == 0 or len(args) > 2: opt_parser.error("improper number of non-option arguments") # prog_ndx_start is the offset in argv for the file/dir and recursion prog_ndx_start = 1 found = 0 parent = "" global do_csv, depth, do_static do_static = options.do_static do_csv = options.do_csv if options.target: do_search = True target = options.target target_file = args[0] if not os.path.isdir(target): print target + " does not appear to be a directory..." sys.exit(1) else: do_search = False target = args[0] if not(os.path.isdir(target) or os.path.isfile(target)): print target + " does not appear to be a directory or file..." sys.exit(1) # sanity check on recursion level if len(args) == 1: depth = 1 else: try: recursion_arg = args[1] depth = int(recursion_arg) except: bad_depth() if depth < 1: bad_depth() if os.path.isdir(target): # walk the directory tree and find ELF files to process for path, dirs, files in os.walk(target): for filename in files: if (do_search and (filename == target_file)) or not(do_search): candidate = os.path.join(path, filename) if os.path.isfile(candidate): try: deps = deps_check(candidate) except NotELFError: deps = [] if len(deps) > 0: if depth == 1: deps_print(parent, parent, candidate, 0, deps) # do recursion if called for else: dep_loop(candidate, deps) if do_search and (filename == target_file): found = 1 break if do_search and not found: print target_file + " was not found in " + target + " ..." sys.exit(1) else: # single file, just check it and exit # top level deps parent = target try: deps = deps_check(target) except NotELFError: print "not an ELF file..." sys.exit(1) # FIXME: for now, if no deps were found, assume the file # is statically linked. Should rework the recursion so # we don't need this. if not deps: deps.append("STATIC") if depth == 1: deps_print(parent, parent, target, 0, deps) # do recursion if called for else: dep_loop(parent, deps) sys.exit(0)
| 473,679
|
def main(): opt_parser = optparse.OptionParser(usage=usage_line, version="%prog version " + version, option_list=command_line_options) (options, args) = opt_parser.parse_args() if len(args) == 0 or len(args) > 2: opt_parser.error("improper number of non-option arguments") # prog_ndx_start is the offset in argv for the file/dir and recursion prog_ndx_start = 1 found = 0 parent = "" global do_csv, depth, do_static do_static = options.do_static do_csv = options.do_csv if options.target: do_search = True target = options.target target_file = args[0] if not os.path.isdir(target): print target + " does not appear to be a directory..." sys.exit(1) else: do_search = False target = args[0] if not(os.path.isdir(target) or os.path.isfile(target)): print target + " does not appear to be a directory or file..." sys.exit(1) # sanity check on recursion level if len(args) == 1: depth = 1 else: try: recursion_arg = args[1] depth = int(recursion_arg) except: bad_depth() if depth < 1: bad_depth() if os.path.isdir(target): # walk the directory tree and find ELF files to process for path, dirs, files in os.walk(target): for filename in files: if (do_search and (filename == target_file)) or not(do_search): candidate = os.path.join(path, filename) if os.path.isfile(candidate): try: deps = deps_check(candidate) except NotELFError: deps = [] if len(deps) > 0: if depth == 1: deps_print(parent, parent, candidate, 0, deps) # do recursion if called for else: dep_loop(candidate, deps) if do_search and (filename == target_file): found = 1 break if do_search and not found: print target_file + " was not found in " + target + " ..." sys.exit(1) else: # single file, just check it and exit # top level deps parent = target try: deps = deps_check(target) except NotELFError: print "not an ELF file..." sys.exit(1) # FIXME: for now, if no deps were found, assume the file # is statically linked. Should rework the recursion so # we don't need this. if not deps: deps.append("STATIC") if depth == 1: deps_print(parent, parent, target, 0, deps) # do recursion if called for else: dep_loop(parent, deps) sys.exit(0)
|
def main(): opt_parser = optparse.OptionParser(usage=usage_line, version="%prog version " + version, option_list=command_line_options) (options, args) = opt_parser.parse_args() if len(args) == 0 or len(args) > 2: opt_parser.error("improper number of non-option arguments") # prog_ndx_start is the offset in argv for the file/dir and recursion prog_ndx_start = 1 found = 0 parent = "" global do_csv, depth, do_static do_static = options.do_static do_csv = options.do_csv if options.target: do_search = True target = options.target target_file = args[0] if not os.path.isdir(target): print target + " does not appear to be a directory..." sys.exit(1) else: do_search = False target = args[0] if not(os.path.isdir(target) or os.path.isfile(target)): print target + " does not appear to be a directory or file..." sys.exit(1) # sanity check on recursion level if len(args) == 1: depth = 1 else: try: recursion_arg = args[1] depth = int(recursion_arg) except: bad_depth() if depth < 1: bad_depth() if os.path.isdir(target): # walk the directory tree and find ELF files to process for path, dirs, files in os.walk(target): for filename in files: if (do_search and (filename == target_file)) or not(do_search): candidate = os.path.join(path, filename) if os.path.isfile(candidate): try: deps = deps_check(candidate) except NotELFError: deps = [] if len(deps) > 0: if depth == 1: deps_print(parent, parent, candidate, 0, deps) # do recursion if called for else: dep_loop(candidate, deps) if do_search and (filename == target_file): found = 1 break if do_search and not found: print target_file + " was not found in " + target + " ..." sys.exit(1) else: # single file, just check it and exit # top level deps parent = target try: deps = deps_check(target) except NotELFError: print "not an ELF file..." sys.exit(1) # FIXME: for now, if no deps were found, assume the file # is statically linked. Should rework the recursion so # we don't need this. if not deps: deps.append("STATIC") if depth == 1: print_deps(target, deps) # do recursion if called for else: dep_loop(parent, deps) sys.exit(0)
| 473,680
|
def main(): opt_parser = optparse.OptionParser(usage=usage_line, version="%prog version " + version, option_list=command_line_options) (options, args) = opt_parser.parse_args() if len(args) == 0 or len(args) > 2: opt_parser.error("improper number of non-option arguments") # prog_ndx_start is the offset in argv for the file/dir and recursion prog_ndx_start = 1 found = 0 parent = "" global do_csv, depth, do_static do_static = options.do_static do_csv = options.do_csv if options.target: do_search = True target = options.target target_file = args[0] if not os.path.isdir(target): print target + " does not appear to be a directory..." sys.exit(1) else: do_search = False target = args[0] if not(os.path.isdir(target) or os.path.isfile(target)): print target + " does not appear to be a directory or file..." sys.exit(1) # sanity check on recursion level if len(args) == 1: depth = 1 else: try: recursion_arg = args[1] depth = int(recursion_arg) except: bad_depth() if depth < 1: bad_depth() if os.path.isdir(target): # walk the directory tree and find ELF files to process for path, dirs, files in os.walk(target): for filename in files: if (do_search and (filename == target_file)) or not(do_search): candidate = os.path.join(path, filename) if os.path.isfile(candidate): try: deps = deps_check(candidate) except NotELFError: deps = [] if len(deps) > 0: if depth == 1: deps_print(parent, parent, candidate, 0, deps) # do recursion if called for else: dep_loop(candidate, deps) if do_search and (filename == target_file): found = 1 break if do_search and not found: print target_file + " was not found in " + target + " ..." sys.exit(1) else: # single file, just check it and exit # top level deps parent = target try: deps = deps_check(target) except NotELFError: print "not an ELF file..." sys.exit(1) # FIXME: for now, if no deps were found, assume the file # is statically linked. Should rework the recursion so # we don't need this. if not deps: deps.append("STATIC") if depth == 1: deps_print(parent, parent, target, 0, deps) # do recursion if called for else: dep_loop(parent, deps) sys.exit(0)
|
def main(): opt_parser = optparse.OptionParser(usage=usage_line, version="%prog version " + version, option_list=command_line_options) (options, args) = opt_parser.parse_args() if len(args) == 0 or len(args) > 2: opt_parser.error("improper number of non-option arguments") # prog_ndx_start is the offset in argv for the file/dir and recursion prog_ndx_start = 1 found = 0 parent = "" global do_csv, depth, do_static do_static = options.do_static do_csv = options.do_csv if options.target: do_search = True target = options.target target_file = args[0] if not os.path.isdir(target): print target + " does not appear to be a directory..." sys.exit(1) else: do_search = False target = args[0] if not(os.path.isdir(target) or os.path.isfile(target)): print target + " does not appear to be a directory or file..." sys.exit(1) # sanity check on recursion level if len(args) == 1: depth = 1 else: try: recursion_arg = args[1] depth = int(recursion_arg) except: bad_depth() if depth < 1: bad_depth() if os.path.isdir(target): # walk the directory tree and find ELF files to process for path, dirs, files in os.walk(target): for filename in files: if (do_search and (filename == target_file)) or not(do_search): candidate = os.path.join(path, filename) if os.path.isfile(candidate): try: deps = deps_check(candidate) except NotELFError: deps = [] if len(deps) > 0: if depth == 1: deps_print(parent, parent, candidate, 0, deps) # do recursion if called for else: dep_loop(candidate, deps) if do_search and (filename == target_file): found = 1 break if do_search and not found: print target_file + " was not found in " + target + " ..." sys.exit(1) else: # single file, just check it and exit # top level deps parent = target try: deps = deps_check(target) except NotELFError: print "not an ELF file..." sys.exit(1) # FIXME: for now, if no deps were found, assume the file # is statically linked. Should rework the recursion so # we don't need this. if not deps: deps.append("STATIC") if depth == 1: deps_print(parent, parent, target, 0, deps) # do recursion if called for else: for dep in deps: dep_loop(parent, None, dep, 1) sys.exit(0)
| 473,681
|
def deps_check(target): deps = [] # run the "file" command and see if it's ELF filetype = os.popen("file " + target).read() if re.search("ELF", filetype): if not re.search("statically linked", filetype): elfcall = "readelf -d " + target for elfdata in os.popen(elfcall).readlines(): # lines we want all have "NEEDED" if re.search("NEEDED", elfdata): # library is the 5th field dep = string.split(elfdata)[4] dep = dep.strip("[]") deps.append(dep) if do_static: deps.extend(static_deps_check(target)) else: raise NotELFError, "not an ELF file" return deps
|
def deps_check(target): deps = [] # run the "file" command and see if it's ELF filetype = os.popen("file " + target).read() if re.search("ELF", filetype): if not re.search("statically linked", filetype): elfcall = "readelf -d " + target for elfdata in os.popen(elfcall).readlines(): # lines we want all have "NEEDED" if re.search("NEEDED", elfdata): # library is the 5th field dep = string.split(elfdata)[4] dep = dep.strip("[]") deps.append(dep) if do_static: deps.extend(static_deps_check(target)) else: raise NotELFError, "not an ELF file" return deps
| 473,682
|
def __unicode__(self): return self.library
|
def __unicode__(self): return self.library
| 473,683
|
#def __unicode__(self):
|
#def __unicode__(self):
| 473,684
|
#def __unicode__(self):
|
#def __unicode__(self):
| 473,685
|
def results(request): if request.method == 'POST': # If the form has been submitted... testlist = request.POST.get('testlist', '') if testlist != '': tests = testlist.split(",") for test in tests: if test != '': q = Test.objects.filter(id = test) q.delete() q = File.objects.filter(test = test) q.delete() q = Lib.objects.filter(test = test) q.delete() else: resultsform = ResultsForm() latest_test_list = Test.objects.all().order_by('-test_date') return render_to_response('linkage/results.html', {'latest_test_list': latest_test_list})
|
def results(request): if request.method == 'POST': # If the form has been submitted... testlist = request.POST.get('testlist', '') if testlist != '': tests = testlist.split(",") for test in tests: if test != '': q = Test.objects.filter(id = test) q.delete() q = File.objects.filter(test = test) q.delete() q = Lib.objects.filter(test = test) q.delete() latest_test_list = Test.objects.all().order_by('-test_date') return render_to_response('linkage/results.html', {'latest_test_list': latest_test_list})
| 473,686
|
def licenses(request): errmsg = '' if request.method == 'POST': # If the form has been submitted... mode = urllib.unquote(request.POST.get('submit')) if re.search("^Add License", mode): licenseform = LicenseForm(request.POST) # A form bound to the POST data # request to add data if licenseform.is_valid(): # All validation rules pass licenseform.save() if re.search("^Add", mode) and re.search("Aliases", mode): aliasesform = AliasesForm(request.POST) # A form bound to the POST data # request to add data - we may have multiple aliases to add if aliasesform.is_valid(): # All validation rules pass license = aliasesform.cleaned_data['license'] errlist = [] for i in range(1,10): ainput = request.POST.get('alinput' + str(i), '') if ainput: aliasdata = Aliases(license = license, alias = ainput) try: aliasdata.save() except: errlist.append(str(ainput)) if errlist: errmsg = "<b>Warning:</b> failed to add duplicate aliases " + str(errlist) if re.search("^Delete Selected Licenses", mode): # delete request licenselist = request.POST.get('licenselist', '') if licenselist != '': delete_records(License, licenselist) if re.search("^Delete Selected Aliases", mode): # delete request aliaslist = request.POST.get('aliaslist', '') if aliaslist != '': # not by id here, so don't call delete_records records = aliaslist.split(",") for record in records: if record != '': q = Aliases.objects.filter(license = record) q.delete() licenseform = LicenseForm() # An unbound form aliasesform = AliasesForm() # An unbound form latest_license_list = License.objects.all().order_by('longname') # we represent this one differently in the gui, pre-arrange things here aliases_list = Aliases.objects.values('license').distinct() for l in aliases_list: alias_list = Aliases.objects.values('alias').filter(license = l['license']) aliases = '' for a in alias_list: aliases += a['alias'] + ' | ' # chomp the last "or" off l['alias'] = aliases[:-3] # we want multiple input boxes to enter a number of aliases per license, at once al_input = [] for i in range(1,10): al_input.append('<input type="text" size="6" name="alinput' + str(i) + '">') return render_to_response('linkage/licenses.html', { 'errmsg': errmsg, 'latest_license_list': latest_license_list, 'latest_aliases_list': aliases_list, 'licenseform': licenseform, 'aliasesform': aliasesform, 'input_list': al_input, 'tab_licenses': True })
|
def licenses(request): errmsg = '' if request.method == 'POST': # If the form has been submitted... mode = urllib.unquote(request.POST.get('submit')) if re.search("^Add", mode) and re.search("License", mode): licenseform = LicenseForm(request.POST) # A form bound to the POST data # request to add data if licenseform.is_valid(): # All validation rules pass licenseform.save() if re.search("^Add", mode) and re.search("Aliases", mode): aliasesform = AliasesForm(request.POST) # A form bound to the POST data # request to add data - we may have multiple aliases to add if aliasesform.is_valid(): # All validation rules pass license = aliasesform.cleaned_data['license'] errlist = [] for i in range(1,10): ainput = request.POST.get('alinput' + str(i), '') if ainput: aliasdata = Aliases(license = license, alias = ainput) try: aliasdata.save() except: errlist.append(str(ainput)) if errlist: errmsg = "<b>Warning:</b> failed to add duplicate aliases " + str(errlist) if re.search("^Delete Selected Licenses", mode): # delete request licenselist = request.POST.get('licenselist', '') if licenselist != '': delete_records(License, licenselist) if re.search("^Delete Selected Aliases", mode): # delete request aliaslist = request.POST.get('aliaslist', '') if aliaslist != '': # not by id here, so don't call delete_records records = aliaslist.split(",") for record in records: if record != '': q = Aliases.objects.filter(license = record) q.delete() licenseform = LicenseForm() # An unbound form aliasesform = AliasesForm() # An unbound form latest_license_list = License.objects.all().order_by('longname') # we represent this one differently in the gui, pre-arrange things here aliases_list = Aliases.objects.values('license').distinct() for l in aliases_list: alias_list = Aliases.objects.values('alias').filter(license = l['license']) aliases = '' for a in alias_list: aliases += a['alias'] + ' | ' # chomp the last "or" off l['alias'] = aliases[:-3] # we want multiple input boxes to enter a number of aliases per license, at once al_input = [] for i in range(1,10): al_input.append('<input type="text" size="6" name="alinput' + str(i) + '">') return render_to_response('linkage/licenses.html', { 'errmsg': errmsg, 'latest_license_list': latest_license_list, 'latest_aliases_list': aliases_list, 'licenseform': licenseform, 'aliasesform': aliasesform, 'input_list': al_input, 'tab_licenses': True })
| 473,687
|
def get_project_root(): project_root_paths = [ ".", "..", "/opt/linuxfoundation" ] for path in project_root_paths: if os.path.exists(os.path.join(path, "bin/readelf.py")): return path # Shouldn't get here unless we can't find the path. raise RuntimeError, "could not find the project path"
|
def get_project_root(): project_root_paths = [ ".", "..", "/opt/linuxfoundation" ] for path in project_root_paths: if os.path.exists(os.path.join(path, "bin/readelf.py")): return path # Shouldn't get here unless we can't find the path. raise RuntimeError, "could not find the project path"
| 473,688
|
def check_policy(flicense, llicense, library, issue): # is the lib dynamic or static? ltype = 'Dynamic' if re.search(is_static, library): ltype = 'Static' # it's possible that the license assigned to the target or library is one of # the aliases, in which case we need the 'official' name for the policy check pllicense = llicense # we want to display both names in the report, if present pflicense = flicense llicenseset = Aliases.objects.filter(alias = llicense) if llicenseset: # can only be one match pllicense = llicenseset[0].license flicenseset = Aliases.objects.filter(alias = flicense) if flicenseset: # can only be one match pflicense = flicenseset[0].license policyset = Policy.objects.filter(tlicense = pflicense, dlicense = pllicense) policyset = policyset.filter(Q(relationship = ltype) | Q(relationship = 'Both')) # if we got multiple matches, just return - bad policies if policyset and policyset.count() < 2: status = policyset[0].status if status == 'D': issue = issue or True if llicense != pllicense: # plug in the alias (real name) llicense = llicense + ' (' + pllicense + ')' llicense = flag_policy_issue(llicense, status) if flicense != pflicense: flicense = flicense + ' (' + pflicense + ')' # only modify the target when there's a problem if issue: flicense = flag_policy_issue(flicense, status) return issue, llicense, flicense
|
def check_policy(flicense, llicense, library, issue): # is the lib dynamic or static? ltype = 'Dynamic' if re.search(is_static, library): ltype = 'Static' # it's possible that the license assigned to the target or library is one of # the aliases, in which case we need the 'official' name for the policy check pllicense = llicense # we want to display both names in the report, if present pflicense = flicense llicenseset = Aliases.objects.filter(alias = llicense) if llicenseset: # can only be one match pllicense = llicenseset[0].license flicenseset = Aliases.objects.filter(alias = flicense) if flicenseset: # can only be one match pflicense = flicenseset[0].license policyset = Policy.objects.filter(tlicense = pflicense, dlicense = pllicense) policyset = policyset.filter(Q(relationship = ltype) | Q(relationship = 'Both')) # if we got multiple matches, just return - bad policies if policyset and policyset.count() < 2: status = policyset[0].status if status == 'D': issue = issue or True if llicense != pllicense: # plug in the alias (real name) llicense = llicense + ' (' + pllicense + ')' llicense = flag_policy_issue(llicense, status) if flicense != pflicense: flicense = flicense + ' (' + pflicense + ')' # only modify the target when there's a problem if issue: flicense = flag_policy_issue(flicense, 'D') return issue, llicense, flicense
| 473,689
|
def main(argv): if len(argv) < 2 or '-?' in argv or '-h' in argv: show_usage(argv) # prog_ndx_start is the offset in argv for the file/dir and recursion prog_ndx_start = 1 do_search = 0 do_csv = 0 found = 0 parent = "" if '-c' in argv: sloc = string.index(argv, "-c") if prog_ndx_start <= sloc: prog_ndx_start = sloc + 1; do_csv = 1 if '-s' in argv: sloc = string.index(argv, "-s") target = argv[sloc + 1] if prog_ndx_start <= sloc: prog_ndx_start = sloc + 2; do_search = 1 # sanity check on file/directory name if not(do_search): target = argv[prog_ndx_start] if not(os.path.isdir(target) or os.path.isfile(target)): print target + " does not appear to be a directory or file..." sys.exit(1) else: if len(argv) < 4: show_usage(argv) target_file = argv[prog_ndx_start] if not os.path.isdir(target): print target + " does not appear to be a directory..." sys.exit(1) # sanity check on recursion level if len(argv) == prog_ndx_start + 1: depth = 1 else: try: recursion_arg = argv[prog_ndx_start + 1] depth = int(recursion_arg) except: bad_depth() if depth < 1: bad_depth() if os.path.isdir(target): # walk the directory tree and find ELF files to process for path, dirs, files in os.walk(target): for filename in files: if (do_search and (filename == target_file)) or not(do_search): candidate = os.path.join(path, filename) if os.path.isfile(candidate): deps = deps_check(candidate) if len(deps) > 0: if depth == 1: deps_print(parent, parent, candidate, 0, deps, do_csv, depth) # do recursion if called for else: dep_loop(depth, candidate, deps, do_csv) if do_search and (filename == target_file): found = 1 break if do_search and not found: print target_file + " was not found in " + target + " ..." sys.exit(1) else: # single file, just check it and exit # top level deps parent = target try: deps = deps_check(target) except NotELFError: print "not an ELF file..." sys.exit(1) # FIXME: for now, if no deps were found, assume the file # is statically linked. Should rework the recursion so # we don't need this. if not deps: deps.append("STATIC") if depth == 1: deps_print(parent, parent, target, 0, deps, do_csv, depth) # do recursion if called for else: dep_loop(depth, parent, deps, do_csv) sys.exit(0)
|
def main(argv): if len(argv) < 2 or '-?' in argv or '-h' in argv: show_usage(argv) # prog_ndx_start is the offset in argv for the file/dir and recursion prog_ndx_start = 1 do_search = 0 do_csv = 0 found = 0 parent = "" if '-c' in argv: sloc = string.index(argv, "-c") if prog_ndx_start <= sloc: prog_ndx_start = sloc + 1; do_csv = 1 if '-s' in argv: sloc = string.index(argv, "-s") target = argv[sloc + 1] if prog_ndx_start <= sloc: prog_ndx_start = sloc + 2; do_search = 1 # sanity check on file/directory name if not(do_search): target = argv[prog_ndx_start] if not(os.path.isdir(target) or os.path.isfile(target)): print target + " does not appear to be a directory or file..." sys.exit(1) else: if len(argv) < 4: show_usage(argv) target_file = argv[prog_ndx_start] if not os.path.isdir(target): print target + " does not appear to be a directory..." sys.exit(1) # sanity check on recursion level if len(argv) == prog_ndx_start + 1: depth = 1 else: try: recursion_arg = argv[prog_ndx_start + 1] depth = int(recursion_arg) except: bad_depth() if depth < 1: bad_depth() if os.path.isdir(target): # walk the directory tree and find ELF files to process for path, dirs, files in os.walk(target): for filename in files: if (do_search and (filename == target_file)) or not(do_search): candidate = os.path.join(path, filename) if os.path.isfile(candidate): try: deps = deps_check(candidate) except NotELFError: deps = [] if len(deps) > 0: if depth == 1: deps_print(parent, parent, candidate, 0, deps, do_csv, depth) # do recursion if called for else: dep_loop(depth, candidate, deps, do_csv) if do_search and (filename == target_file): found = 1 break if do_search and not found: print target_file + " was not found in " + target + " ..." sys.exit(1) else: # single file, just check it and exit # top level deps parent = target try: deps = deps_check(target) except NotELFError: print "not an ELF file..." sys.exit(1) # FIXME: for now, if no deps were found, assume the file # is statically linked. Should rework the recursion so # we don't need this. if not deps: deps.append("STATIC") if depth == 1: deps_print(parent, parent, target, 0, deps, do_csv, depth) # do recursion if called for else: dep_loop(depth, parent, deps, do_csv) sys.exit(0)
| 473,690
|
def start(run_browser, interface=None): if settings.USERDIR_ROOT: setup_userdir() childpid = os.fork() if childpid == 0: os.setsid() log_fn = os.path.join(settings.STATE_ROOT, "server.log") try: log_fd = os.open(log_fn, os.O_WRONLY | os.O_APPEND | os.O_CREAT) except OSError: log_fd = -1 if log_fd < 0: sys.stderr.write("Could not open log file; logging to stdout.\n") else: os.dup2(log_fd, 1) os.dup2(log_fd, 2) os.close(0) manager_args = ["dep-checker", "runserver"] if interface: manager_args.append(interface) execute_manager(settings, manager_args) else: pid_path = os.path.join(settings.STATE_ROOT, "server.pid") pid_file = open(pid_path, "w") pid_file.write(str(childpid)) pid_file.close() if run_browser: if interface: if interface.find(":") != -1: (ipaddr, port) = interface.split(":") if ipaddr == "0.0.0.0": interface = "127.0.0.1:" + port app_url = "http://%s/linkage" % interface else: app_url = "http://127.0.0.1:8000/linkage" sys.stdout.write("Waiting for the server to start...\n") time.sleep(10) sys.stdout.write("Starting a web browser.\n") os.execlp("xdg-open", "xdg-open", app_url) else: sys.exit(0)
|
def start_server(run_browser, interface=None): if settings.USERDIR_ROOT: setup_userdir() childpid = os.fork() if childpid == 0: os.setsid() log_fn = os.path.join(settings.STATE_ROOT, "server.log") try: log_fd = os.open(log_fn, os.O_WRONLY | os.O_APPEND | os.O_CREAT) except OSError: log_fd = -1 if log_fd < 0: sys.stderr.write("Could not open log file; logging to stdout.\n") else: os.dup2(log_fd, 1) os.dup2(log_fd, 2) os.close(0) manager_args = ["dep-checker", "runserver"] if interface: manager_args.append(interface) execute_manager(settings, manager_args) else: pid_path = os.path.join(settings.STATE_ROOT, "server.pid") pid_file = open(pid_path, "w") pid_file.write(str(childpid)) pid_file.close() if run_browser: if interface: if interface.find(":") != -1: (ipaddr, port) = interface.split(":") if ipaddr == "0.0.0.0": interface = "127.0.0.1:" + port app_url = "http://%s/linkage" % interface else: app_url = "http://127.0.0.1:8000/linkage" sys.stdout.write("Waiting for the server to start...\n") time.sleep(10) sys.stdout.write("Starting a web browser.\n") os.execlp("xdg-open", "xdg-open", app_url) else: sys.exit(0)
| 473,691
|
def stop(): pid_path = os.path.join(settings.STATE_ROOT, "server.pid") if os.path.exists(pid_path): server_pid = int(open(pid_path).read()) sys.stdout.write("Killing process %d...\n" % server_pid) try: try: os.kill(server_pid, signal.SIGTERM) finally: os.unlink(pid_path) except OSError, e: sys.stderr.write("Could not kill process: %s\n" % str(e)) sys.exit(1) else: sys.stderr.write("No server process found to stop.\n") sys.exit(1)
|
def stop_server(): pid_path = os.path.join(settings.STATE_ROOT, "server.pid") if os.path.exists(pid_path): server_pid = int(open(pid_path).read()) sys.stdout.write("Killing process %d...\n" % server_pid) try: try: os.kill(server_pid, signal.SIGTERM) finally: os.unlink(pid_path) except OSError, e: sys.stderr.write("Could not kill process: %s\n" % str(e)) sys.exit(1) else: sys.stderr.write("No server process found to stop.\n") sys.exit(1)
| 473,692
|
def main(): cmdline_parser = optparse.OptionParser(usage=command_line_usage, option_list=command_line_options) (options, args) = cmdline_parser.parse_args() if len(args) != 1 or args[0] not in ["start", "stop"]: cmdline_parser.error("incorrect arguments") # Switch users if needed. if args[0] == "start": if not options.force_root: check_current_user() start(not options.server_only, options.interface) else: stop()
|
def main(): cmdline_parser = optparse.OptionParser(usage=command_line_usage, option_list=command_line_options) (options, args) = cmdline_parser.parse_args() if len(args) != 1 or args[0] not in ["start", "stop"]: cmdline_parser.error("incorrect arguments") # Switch users if needed. if args[0] == "start": if not options.force_root: check_current_user() start_server(not options.server_only, options.interface) else: stop()
| 473,693
|
def main(): cmdline_parser = optparse.OptionParser(usage=command_line_usage, option_list=command_line_options) (options, args) = cmdline_parser.parse_args() if len(args) != 1 or args[0] not in ["start", "stop"]: cmdline_parser.error("incorrect arguments") # Switch users if needed. if args[0] == "start": if not options.force_root: check_current_user() start(not options.server_only, options.interface) else: stop()
|
def main(): cmdline_parser = optparse.OptionParser(usage=command_line_usage, option_list=command_line_options) (options, args) = cmdline_parser.parse_args() if len(args) != 1 or args[0] not in ["start", "stop"]: cmdline_parser.error("incorrect arguments") # Switch users if needed. if args[0] == "start": if not options.force_root: check_current_user() start(not options.server_only, options.interface) else: stop_server()
| 473,694
|
def find_static_library(func): "Given a symbol, return the most likely static library it's from." found_lib = None dbpath = None for dp in database_search_path: if os.path.exists(os.path.join(dp, "staticdb.sqlite")): dbpath = dp break if dbpath: staticdb = sqlite3.connect(os.path.join(dbpath, "staticdb.sqlite")) cursor = staticdb.cursor() cursor.execute("SELECT library FROM static WHERE symbol=?", (func,)) results = cursor.fetchall() if len(results) == 1: found_lib = results[0][0] + " (static)" elif len(results) > 1: found_libs = [ x[0] for x in results ] found_lib = ",".join(found_libs) + " (static)" return found_lib
|
def find_static_library(func): "Given a symbol, return the most likely static library it's from." found_libs = [] dbpath = None for dp in database_search_path: if os.path.exists(os.path.join(dp, "staticdb.sqlite")): dbpath = dp break if dbpath: staticdb = sqlite3.connect(os.path.join(dbpath, "staticdb.sqlite")) cursor = staticdb.cursor() cursor.execute("SELECT library FROM static WHERE symbol=?", (func,)) results = cursor.fetchall() if len(results) == 1: found_lib = results[0][0] + " (static)" elif len(results) > 1: found_libs = [ x[0] for x in results ] found_lib = ",".join(found_libs) + " (static)" return found_lib
| 473,695
|
def find_static_library(func): "Given a symbol, return the most likely static library it's from." found_lib = None dbpath = None for dp in database_search_path: if os.path.exists(os.path.join(dp, "staticdb.sqlite")): dbpath = dp break if dbpath: staticdb = sqlite3.connect(os.path.join(dbpath, "staticdb.sqlite")) cursor = staticdb.cursor() cursor.execute("SELECT library FROM static WHERE symbol=?", (func,)) results = cursor.fetchall() if len(results) == 1: found_lib = results[0][0] + " (static)" elif len(results) > 1: found_libs = [ x[0] for x in results ] found_lib = ",".join(found_libs) + " (static)" return found_lib
|
def find_static_library(func): "Given a symbol, return the most likely static library it's from." found_lib = None dbpath = None for dp in database_search_path: if os.path.exists(os.path.join(dp, "staticdb.sqlite")): dbpath = dp break if dbpath: staticdb = sqlite3.connect(os.path.join(dbpath, "staticdb.sqlite")) cursor = staticdb.cursor() cursor.execute("SELECT library FROM static WHERE symbol=?", (func,)) results = cursor.fetchall() if len(results) == 1: found_libs.append(results[0][0]) elif len(results) > 1: found_libs = [ x[0] for x in results ] found_lib = ",".join(found_libs) + " (static)" return found_lib
| 473,696
|
def find_static_library(func): "Given a symbol, return the most likely static library it's from." found_lib = None dbpath = None for dp in database_search_path: if os.path.exists(os.path.join(dp, "staticdb.sqlite")): dbpath = dp break if dbpath: staticdb = sqlite3.connect(os.path.join(dbpath, "staticdb.sqlite")) cursor = staticdb.cursor() cursor.execute("SELECT library FROM static WHERE symbol=?", (func,)) results = cursor.fetchall() if len(results) == 1: found_lib = results[0][0] + " (static)" elif len(results) > 1: found_libs = [ x[0] for x in results ] found_lib = ",".join(found_libs) + " (static)" return found_lib
|
def find_static_library(func): "Given a symbol, return the most likely static library it's from." found_lib = None dbpath = None for dp in database_search_path: if os.path.exists(os.path.join(dp, "staticdb.sqlite")): dbpath = dp break if dbpath: staticdb = sqlite3.connect(os.path.join(dbpath, "staticdb.sqlite")) cursor = staticdb.cursor() cursor.execute("SELECT library FROM static WHERE symbol=?", (func,)) results = cursor.fetchall() if len(results) == 1: found_lib = results[0][0] + " (static)" elif len(results) > 1: found_libs = [ x[0] for x in results ] return found_libs
| 473,697
|
def static_deps_check(target): "Look for statically linked dependencies." # State enumeration for debug parser. FIND_NEXT = 1 FIND_NAME = 2 # The algorithm here is pretty basic. We grab a complete symbol list # and debug information. Any symbols that aren't covered by debug # information are considered to be source from static libraries. # Read the functions from the symbol list. symlist = [ x.split() for x in os.popen("readelf -s " + target) ] symlist = [ x for x in symlist if len(x) == 8 ] sym_funcs = set([ x[7] for x in symlist if x[3] == "FUNC" ]) # Read the functions from the debug information. debuginfo = os.popen("readelf -wi " + target) debug_funcs = set() debugstate = FIND_NEXT for line in debuginfo: if len(line) < 2: continue if debugstate == FIND_NAME: if line[1] == "<": debugstate = FIND_NEXT else: match = re.match(r'\s+<.+>\s+(.+?)\s+:\s+\(.+\):\s+(.+)$', line) if match: (field, value) = match.group(1, 2) if field == "DW_AT_name": debug_funcs.add(value.strip()) debugstate = FIND_NEXT if debugstate == FIND_NEXT and line[1] == "<": match = re.search(r'\((.+)\)$', line) if match and match.group(1) == "DW_TAG_subprogram": found_name = None debugstate = FIND_NAME # Get the functions in the symbol list that have no debug info. staticsym_funcs = sym_funcs - debug_funcs # For each function, figure out where it came from. staticlib_list = [] for func in staticsym_funcs: lib = find_static_library(func) if lib and lib not in staticlib_list: staticlib_list.append(lib) # Return the list. staticlib_list.sort() return staticlib_list
|
def static_deps_check(target): "Look for statically linked dependencies." # State enumeration for debug parser. FIND_NEXT = 1 FIND_NAME = 2 # The algorithm here is pretty basic. We grab a complete symbol list # and debug information. Any symbols that aren't covered by debug # information are considered to be source from static libraries. # Read the functions from the symbol list. symlist = [ x.split() for x in os.popen("readelf -s " + target) ] symlist = [ x for x in symlist if len(x) == 8 ] sym_funcs = set([ x[7] for x in symlist if x[3] == "FUNC" ]) # Read the functions from the debug information. debuginfo = os.popen("readelf -wi " + target) debug_funcs = set() debugstate = FIND_NEXT for line in debuginfo: if len(line) < 2: continue if debugstate == FIND_NAME: if line[1] == "<": debugstate = FIND_NEXT else: match = re.match(r'\s+<.+>\s+(.+?)\s+:\s+\(.+\):\s+(.+)$', line) if match: (field, value) = match.group(1, 2) if field == "DW_AT_name": debug_funcs.add(value.strip()) debugstate = FIND_NEXT if debugstate == FIND_NEXT and line[1] == "<": match = re.search(r'\((.+)\)$', line) if match and match.group(1) == "DW_TAG_subprogram": found_name = None debugstate = FIND_NAME # Get the functions in the symbol list that have no debug info. staticsym_funcs = sym_funcs - debug_funcs # For each function, figure out where it came from. staticlib_list = [] for func in staticsym_funcs: lib = find_static_library(func) if lib and lib not in staticlib_list: staticlib_list.append(lib) # Return the list. staticlib_list.sort() return staticlib_list
| 473,698
|
def static_deps_check(target): "Look for statically linked dependencies." # State enumeration for debug parser. FIND_NEXT = 1 FIND_NAME = 2 # The algorithm here is pretty basic. We grab a complete symbol list # and debug information. Any symbols that aren't covered by debug # information are considered to be source from static libraries. # Read the functions from the symbol list. symlist = [ x.split() for x in os.popen("readelf -s " + target) ] symlist = [ x for x in symlist if len(x) == 8 ] sym_funcs = set([ x[7] for x in symlist if x[3] == "FUNC" ]) # Read the functions from the debug information. debuginfo = os.popen("readelf -wi " + target) debug_funcs = set() debugstate = FIND_NEXT for line in debuginfo: if len(line) < 2: continue if debugstate == FIND_NAME: if line[1] == "<": debugstate = FIND_NEXT else: match = re.match(r'\s+<.+>\s+(.+?)\s+:\s+\(.+\):\s+(.+)$', line) if match: (field, value) = match.group(1, 2) if field == "DW_AT_name": debug_funcs.add(value.strip()) debugstate = FIND_NEXT if debugstate == FIND_NEXT and line[1] == "<": match = re.search(r'\((.+)\)$', line) if match and match.group(1) == "DW_TAG_subprogram": found_name = None debugstate = FIND_NAME # Get the functions in the symbol list that have no debug info. staticsym_funcs = sym_funcs - debug_funcs # For each function, figure out where it came from. staticlib_list = [] for func in staticsym_funcs: lib = find_static_library(func) if lib and lib not in staticlib_list: staticlib_list.append(lib) # Return the list. staticlib_list.sort() return staticlib_list
|
def static_deps_check(target): "Look for statically linked dependencies." # State enumeration for debug parser. FIND_NEXT = 1 FIND_NAME = 2 # The algorithm here is pretty basic. We grab a complete symbol list # and debug information. Any symbols that aren't covered by debug # information are considered to be source from static libraries. # Read the functions from the symbol list. symlist = [ x.split() for x in os.popen("readelf -s " + target) ] symlist = [ x for x in symlist if len(x) == 8 ] sym_funcs = set([ x[7] for x in symlist if x[3] == "FUNC" ]) # Read the functions from the debug information. debuginfo = os.popen("readelf -wi " + target) debug_funcs = set() debugstate = FIND_NEXT for line in debuginfo: if len(line) < 2: continue if debugstate == FIND_NAME: if line[1] == "<": debugstate = FIND_NEXT else: match = re.match(r'\s+<.+>\s+(.+?)\s+:\s+\(.+\):\s+(.+)$', line) if match: (field, value) = match.group(1, 2) if field == "DW_AT_name": debug_funcs.add(value.strip()) debugstate = FIND_NEXT if debugstate == FIND_NEXT and line[1] == "<": match = re.search(r'\((.+)\)$', line) if match and match.group(1) == "DW_TAG_subprogram": found_name = None debugstate = FIND_NAME # Get the functions in the symbol list that have no debug info. staticsym_funcs = sym_funcs - debug_funcs # For each function, figure out where it came from. staticlib_list = [] for func in staticsym_funcs: lib = find_static_library(func) if lib and lib not in staticlib_list: staticlib_list.append(lib) # Return the list. staticlib_list.sort() staticlib_results = [ x + " (static)" for x in staticlib_list ] return staticlib_results
| 473,699
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.