我收到以下错误:
File "/Users/tai/Desktop/FlashY/flashy/sniffer/database.py", line 21, in <module>
import dynamoStorage
File "/Users/tai/Desktop/FlashY/flashy/sniffer/dynamoStorage.py", line 37, in <module>
swfTable = Table(decompiled_dynamo_table, connection=dynamoConn)
File "/Library/Python/2.7/site-packages/boto/dynamodb2/table.py", line 107, in __init__
self.connection = DynamoDBConnection()
File "/Library/Python/2.7/site-packages/boto/dynamodb2/layer1.py", line 183, in __init__
super(DynamoDBConnection, self).__init__(**kwargs)
File "/Library/Python/2.7/site-packages/boto/connection.py", line 1073, in __init__
profile_name=profile_name)
File "/Library/Python/2.7/site-packages/boto/connection.py", line 572, in __init__
host, config, self.provider, self._required_auth_capability())
File "/Library/Python/2.7/site-packages/boto/auth.py", line 883, in get_auth_handler
'Check your credentials' % (len(names), str(names)))
boto.exception.NoAuthHandlerFound: No handler was ready to authenticate. 1 handlers were checked. ['HmacAuthV4Handler'] Check your credentials
当我直接在文件中使用auth时,我的按键有效,所以我知道按键是正确的。
我有awsAccess.py:
#aswAccess holds the names of the bash environment set keys.
#used by other classes to create a connection to aws
aws_access_key_id=os.getenv('AWS_ACCESS_KEY');
aws_secret_access_key=os.getenv('AWS_SECRET_KEY');
aws_dynamo_region=os.getenv('DYANAMO_REGION')
我有database.py
#for connecting to aws
aws_access_key_id=awsAccess.aws_access_key_id
aws_secret_access_key=awsAccess.aws_secret_access_key
aws_dynamo_region=awsAccess.aws_dynamo_region
aws_dynamo_table="decompiled_swf_text"
conn= S3Connection(aws_access_key_id,aws_secret_access_key);
dynamoConn = boto.connect_dynamodb(aws_access_key_id, aws_secret_access_key)
dTable = dynamoConn.get_table(aws_dynamo_table)
所以我知道钥匙本身是正确的。
我有一个.bash_profile文件看起来像这样(**表示已删除,我也尝试使用和不使用&#34;&#34;&#39; s):
export AWS_ACCESS_KEY="myAccessKey**"
export AWS_SECRET_KEY="mySecretKey**"
export DYNAMO_REGION="us-east"
我运行source~ / .bash_profile,然后尝试运行但得到错误。我无法理解为什么导入会改变相同键字符串的影响。
答案 0 :(得分:3)
几点提示:
boto.connect_<something>
删除身份验证参数。这将允许boto
使用内置的身份验证处理程序,这些将尝试读取文件,检查环境变量等。您将使代码更简单,同时仍然能够提供{{1}中任何一个所需的所有内容。验证方法。boto
)并将boto.cfg
环境变量设置为此文件的完整路径,例如到'&#34; /home/javl/.boto/boto.cfg" BOTO_CONFIG
的{{1}},则boto.connect_<something>
会检查其他方法以查找值。null
,允许在boto配置文件中引用特定的配置文件。这让我可以在代码中的任何地方切换到不同的配置文件。有关更多提示和详细信息,请参阅related SO answer
答案 1 :(得分:0)