小编Nav*_*een的帖子

使用Google Compute Engine时,"EntryPoint"对象没有属性"resolve"

我有一个与Python中的Cryptography包相关的问题.如果可能的话,你能帮忙解决这些问题吗?(尝试了很多,但无法找出确切的解决方案)

启动此错误的python代码:

print("Salt: %s" % salt)
server_key = pyelliptic.ECC(curve="prime256v1")  # ----->> Line2
print("Server_key: %s" % server_key)   # ----->> Line3
server_key_id = base64.urlsafe_b64encode(server_key.get_pubkey()[1:])

http_ece.keys[server_key_id] = server_key
http_ece.labels[server_key_id] = "P-256"
encrypted = http_ece.encrypt(data, salt=salt, keyid=server_key_id,
            dh=self.receiver_key, authSecret=self.auth_key)  # ----->> Line8
Run Code Online (Sandbox Code Playgroud)

"盐"的值在100%的情况下显示.

如果Line3成功执行,由于http_ece.encrypt()调用(Line8),我看到以下入口点错误:

AttributeError("'EntryPoint' object has no attribute 'resolve'",)
Run Code Online (Sandbox Code Playgroud)

(参考文件链接:https://github.com/martinthomson/encrypted-content-encoding/blob/master/python/http_ece/init.py#L128)

Requirements.txt(部分):

cryptography==1.5
pyelliptic==1.5.7
pyOpenSSL==16.1.0
Run Code Online (Sandbox Code Playgroud)

在运行命令:sudo pip freeze --all |grep setuptools,我得到: setuptools==27.1.2

如果需要更多细节,请告诉我.

这个问题似乎是基本上是由于安装在VM中的一些旧的/不兼容包(与PyElliptic,密码学,PyOpenSSL和/或setuptools的).供参考:https://github.com/pyca/cryptography/issues/3149

有人可以建议一个很好的解决方案来完全解决这个问题吗?

谢谢,

python django cryptography google-compute-engine

9
推荐指数
1
解决办法
680
查看次数

gcloud.exceptions.Forbidden:403权限丢失或不足

我是Google云端平台的新手.我已经设置了Google VM实例.运行命令时,我在Local Machine上遇到身份验证问题:

python manage.py makemigrations

你能否提出一些建议/步骤来解决这个问题?

错误跟踪

  File "/constants.py", line 18, in <module>
    table_data = datastore_fetch(project_id, entity_kind)
  File "/datastore_helper.py", line 23, in datastore_fetch
    results = list(query.fetch())
  File "/venv/local/lib/python2.7/site-packages/gcloud/datastore/query.py", line 463, in __iter__
    self.next_page()
  File "/venv/local/lib/python2.7/site-packages/gcloud/datastore/query.py", line 434, in next_page
    transaction_id=transaction and transaction.id,
  File "/venv/local/lib/python2.7/site-packages/gcloud/datastore/connection.py", line 286, in run_query
    _datastore_pb2.RunQueryResponse)
  File "/venv/local/lib/python2.7/site-packages/gcloud/datastore/connection.py", line 124, in _rpc
    data=request_pb.SerializeToString())
  File "/venv/local/lib/python2.7/site-packages/gcloud/datastore/connection.py", line 98, in _request
    raise make_exception(headers, error_status.message, use_json=False)
gcloud.exceptions.Forbidden: 403 Missing or insufficient permissions.
Run Code Online (Sandbox Code Playgroud)

其他信息:

gcloud auth list
Credentialed Accounts:
 - …
Run Code Online (Sandbox Code Playgroud)

python django google-cloud-storage google-cloud-datastore google-cloud-platform

6
推荐指数
2
解决办法
5906
查看次数

Amazon Rekognition API-S3元数据问题

我正在尝试使用AWS Image Rekognition API检测图像中的面部。但是出现以下错误:

错误1:

ClientError: An error occurred (InvalidS3ObjectException) when calling the DetectFaces operation: Unable to get image metadata from S3.  Check object key, region and/or access permissions.
Run Code Online (Sandbox Code Playgroud)

Python代码1:

