Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#
# get mirrors from database
#
mirrors = []
if args:
# select all mirrors matching the given identifiers
result = conn.Server.select()
for i in result:
if i.identifier in args:
mirrors.append(i)
else:
# select all enabled mirrors
#
# ignore wildcard mirrors, assuming that they can't be checked by normal means (i.e., baseurl itself may
# not give a 200. Just some files are served maybe...
result = conn.Server.select(AND(conn.Server.q.enabled, conn.Server.q.country != '**'))
for i in result:
mirrors.append(i)
if not mirrors:
sys.exit('no mirrors found')
#
# start work
#
logging.info('----- %s mirrors to check' % len(mirrors))
for i, mirror in enumerate(mirrors):
#mirror.status_baseurl_new = False
#mirror.timed_out = True
t = threading.Thread(target=probe_http,
def get_balance(self):
""" Return the total of all "extra" payments (like cash
advance, till complement, ...) associated to this till
operation *plus* all the payments, which payment method is
money, of all the sales associated with this operation
*plus* the initial cash amount.
"""
conn = self.get_connection()
result = Sale.selectBy(till=self, connection=conn)
query = AND(Sale.q.status == Sale.STATUS_CONFIRMED,
Sale.q.tillID == self.id)
result = Sale.select(query, connection=conn)
payments = []
money_payment_method = sysparam(conn).METHOD_MONEY
for sale in result:
sale_pg_facet = IPaymentGroup(sale)
assert sale_pg_facet, ("The sale associated to this "
"till operation don't have a "
"PaymentGroup facet.")
payments.extend([p for p in sale_pg_facet.get_items()
if p.status == Payment.STATUS_PAID])
pg_facet = IPaymentGroup(self, connection=conn)
if pg_facet:
payments.extend(pg_facet.get_items())
total = reduce(operator.add, [p.value for p in payments], 0.0)
for num, dbRenderNode in enumerate(renderNodes):
id, name, coresNumber, speed, ip, port, ramSize, caracteristics, performance = dbRenderNode
realRenderNode = RenderNode(id,
name,
coresNumber,
speed,
ip,
port,
ramSize,
json.loads(caracteristics),
performance)
# get the pools of the rendernode
prn = Table('pools_render_nodes')
join = INNERJOINOn(None, Pools, Pools.q.id == prn.pools_id)
dbPools = poolConn.queryAll(poolConn.sqlrepr(Select(poolFields, join=join, where=AND(prn.render_nodes_id == id, Pools.q.archived == False))))
for idx, dbPool in enumerate(dbPools):
id, name = dbPool
poolsById[id].renderNodes.append(realRenderNode)
realRenderNode.pools.append(poolsById[id])
tree.renderNodes[str(realRenderNode.name)] = realRenderNode
rnById[realRenderNode.id] = realRenderNode
if (time.time() - tmpTimer) > refreshDelay:
tmpTimer = time.time()
LOGGER.warning(" - progress: %d%%" % (100*num/float(nbElems-1)))
# add the pools to the dispatch tree
for pool in poolsById.values():
tree.pools[pool.name] = pool
else:
# pools and rns have already been processed, either from a file or a webservice
def _payment_query(self):
current_till = get_current_till_operation(self.conn)
group = IPaymentGroup(current_till, connection=self.conn)
statuses = [Payment.STATUS_TO_PAY, Payment.STATUS_CANCELLED]
query = AND(IN(Payment.q.status, statuses),
Payment.q.groupID == group.id)
payments = Payment.select(query, connection=self.conn)
self.debits = 0
self.credits = 0
for payment in payments:
if payment.value < 0:
self.debits += payment.value
else:
self.credits += payment.value
if current_till.initial_cash_amount < 0:
raise ValueError(_('Initial cash amount cannot be lesser than '
'zero'))
self.credits -= current_till.initial_cash_amount
base = config.get('base_address')
title = 'Latest Critical Path Updates'
query = [PackageUpdate.q.status != 'obsolete']
if release:
try:
release = Release.byName(release)
except SQLObjectNotFound:
return dict(title = '%s release not found' % release, entries=[])
releases = [release]
title = title + ' for %s' % release.long_name
else:
releases = Release.select()
if unapproved:
query.append(PackageUpdate.q.status != 'stable')
for update in PackageUpdate.select(
AND(OR(*[PackageUpdate.q.releaseID == release.id
for release in releases]),
*query),
orderBy=PackageUpdate.q.date_submitted).reversed():
delta = datetime.utcnow() - update.date_submitted
if delta and delta.days > config.get('feeds.num_days_to_show'):
if len(entries) >= config.get('feeds.max_entries'):
break
if update.critpath:
if unapproved:
if update.critpath_approved:
continue
entries.append({
'id' : base + url(update.get_url()),
'summary' : update.notes,
@expose(template="bodhi.templates.security")
@identity.require(identity.in_group("security_respons"))
def security(self):
""" Return a list of security updates pending approval """
updates = PackageUpdate.select(
AND(PackageUpdate.q.type == 'security',
PackageUpdate.q.status == 'pending',
PackageUpdate.q.approved == None),
orderBy=PackageUpdate.q.date_submitted)
return dict(updates=updates)
def get_last_till_operation(conn):
""" The last till operation is used to get a initial cash amount
to a new till operation that will be created, this value is based
on the final_cash_amount attribute of the last till operation
"""
query = AND(Till.q.status == Till.STATUS_CLOSED,
Till.q.branchID == sysparam(conn).CURRENT_BRANCH.id)
result = Till.select(query, connection=conn)
return result.count() and result[-1] or None
else:
# Let's only show pushed testing/stable updates
query.append(PackageUpdate.q.pushed == True)
title.append(status.title())
else:
query.append(PackageUpdate.q.pushed == True)
if submitter:
query.append(PackageUpdate.q.submitter == submitter)
title.append("submitted by %s" % submitter)
if builds:
query.append(PackageUpdate.q.builds == builds)
title.append("for %s" % builds)
updates = PackageUpdate.select(AND(*query), orderBy=order).reversed()
for update in updates:
delta = datetime.utcnow() - update.date_submitted
if delta and delta.days > config.get('feeds.num_days_to_show'):
if len(entries) >= config.get('feeds.max_entries'):
break
entries.append({
'id' : config.get('base_address') + url(update.get_url()),
'summary' : update.notes,
'published' : date(update),
'link' : config.get('base_address') + url(update.get_url()),
'title' : "%s %sUpdate: %s" % (update.release.long_name,
update.type == 'security'
and 'Security ' or '',
update.title)
})
def _parse_number_interval_state(self, state, table_field):
queries = []
if state.start is not None:
queries.append(table_field >= state.start)
if state.end is not None:
queries.append(table_field <= state.end)
if queries:
return AND(*queries)
def get_extra_query(self):
"""Hook called by SearchBar"""
q1 = BaseSellableInfo.q.id == AbstractSellable.q.base_sellable_infoID
q2 = AbstractSellable.get_available_sellables_query(self.conn)
return AND(q1, q2)