Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@defer.inlineCallbacks
def test_FilterMerge(self):
self.assertEqual(qf.sort(qf.ASCENDING('x') + qf.DESCENDING('y')),
qf.sort(qf.ASCENDING('x')) + qf.sort(qf.DESCENDING('y')))
comment = "hello world"
yield self.db.command("profile", 2)
yield self.coll.find({}, filter=qf.sort(qf.ASCENDING('x')) + qf.comment(comment))
yield self.db.command("profile", 0)
if (yield self.__3_6_or_higher()):
profile_filter = {"command.sort.x": 1, "command.comment": comment}
elif (yield self.__3_2_or_higher()):
profile_filter = {"query.sort.x": 1, "query.comment": comment}
else:
profile_filter = {"query.$orderby.x": 1, "query.$comment": comment}
@defer.inlineCallbacks
def test_decrypt_does_not_update_sign_used_for_recipient(self):
# given
km = self._key_manager()
yield km._openpgp.put_raw_key(PRIVATE_KEY, ADDRESS)
yield km._openpgp.put_raw_key(PRIVATE_KEY_2, ADDRESS_2)
encdata = yield km.encrypt('data', ADDRESS, sign=ADDRESS_2,
fetch_remote=False)
yield km.decrypt(
encdata, ADDRESS, verify=ADDRESS_2, fetch_remote=False)
# when
key = yield km.get_key(
ADDRESS, private=False, fetch_remote=False)
# then
self.assertEqual(False, key.sign_used)
@defer.inlineCallbacks
def test_middleware(self):
with self._middleware() as mw:
_ = yield mw.process_request(self.request, self.spider)
assert _ is None
yield mw.process_response(self.request, self.response, self.spider)
response = yield mw.process_request(self.request, self.spider)
assert isinstance(response, HtmlResponse)
self.assertEqualResponse(self.response, response)
assert 'cached' in response.flags
@inlineCallbacks
def command_deleteLocation(self, command):
txn = self.store.newTransaction()
uid = command['GeneratedUID']
yield txn.enqueue(PrincipalPurgeWork, uid=uid)
yield txn.commit()
yield self._delete("locations", command)
@defer.inlineCallbacks
def _check_vm_pre(self, cmd, name, destination_hostname, destination_vms):
try:
yield self._get_vm(destination_vms, name)
self._action_log(cmd, 'Failed migration of %s to %s: destination already contains this VM'
% (name, destination_hostname))
defer.returnValue(False)
except OperationRemoteError:
defer.returnValue(True)
@defer.inlineCallbacks
def list_objects(self, prefix=''):
yield self._chunks_lock.acquire()
try:
if self._chunks is None:
yield self._chunks_find()
finally: self._chunks_lock.release()
defer.returnValue(
self.build_listing(self.folder_name, prefix, list(
item for key, item in self._chunks.viewitems()
if key != item.backend_id\
and (not prefix or key.startswith(prefix)) )) )
@inlineCallbacks
def login(self):
"""Login to Neutron.
Client normally handles logins transparently. So it's not
recommended that login be explicitely called for most usages.
"""
if self._token:
returnValue(None)
body = {}
body["auth"] = {}
body["auth"]["tenantName"] = self.project_id
body["auth"]["passwordCredentials"] = {}
body["auth"]["passwordCredentials"]["username"] = self.username
body["auth"]["passwordCredentials"]["password"] = self.password
@inlineCallbacks
def _assert_nonleadership(self, leader_id):
"""(Re-)assert non-leader role"""
# update leader_id anyway
self._set_leader_id(leader_id)
if self.i_am_leader:
self.i_am_leader = False
yield self._just_lost_leadership()
@inlineCallbacks
def get_salons(self):
rows = yield self.database.runQuery(
"SELECT name, conch_emoji, deploy_hours_start, deploy_hours_end, tz, allow_deploys FROM salons"
)
salons = []
for row in rows:
name, conch_emoji, deploy_hours_start, deploy_hours_end, tz, allow_deploys = row
salon = Salon(
name,
conch_emoji,
parse_time(deploy_hours_start),
parse_time(deploy_hours_end),
pytz.timezone(tz),
allow_deploys=allow_deploys,
)
@inlineCallbacks
def logRequest(self, request):
"""
Log an HTTP request.
"""
iostr = StringIO()
iostr.write(">>>> Request start\n\n")
if hasattr(request, "clientproto"):
protocol = "HTTP/{:d}.{:d}".format(request.clientproto[0], request.clientproto[1])
else:
protocol = "HTTP/1.1"
iostr.write("{} {} {}\n".format(request.method, request.uri, protocol))
for name, valuelist in request.headers.getAllRawHeaders():
for value in valuelist:
# Do not log authorization details
if name not in ("Authorization",):