def detect_faces(object_name="path/to/image/001.jpg"):
    client = get_aws_client('rekognition')

    response = client.detect_faces(
        Image={
            # 'Bytes': source_bytes,
            'S3Object': {
                'Bucket': "bucket-name",
                'Name': object_name,
                'Version': 'string'
            }
        },
        Attributes=[
            'ALL',
        ]
    )

    return response
Run Code Online (Sandbox Code Playgroud)

对象“ path / to / image / 001.jpg”存在于AWS S3存储桶“存储桶名称”中。并且区域名称也正确。

该对象'001.jpg'的权限是:每个人都被授予打开/下载/查看权限。对象的元数据:内容类型:image / jpeg

不知道如何调试它。有什么建议解决这个问题吗?

谢谢,

python metadata amazon-s3 amazon-web-services

5
推荐指数
1
解决办法
2127
查看次数

从 Google Cloud Storage Bucket 提供静态文件(适用于托管在 GCE 上的 Django 应用程序)

我正在尝试从 Cloud Storage Bucket 为我的 django 应用程序提供静态文件,但不知道确切的过程。有人可以建议这样做的正确方法吗?

我做的步骤:

  1. 使用 gsutil 命令上传 Google Cloud Storage Bucket(www.example.com) 上的所有静态文件。
  2. 编辑的/etc/apache2/sites-available/default-ssl.conf文件。

文件内容:

<VirtualHost *:443>
        ServerName example.com
        ServerAdmin admin@example.com

 #       Alias /static /opt/projects/example-google/example_static
        Alias /static https://storage.googleapis.com/www.example.com/static
        <Directory /opt/projects/example-google/example_static>
           Require all granted
        </Directory>

        <Directory /opt/projects/example-google/example/example>
            <Files wsgi.py>
                Require all granted
            </Files>
        </Directory>

        WSGIDaemonProcess example python-path=/opt/projects/example-google/example:/opt/projects/example-google/venv/lib/python2.7/site-packages
        WSGIProcessGroup example
WSGIApplicationGroup %{GLOBAL}
        WSGIScriptAlias / /opt/projects/example-google/example/example/wsgi.py

        SSLEngine on
        SSLCertificateFile  /etc/apache2/ssl/example.com.crt
        SSLCertificateKeyFile /etc/apache2/ssl/example.com.key
        SSLCertificateChainFile /etc/apache2/ssl/intermediate.crt
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

设置.py文件:

# Static files (CSS, JavaScript, Images)
STATIC_URL = '/static/'
# STATIC_URL = …
Run Code Online (Sandbox Code Playgroud)

python django static django-staticfiles google-cloud-storage

4
推荐指数
2
解决办法
5987
查看次数

在AWS ec2主机上访问Django应用

这个问题看似微不足道,但如果可能,请尝试提出解决方案。我已经在AWS ec2主机上部署了django App,并且能够成功运行以下命令。

(venv)[ec2-user@ip-xxx-xx-xx-xx abc]$ python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
January 03, 2016 - 13:15:31
Django version 1.7.1, using settings 'abc.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Run Code Online (Sandbox Code Playgroud)

但是我无法从浏览器访问http://127.0.0.1:8000/。在谷歌搜索时,建议使用nginx或gunicorn。我不确定是否要使用nginx,gunicorn等。

有人可以让我知道如何从浏览器访问吗?谢谢,

django amazon-ec2 amazon-web-services aws-cli

0
推荐指数
2
解决办法
1716
查看次数

从模板Django中包含静态文件

项目结构:

??? db.sqlite3
??? manage.py
??? static
?   ??? admin
?       ??? css
?       ??? img
?       ??? js
??? abc1
?   ??? admin.py
?   ??? __init__.py
?   ??? migrations
?   ?   ??? __init__.py
?   ??? models.py
?   ??? templates
?   ?   ??? abc1
?   ?       ??? homepage.html
?   ?       ??? css
?   ?       ??? img
?   ?       ??? js
?   ??? tests.py
?   ??? urls.py
?   ??? views.py
??? abc2
    ??? functions.py
    ??? __init__.py
    ??? settings.py
    ??? urls.py
    ??? …
Run Code Online (Sandbox Code Playgroud)

python django django-templates django-admin

0
推荐指数
1
解决办法
582
查看次数