rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
url += urllib.quote_plus('?next=/%s' % request.META['HTTP_REFERER'].split('/', 3)[-1])
referer = request.META.get('HTTP_REFERER') if referer: url += urllib.quote_plus('?next=/%s' % referer.split('/', 3)[-1])
def usage(request, slug, action): success = False # Check if the user is authenticated, redirecting them to the login page if # they're not. if not request.user.is_authenticated(): url = settings.LOGIN_URL + '?next=%s' % reverse('usage', args=(slug, action)) url += urllib.quote_plus('?next=/%s' % request.META['HTTP_REF...
<li><strong>Utilities</strong> are apps, frameworks or sites but help Django.</li>
<li><strong>Utilities</strong> are not apps, frameworks or sites but still help Django in some way.</li>
def __unicode__(self): if not self.is_supported: return '%s (unsupported)' % self.title return self.title
self.save()
def fetch_metadata(self, *args, **kwargs): # Get the downloads from pypi if self.pypi_url.strip() and self.pypi_url != "http://pypi.python.org/pypi/": total_downloads = 0 for release in fetch_releases(self.pypi_name()): version, created = Version.objects.get_or_create( package = self, number = release.version )
django_dash = 'django-%s' % letter django_space = 'django %s' % letter packages = Package.objects.filter( Q(title__istartswith=letter) | Q(title__istartswith=django_dash) | Q(title__istartswith=django_space))
letter = letter.lower() if letter == 'd': packages = Package.objects.filter(title__istartswith=letter).exclude(title__istartswith='django-').exclude(title__istartswith='django ') else: django_dash = 'django-%s' % letter django_space = 'django %s' % letter packages = Package.objects.filter( Q(title__istartswith=letter) ...
def handle(self, *args, **options):
for package in Package.objects.filter(title__startswith=letter):
for package in packages:
def handle(self, *args, **options):
print >> stdout, "%s packages updated" % index +1
print >> stdout, "%s packages updated" % int(index) + 1
def handle(self, *args, **options): print >> stdout, "Commencing package updating now" github = Github()
match = downloads_re.search(page).group()
match = downloads_re.search(page)
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....
logging.error('No serial port is available.') logging.error('Are the game buttons connected?')
print 'No serial port is available.' print 'Are the game buttons connected?'
def __init__(self): """ Setup the serial system. """ super(GameButtons, self).__init__()
self.daily_double_overlay(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(self.get_width(), self.get_heigh...
logging.debug('called set text.')
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)
logging.debug("Entered clue square on_paint.")
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 ==...
absolute_path = path
absolute_path = location
def _find_config_file(self): absolute_path = None for location in CONFIG_LOCATIONS: if os.path.isfile(location): absolute_path = path return absolute_path
self.set_text('')
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('')
self.game_board = GameBoard() self.game_board.set_scale(0.6, 0.6) self.add(self.game_board)
def __init__(self): super(IdleBox, self).__init__(clutter.FlowLayout(clutter.FLOW_VERTICAL))
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)
self.add(self.text) class DailyDoubleOverlay(clutter.Box): """ """ def __init__(self): """ """ super(DailyDoubleOverlay, self).__init__(clutter.BinLayout( clutter.BIN_ALIGNMENT_CENTER, clutter.BIN_ALIGNMENT_CENTER)) self.set_color(config.square_background_color) self.text = Text(config.player_overlay_font, 'Daily\nDo...
def set_text(self, text): """ """ self.remove(self.text) self.text = Text(config.player_overlay_font, text) self.add(self.text)
self.board_box.add(self.game_board)
board_box_layout.pack(self.game_board, True, True, True, clutter.BOX_ALIGNMENT_CENTER, clutter.BOX_ALIGNMENT_CENTER)
def __init__(self): super(GUI, self).__init__()
board_box_layout = self.board_box.get_layout_manager()
self.player_score_box.set_width(0.1 * self.get_width())
def __init__(self): super(GUI, self).__init__()
self.game_board.set_size(self.get_width() * 0.9, 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())
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....
self.remove(self.game_board)
self.board_box.remove(self.game_board)
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...
self.game_board.set_size(self.get_width(), self.get_height()) self.add(self.game_board)
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())
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...
self.model = model layout = self.get_layout_manager() layout.set_vertical(False) spacing = int(self.get_width() * 0.01) layout.set_spacing(spacing) self.categories = [] category_number = 0 round = self.model.get_round() for category in round: category = Category(model, category, category_number) self.add(category) ca...
def __init__(self):
def __init__(self, model): super(GameBoard, self).__init__(clutter.BoxLayout())
for category in self.categories: category.set_click_handler(click_handler)
super(Model, self).__init__()
def set_click_handler(self, click_handler): """ """ for category in self.categories: category.set_click_handler(click_handler)
self.players.index(player)
return self.players.index(player)
def get_player_index(self, player): """ Given a player return that player's index. """ self.players.index(player)
bits = next(31)
bits = self.next(31)
def nextInt(self, n = None): """ Return a random int in [0, `n`).
return bool(next(1))
return bool(self.next(1))
def nextBoolean(self): """ Return a random bool. """
return next(24) / float(1 << 24)
return self.next(24) / float(1 << 24)
def nextFloat(self): """ Return a random float in (0, 1).
return ((next(26) << 27) + next(27)) / float(1 << 53)
return ((self.next(26) << 27) + self.next(27)) / float(1 << 53)
def nextDouble(self): """ Return a random float in (0, 1). """
retval = (self.next(32) << 32) + self.next(32) if retval & (1 << 63): retval -= (1 << 64) return retval
return (self.next(32) << 32) + self.next(32)
def nextLong(self): """ Return a random long.
haveEvents = firstEvent != u''
haveEvents = (firstEvent.id != u'')
def _getPartyStatus(self, now, nextEvents): firstEvent = self.context.getFirstEvent(self.request) lastEvent = self.context.getLastEvent(self.request)
clshideUntil = datetime.timedelta(seconds=config.defaultHideTime)
cls.hideUntil = datetime.timedelta(seconds=config.defaultHideTime)
def _initialize(config): cls = NoneLocation_cls cls.priority = config.defaultLocationPriority clshideUntil = datetime.timedelta(seconds=config.defaultHideTime)
self._gen = scheduler.run()
self._gen = self._scheduler.run()
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()
import copy return (copy.copy(inputs[0]), )
return (dict(inputs[0]), )
def __call__(self, inputs): """ inputs is the list of input values """ import copy return (copy.copy(inputs[0]), )
while (not loc_mask[bb].any() ) and (bb[ind] < imax) :
while (bb[ind] < imax) and (not loc_mask[bb].any() ) :
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 an...
while mask[bb].any() and (bb[ind] < imax) :
while (bb[ind] < imax) and mask[bb].any() :
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 an...
def flatten (img_list) :
def flatten (img_list, alpha = False) :
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 ...
.. warning:: all images must have the same shape either 2D or 3D and an alpha channel .. warning:: the resulting image has no alpha channel
.. 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 ...
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 ...
:Returns Type: NxM(xP)x3 array of uint8 """ R = img_list[0][...,0] G = img_list[0][...,1] B = img_list[0][...,2]
- `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 = []
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 ...
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) )
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) ) i...
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 ...
if instance and name:
if instance is not None and name is not None:
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...
prefix = str(instance)
prefix = type(instance).__name__ if not hasattr(instance, "__name__") \ else instance.__name__
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...
self._transform = self._transform * transfo
self._transform = transfo * self._transform
def transform (self, transfo) : """Combine a transformation with the actual transformation of this element. :Parameters: - `transfo` (:class:`SVGTransform`) """ self._transform = self._transform * transfo
self._transform = self._transform * translation(dx,dy)
self._transform = translation(dx,dy) * self._transform
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)
self._transform = self._transform * rotation(angle)
self._transform = rotation(angle) * self._transform
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)
self._transform = self._transform * scaling(sx,sy)
self._transform = scaling(sx,sy) * self._transform
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)
urllib.urlretrieve( "http://gforge.inria.fr/plugins/scmsvn/viewcvs.php/*checkout*/trunk/deploygui/src/openalea/deploygui/auth.py?root=openalea",
urllib.urlretrieve( "http://gforge.inria.fr/scm/viewcvs.php/*checkout*/trunk/deploygui/src/openalea/deploygui/auth.py?root=openalea",
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
self.add_input(name="legend", interface=IBool, value=True) self.add_input(name="show", interface=IBool, value=True) self.add_input(name="figure", interface=IDict, value={"num":1}) self.add_input(name="axes", interface=IDict, value={})
self.add_input(name="legend", interface=IDict, value={'legend on':True}) self.add_input(name="show", interface=IBool, value=True) self.add_input(name="figure", interface=IDict, value={"num":1}) self.add_input(name="axes", interface=IDict, value={})
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__
figure(**self.get_input("figure"))
fig = figure(**self.get_input("figure"))
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_...
line2dkwds = get_kwds_from_line2d(x, **kwds)
line2dkwds = get_kwds_from_line2d(x, kwds)
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_...
if self.get_input('legend') is True: legend(loc='best')
print self.get_input("legend").keys() if self.get_input("legend")['legend on']==True: mykwds = self.get_input("legend") del mykwds['legend on'] legend(**mykwds)
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_...
dummy=[] return (dummy, )
return (fig, )
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_...
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)
location = {'best':0, 'upper right': 1, 'upper left': 2, 'lower left': 3, 'lower right': 4, 'right': 5, 'center left': 6, 'center right': 7, 'lower center': 8, 'upper center': 9, 'center': 10} def __init__(self): Node.__init__(self) self.add_input(name="legend on", interface=IBool, value=True) self.add_input(name="sha...
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)
if self.get_input('legend') is None: legend(loc='best') else: legend(self.get_input('legend'), loc='best')
kwds = {} kwds['legend on'] = self.get_input('legend on') kwds['loc'] = self.get_input('location') kwds['numpoints'] = self.get_input('numpoints') kwds['loc'] = self.get_input('location') kwds['fancybox'] = self.get_input('fancybox') kwds['markerscale'] = self.get_input('markerscale') kwds['shadow'] = self.get_input(...
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')
self.add_output(name="figure")
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(...
fig = figure(num=self.get_input('num'), figsize=self.get_input('figsize'), dpi=self.get_input('dpi'), facecolor=self.get_input('facecolor'), edgecolor=self.get_input('edgecolor')) return fig,kwds
return kwds
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')
revision = __revision__.strip().split() if len(revision) > 2: revision = revision[2] else: revision = '0.8' print "Running ez_alea_setup version %s" % revision
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
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 """
print "Running ez_alea_setup version %s" % __revision__.split()[2]
revision = __revision__.strip().split() if len(revision) > 2: revision = revision[2] else: revision = '0.8' print "Running ez_alea_setup version %s" % revision
def welcome_setup(): print "Running ez_alea_setup version %s" % __revision__.split()[2] print """
tcolor = "yellow" if status == 'A': tcolor = "green"
tcolor = '' if status == 'U': tcolor = 'orange' tag_end += '<img src="/site_media/images/orange_flag.png" width="16" height="16" alt="orange_flag.png">'
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 = ...
tcolor = "red"
tcolor = 'red'
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 = ...
pllicense = llicenseset[0].license
pllicense = llicenseset[0].license if llicense != pllicense: llicense = llicense + ' (' + pllicense + ')'
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 # w...
pflicense = flicenseset[0].license
pflicense = flicenseset[0].license if flicense != pflicense: flicense = flicense + ' (' + pflicense + ')'
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 # w...
if llicense != pllicense: llicense = llicense + ' (' + pllicense + ')'
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 # w...
if flicense != pflicense: flicense = flicense + ' (' + pflicense + ')'
if not policyset and flicense != 'TBD': llicense = flag_policy_issue(llicense, 'U')
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 # w...
tag_start = '<font color="'
tag_start = '<span class="'
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_end = '</font>'
tag_end = '</span>'
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 = ...
target = dep_path(parent, dep) childdeps = deps_check(target)
if not re.search('(static)', dep): target = dep_path(parent, dep) childdeps = deps_check(target) else: childdeps = []
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 i...
for lib in libs: if lib not in staticlib_list: staticlib_list.append(lib)
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_mul...
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...
dep = dep.replace("[","") dep = dep.replace("]","")
dep = dep.strip("[]")
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...
def deps_print(title, parent, target, level, deps):
def print_deps(target, deps):
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_c...
nospace = '' if level > 0: nospace += spacer for space in range(0, level):
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 + ":"
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_c...
if len(deps) < 1:
for dep in deps: print spacer + dep def print_dep(dep, indent): spacer = 2 * indent * " " if not do_csv: print spacer + dep def print_path_dep(parent, soname, dep, indent): csvstring = '' spacer = (indent - 1) * " " token = "[" + str(indent) + "]" if not do_csv: print spacer + token + parent + ":" else: csvstring +=...
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_c...
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 + ":" space...
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 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_c...
deps_print(parent, parent, candidate, 0, deps)
print_deps(candidate, deps)
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 th...
dep_loop(candidate, deps)
for dep in deps: dep_loop(candidate, None, dep, 1)
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 th...
if not deps: deps.append("STATIC")
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 th...
deps_print(parent, parent, target, 0, deps)
print_deps(target, deps)
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 th...
dep_loop(parent, deps)
for dep in deps: dep_loop(parent, None, dep, 1)
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 th...
license = models.CharField('License', max_length=200, unique=True)
license = models.CharField('License', max_length=200) version = models.CharField('Version', max_length=20)
def __unicode__(self): return self.library
licenses = License.objects.all().order_by('license') choices = [] choices.append(('','')) for lic in licenses: choices.append((lic.license, lic.license))
def __init__(self, *args, **kwargs): super(PolicyForm, self).__init__(*args, **kwargs) self.fields['tlicense'].choices = license_choices() self.fields['dlicense'].choices = license_choices()
#def __unicode__(self):
tlicense.choices = choices dlicense.choices = choices
#def __unicode__(self):
else: resultsform = ResultsForm()
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.objec...
if re.search("^Add License", mode):
if re.search("^Add", mode) and re.search("License", mode):
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 valida...
TIME_ZONE = 'America/Chicago'
if 'TZ' not in os.environ: TIME_ZONE = 'Etc/GMT%+d' % (time.altzone / 3600) else: TIME_ZONE = os.environ['TZ']
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"
if issue: flicense = flag_policy_issue(flicense, status)
if issue: flicense = flag_policy_issue(flicense, 'D')
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...
deps = deps_check(candidate)
try: deps = deps_check(candidate) except NotELFError: deps = []
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 +...
def start(run_browser, interface=None):
def start_server(run_browser, interface=None):
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.writ...
def stop():
def stop_server():
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 k...
found_lib = None
found_libs = []
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")) curs...
found_lib = results[0][0] + " (static)"
found_libs.append(results[0][0])
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")) curs...
found_lib = ",".join(found_libs) + " (static)" return found_lib
return found_libs
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")) curs...
lib = find_static_library(func) if lib and lib not in staticlib_list: staticlib_list.append(lib)
libs = find_static_library(func) for lib in libs: if lib not in staticlib_list: staticlib_list.append(lib)
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...
return staticlib_list
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...
help="don't set cfg permissions")
help="don't set file permissions")
def arguments(): """Defines the command line arguments for the script.""" main_desc = ("Mirror a remote FTP directory into a local directory or vice " "versa through the lftp program") subs_desc = "Select a running mode from the following:" epilog = ("For detailed help for each mode, select a mode followed by help " "o...
help="don't apply umask to cfg modes")
help="don't apply umask to file modes")
def arguments(): """Defines the command line arguments for the script.""" main_desc = ("Mirror a remote FTP directory into a local directory or vice " "versa through the lftp program") subs_desc = "Select a running mode from the following:" epilog = ("For detailed help for each mode, select a mode followed by help " "o...
def bes_unit_size(f_size): """Get a size in bytes and convert it for the best unit for readability. Return two values: (int) bu_size -- Size of the path converted to the best unit for easy read (str) unit -- The units (IEC) for bu_size (from bytes(2^0) to YiB(2^80))
def best_unit_size(bytes_size): """Get a size in bytes & convert it to the best IEC prefix for readability. Return a dictionary with three pair of keys/values: 's' -- (float) Size of path converted to the best unit for easy read 'u' -- (str) The prefix (IEC) for s (from bytes(2^0) to YiB(2^80)) 'b' -- (int / long) Th...
def bes_unit_size(f_size): """Get a size in bytes and convert it for the best unit for readability. Return two values: (int) bu_size -- Size of the path converted to the best unit for easy read (str) unit -- The units (IEC) for bu_size (from bytes(2^0) to YiB(2^80)) """ for exp in range(0, 90 , 10): bu_size = f_size...
bu_size = f_size / pow(2.0, exp)
bu_size = abs(bytes_size) / pow(2.0, exp)
def bes_unit_size(f_size): """Get a size in bytes and convert it for the best unit for readability. Return two values: (int) bu_size -- Size of the path converted to the best unit for easy read (str) unit -- The units (IEC) for bu_size (from bytes(2^0) to YiB(2^80)) """ for exp in range(0, 90 , 10): bu_size = f_size...
return {'s':bu_size, 'u':unit}
return {'s':bu_size, 'u':unit, 'b':bytes_size}
def bes_unit_size(f_size): """Get a size in bytes and convert it for the best unit for readability. Return two values: (int) bu_size -- Size of the path converted to the best unit for easy read (str) unit -- The units (IEC) for bu_size (from bytes(2^0) to YiB(2^80)) """ for exp in range(0, 90 , 10): bu_size = f_size...
if os.path.isfile(the_path): path_size = os.path.getsize(the_path) for path, dirs, files in os.walk(the_path): for fil in files: filename = os.path.join(path, fil) path_size += os.path.getsize(filename)
for path, directories, files in os.walk(the_path): for filename in files: path_size += os.lstat(os.path.join(path, filename)).st_size for directory in directories: path_size += os.lstat(os.path.join(path, directory)).st_size path_size += os.path.getsize(the_path)
def get_size(the_path): """Get size of a directory tree or a file in bytes.""" path_size = 0 if os.path.isfile(the_path): path_size = os.path.getsize(the_path) for path, dirs, files in os.walk(the_path): for fil in files: filename = os.path.join(path, fil) path_size += os.path.getsize(filename) return path_size
log_size = get_size(log.filename)
log_size = get_size(log.filename) if os.path.exists(log.filename) else 0
def mirror(args, log): """Mirror the directories.""" user = '' if args.anonymous else ' '.join(args.login) local, remote = os.path.normpath(args.local), os.path.normpath(args.remote) port = '-p {0}'.format(args.port) if args.port else '' include = ' --include-glob {0}'.format(args.inc_glob) if args.inc_glob else '' ex...
size = bes_unit_size(local_size + gz_size + log_size)
size = best_unit_size(local_size + gz_size + log_size)
def mirror(args, log): """Mirror the directories.""" user = '' if args.anonymous else ' '.join(args.login) local, remote = os.path.normpath(args.local), os.path.normpath(args.remote) port = '-p {0}'.format(args.port) if args.port else '' include = ' --include-glob {0}'.format(args.inc_glob) if args.inc_glob else '' ex...