Permalink
Browse files

Removed the tabs from the only other files that had them.

  • Loading branch information...
1 parent 23ff356 commit b290008062e94dbb5d1b5546fe32b52a83c08405 walsh159 committed Jan 13, 2010
Showing with 149 additions and 149 deletions.
  1. +15 −15 boto/contrib/ymlmessage.py
  2. +128 −128 boto/fps/connection.py
  3. +6 −6 boto/mturk/connection.py
View
@@ -29,24 +29,24 @@
import yaml
class YAMLMessage(Message):
- """
- The YAMLMessage class provides a YAML compatible message. Encoding and
- decoding are handled automaticaly.
+ """
+ The YAMLMessage class provides a YAML compatible message. Encoding and
+ decoding are handled automaticaly.
- Access this message data like such:
+ Access this message data like such:
- m.data = [ 1, 2, 3]
- m.data[0] # Returns 1
+ m.data = [ 1, 2, 3]
+ m.data[0] # Returns 1
- This depends on the PyYAML package
- """
+ This depends on the PyYAML package
+ """
- def __init__(self, queue=None, body='', xml_attrs=None):
- self.data = None
- Message.__init__(self, queue, body)
+ def __init__(self, queue=None, body='', xml_attrs=None):
+ self.data = None
+ Message.__init__(self, queue, body)
- def set_body(self, body):
- self.data = yaml.load(body)
+ def set_body(self, body):
+ self.data = yaml.load(body)
- def get_body(self):
- return yaml.dump(self.data)
+ def get_body(self):
+ return yaml.dump(self.data)
View
@@ -32,142 +32,142 @@
class FPSConnection(AWSQueryConnection):
- APIVersion = '2007-01-08'
- SignatureVersion = '1'
+ APIVersion = '2007-01-08'
+ SignatureVersion = '1'
- def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
- is_secure=True, port=None, proxy=None, proxy_port=None,
- host='fps.sandbox.amazonaws.com', debug=0,
- https_connection_factory=None):
- AWSQueryConnection.__init__(self, aws_access_key_id,
- aws_secret_access_key,
- is_secure, port, proxy, proxy_port,
- host, debug, https_connection_factory)
-
- def install_payment_instruction(self, instruction, token_type="Unrestricted", transaction_id=None):
- """
- InstallPaymentInstruction
- instruction: The PaymentInstruction to send, for example:
-
- MyRole=='Caller' orSay 'Roles do not match';
-
- token_type: Defaults to "Unrestricted"
- transaction_id: Defaults to a new ID
- """
+ def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
+ is_secure=True, port=None, proxy=None, proxy_port=None,
+ host='fps.sandbox.amazonaws.com', debug=0,
+ https_connection_factory=None):
+ AWSQueryConnection.__init__(self, aws_access_key_id,
+ aws_secret_access_key,
+ is_secure, port, proxy, proxy_port,
+ host, debug, https_connection_factory)
+
+ def install_payment_instruction(self, instruction, token_type="Unrestricted", transaction_id=None):
+ """
+ InstallPaymentInstruction
+ instruction: The PaymentInstruction to send, for example:
+
+ MyRole=='Caller' orSay 'Roles do not match';
+
+ token_type: Defaults to "Unrestricted"
+ transaction_id: Defaults to a new ID
+ """
- if(transaction_id == None):
- transaction_id = uuid.uuid4()
- params = {}
- params['PaymentInstruction'] = instruction
- params['TokenType'] = token_type
- params['CallerReference'] = transaction_id
- response = self.make_request("InstallPaymentInstruction", params)
- return response
-
- def install_caller_instruction(self, token_type="Unrestricted", transaction_id=None):
- """
- Set us up as a caller
- This will install a new caller_token into the FPS section.
- This should really only be called to regenerate the caller token.
- """
- response = self.install_payment_instruction("MyRole=='Caller';", token_type=token_type, transaction_id=transaction_id)
- body = response.read()
- if(response.status == 200):
- rs = ResultSet()
- h = handler.XmlHandler(rs, self)
- xml.sax.parseString(body, h)
- caller_token = rs.TokenId
- try:
- boto.config.save_system_option("FPS", "caller_token", caller_token)
- except(IOError):
- boto.config.save_user_option("FPS", "caller_token", caller_token)
- return caller_token
- else:
- raise FPSResponseError(response.status, respons.reason, body)
+ if(transaction_id == None):
+ transaction_id = uuid.uuid4()
+ params = {}
+ params['PaymentInstruction'] = instruction
+ params['TokenType'] = token_type
+ params['CallerReference'] = transaction_id
+ response = self.make_request("InstallPaymentInstruction", params)
+ return response
+
+ def install_caller_instruction(self, token_type="Unrestricted", transaction_id=None):
+ """
+ Set us up as a caller
+ This will install a new caller_token into the FPS section.
+ This should really only be called to regenerate the caller token.
+ """
+ response = self.install_payment_instruction("MyRole=='Caller';", token_type=token_type, transaction_id=transaction_id)
+ body = response.read()
+ if(response.status == 200):
+ rs = ResultSet()
+ h = handler.XmlHandler(rs, self)
+ xml.sax.parseString(body, h)
+ caller_token = rs.TokenId
+ try:
+ boto.config.save_system_option("FPS", "caller_token", caller_token)
+ except(IOError):
+ boto.config.save_user_option("FPS", "caller_token", caller_token)
+ return caller_token
+ else:
+ raise FPSResponseError(response.status, respons.reason, body)
- def install_recipient_instruction(self, token_type="Unrestricted", transaction_id=None):
- """
- Set us up as a Recipient
- This will install a new caller_token into the FPS section.
- This should really only be called to regenerate the recipient token.
- """
- response = self.install_payment_instruction("MyRole=='Recipient';", token_type=token_type, transaction_id=transaction_id)
- body = response.read()
- if(response.status == 200):
- rs = ResultSet()
- h = handler.XmlHandler(rs, self)
- xml.sax.parseString(body, h)
- recipient_token = rs.TokenId
- try:
- boto.config.save_system_option("FPS", "recipient_token", recipient_token)
- except(IOError):
- boto.config.save_user_option("FPS", "recipient_token", recipient_token)
+ def install_recipient_instruction(self, token_type="Unrestricted", transaction_id=None):
+ """
+ Set us up as a Recipient
+ This will install a new caller_token into the FPS section.
+ This should really only be called to regenerate the recipient token.
+ """
+ response = self.install_payment_instruction("MyRole=='Recipient';", token_type=token_type, transaction_id=transaction_id)
+ body = response.read()
+ if(response.status == 200):
+ rs = ResultSet()
+ h = handler.XmlHandler(rs, self)
+ xml.sax.parseString(body, h)
+ recipient_token = rs.TokenId
+ try:
+ boto.config.save_system_option("FPS", "recipient_token", recipient_token)
+ except(IOError):
+ boto.config.save_user_option("FPS", "recipient_token", recipient_token)
- return recipient_token
- else:
- raise FPSResponseError(response.status, respons.reason, body)
+ return recipient_token
+ else:
+ raise FPSResponseError(response.status, respons.reason, body)
- def make_url(self, returnURL, paymentReason, pipelineName, **params):
- """
- Generate the URL with the signature required for a transaction
- """
- params['callerKey'] = str(self.aws_access_key_id)
- params['returnURL'] = str(returnURL)
- params['paymentReason'] = str(paymentReason)
- params['pipelineName'] = pipelineName
+ def make_url(self, returnURL, paymentReason, pipelineName, **params):
+ """
+ Generate the URL with the signature required for a transaction
+ """
+ params['callerKey'] = str(self.aws_access_key_id)
+ params['returnURL'] = str(returnURL)
+ params['paymentReason'] = str(paymentReason)
+ params['pipelineName'] = pipelineName
- if(not params.has_key('callerReference')):
- params['callerReference'] = str(uuid.uuid4())
+ if(not params.has_key('callerReference')):
+ params['callerReference'] = str(uuid.uuid4())
- url = ""
- keys = params.keys()
- keys.sort()
- for k in keys:
- url += "&%s=%s" % (k, urllib.quote_plus(str(params[k])))
+ url = ""
+ keys = params.keys()
+ keys.sort()
+ for k in keys:
+ url += "&%s=%s" % (k, urllib.quote_plus(str(params[k])))
- url = "/cobranded-ui/actions/start?%s" % ( url[1:])
- signature= boto.utils.encode(self.aws_secret_access_key, url, True)
- return "https://authorize.payments-sandbox.amazon.com%s&awsSignature=%s" % (url, signature)
+ url = "/cobranded-ui/actions/start?%s" % ( url[1:])
+ signature= boto.utils.encode(self.aws_secret_access_key, url, True)
+ return "https://authorize.payments-sandbox.amazon.com%s&awsSignature=%s" % (url, signature)
- def make_payment(self, amount, sender_token, charge_fee_to="Recipient", reference=None, senderReference=None, recipientReference=None, senderDescription=None, recipientDescription=None, callerDescription=None, metadata=None, transactionDate=None):
- """
- Make a payment transaction
- You must specify the amount and the sender token.
- """
- params = {}
- params['RecipientTokenId'] = boto.config.get("FPS", "recipient_token")
- params['CallerTokenId'] = boto.config.get("FPS", "caller_token")
- params['SenderTokenId'] = sender_token
- params['TransactionAmount.Amount'] = str(amount)
- params['TransactionAmount.CurrencyCode'] = "USD"
- params['ChargeFeeTo'] = charge_fee_to
+ def make_payment(self, amount, sender_token, charge_fee_to="Recipient", reference=None, senderReference=None, recipientReference=None, senderDescription=None, recipientDescription=None, callerDescription=None, metadata=None, transactionDate=None):
+ """
+ Make a payment transaction
+ You must specify the amount and the sender token.
+ """
+ params = {}
+ params['RecipientTokenId'] = boto.config.get("FPS", "recipient_token")
+ params['CallerTokenId'] = boto.config.get("FPS", "caller_token")
+ params['SenderTokenId'] = sender_token
+ params['TransactionAmount.Amount'] = str(amount)
+ params['TransactionAmount.CurrencyCode'] = "USD"
+ params['ChargeFeeTo'] = charge_fee_to
- if(transactionDate != None):
- params['TransactionDate'] = transactionDate
- if(senderReference != None):
- params['SenderReference'] = senderReference
- if(recipientReference != None):
- params['RecipientReference'] = recipientReference
- if(senderDescription != None):
- params['SenderDescription'] = senderDescription
- if(recipientDescription != None):
- params['RecipientDescription'] = recipientDescription
- if(callerDescription != None):
- params['CallerDescription'] = callerDescription
- if(metadata != None):
- params['MetaData'] = metadata
- if(transactionDate != None):
- params['TransactionDate'] = transactionDate
- if(reference == None):
- reference = uuid.uuid4()
- params['CallerReference'] = reference
+ if(transactionDate != None):
+ params['TransactionDate'] = transactionDate
+ if(senderReference != None):
+ params['SenderReference'] = senderReference
+ if(recipientReference != None):
+ params['RecipientReference'] = recipientReference
+ if(senderDescription != None):
+ params['SenderDescription'] = senderDescription
+ if(recipientDescription != None):
+ params['RecipientDescription'] = recipientDescription
+ if(callerDescription != None):
+ params['CallerDescription'] = callerDescription
+ if(metadata != None):
+ params['MetaData'] = metadata
+ if(transactionDate != None):
+ params['TransactionDate'] = transactionDate
+ if(reference == None):
+ reference = uuid.uuid4()
+ params['CallerReference'] = reference
- response = self.make_request("Pay", params)
- body = response.read()
- if(response.status == 200):
- rs = ResultSet()
- h = handler.XmlHandler(rs, self)
- xml.sax.parseString(body, h)
- return rs
- else:
- raise FPSResponseError(response.status, response.reason, body)
+ response = self.make_request("Pay", params)
+ body = response.read()
+ if(response.status == 200):
+ rs = ResultSet()
+ h = handler.XmlHandler(rs, self)
+ xml.sax.parseString(body, h)
+ return rs
+ else:
+ raise FPSResponseError(response.status, response.reason, body)
View
@@ -317,12 +317,12 @@ def expire_hit(self, hit_id):
"""
Expire a HIT that is no longer needed.
- The effect is identical to the HIT expiring on its own. The HIT no longer appears on the
- Mechanical Turk web site, and no new Workers are allowed to accept the HIT. Workers who
- have accepted the HIT prior to expiration are allowed to complete it or return it, or
- allow the assignment duration to elapse (abandon the HIT). Once all remaining assignments
- have been submitted, the expired HIT becomes "reviewable", and will be returned by a call
- to GetReviewableHITs.
+ The effect is identical to the HIT expiring on its own. The HIT no longer appears on the
+ Mechanical Turk web site, and no new Workers are allowed to accept the HIT. Workers who
+ have accepted the HIT prior to expiration are allowed to complete it or return it, or
+ allow the assignment duration to elapse (abandon the HIT). Once all remaining assignments
+ have been submitted, the expired HIT becomes "reviewable", and will be returned by a call
+ to GetReviewableHITs.
"""
params = {'HITId' : hit_id,}
return self._process_request('ForceExpireHIT', params)

0 comments on commit b290008

Please sign in to comment.