小编Cha*_*rts的帖子

mkvirtualenv:符号链接的级别太多

我正在运行virtualenv卷饼并得到一个错误,即有太多级别的符号链接.我不知道这意味着什么.

mkvirtualenv --python /usr/local/bin/Python3 mantis
Run Code Online (Sandbox Code Playgroud)

错误:

Running virtualenv with interpreter /usr/local/bin/Python3
Using base prefix '/Library/Frameworks/Python.framework/Versions/3.4'
New python executable in mantis/bin/Python3
Also creating executable in mantis/bin/python
Traceback (most recent call last):
  File "/Users/croberts/.venvburrito/lib/python2.7/site-packages/virtualenv.py", line 2352, in <module>
    main()
  File "/Users/croberts/.venvburrito/lib/python2.7/site-packages/virtualenv.py", line 825, in main
    symlink=options.symlink)
  File "/Users/croberts/.venvburrito/lib/python2.7/site-packages/virtualenv.py", line 985, in create_environment
    site_packages=site_packages, clear=clear, symlink=symlink))
  File "/Users/croberts/.venvburrito/lib/python2.7/site-packages/virtualenv.py", line 1439, in install_python
    raise e
  File "/Users/croberts/.venvburrito/lib/python2.7/site-packages/virtualenv.py", line 1431, in install_python
    stdout=subprocess.PIPE)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/subprocess.py", line 859, in __init__
    restore_signals, start_new_session)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/subprocess.py", …
Run Code Online (Sandbox Code Playgroud)

virtualenv virtualenvwrapper

29
推荐指数
4
解决办法
3万
查看次数

Django App配置不当 - 应用程序模块有多个文件系统位置

我想我真的搞砸了.在我的django应用程序(生产一个)上,我推了一个重大更新,每当我尝试进入我的域时就会出现"内部服务器错误".我在uwsgi日志中收到错误:

*** Starting uWSGI 2.0.8 (64bit) on [Thu Jan 29 00:36:43 2015] ***
compiled with version: 4.8.2 on 11 December 2014 17:29:38
os: Linux-3.13.0-41-generic #70-Ubuntu SMP Tue Nov 25 14:40:34 UTC 2014
nodename: ip-172-31-9-208
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /
detected binary path: /usr/local/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root …
Run Code Online (Sandbox Code Playgroud)

django uwsgi

22
推荐指数
1
解决办法
8888
查看次数

Firebase无法获取APNS令牌错误域= com.firebase.iid代码= 1001"(null)"

2016-08-22 18:34:50.108: <FIRInstanceID/WARNING> FIRInstanceID AppDelegate proxy enabled, will swizzle app delegate remote notification handlers. To disable add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
2016-08-22 18:34:50.106 YAKKO[4269:] <FIRAnalytics/INFO> To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see ...)
2016-08-22 18:34:50.114: <FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(null)"
2016-08-22 18:34:50.120: <FIRMessaging/INFO> FIRMessaging library version 1.1.1
2016-08-22 18:34:50.125: <FIRMessaging/WARNING> FIRMessaging AppDelegate proxy enabled, will swizzle app delegate remote notification receiver handlers. Add "FirebaseAppDelegateProxyEnabled" to your …
Run Code Online (Sandbox Code Playgroud)

ios firebase firebase-cloud-messaging

13
推荐指数
1
解决办法
6071
查看次数

iText,Font,BaseFont和createFont()发生了什么?

关于font和basefont发生了什么,我有很多神秘感.特别是在构造函数方面.iText网站将此行作为新字体的示例代码

 BaseFont unicode = BaseFont.createFont("c:/windows/fonts/arialuni.ttf", 
                        BaseFont.IDENTITY_H, 
                        BaseFont.EMBEDDED);
Run Code Online (Sandbox Code Playgroud)

我可以接听这个电话:

BaseFont bf = BaseFont.createFont(BaseFont.COURIER, BaseFont.CP1257, 
                  BaseFont.EMBEDDED);
Run Code Online (Sandbox Code Playgroud)

但是,如果我用BaseFont.HELVETICA替换BaseFont.CP1257然后它不起作用,我得到一个页面,上面写着"无法加载pdf文档".

我尝试查看类文件,我似乎无法弄清楚第二个参数是什么(我假设它是类似于备份字体,如果第一个字体不起作用,如HTML),我可以弄清楚为什么有些字体会起作用而不是其他字体.

itext

11
推荐指数
2
解决办法
3万
查看次数

使用信号时django TransactionManagementError

我与django的用户和UserInfo有一对一的字段.我想订阅用户模型上的post_save回调函数,以便我可以保存UserInfo.

@receiver(post_save, sender=User) 
def saveUserAndInfo(sender, instance, **kwargs):
    user = instance
    try:
        user.user_info.save()
    except:
        info = UserInfo()
        info.user = user
        info.save()
Run Code Online (Sandbox Code Playgroud)

但是,TransactionManagementError当我尝试这样做时,我得到了一个.我假设因为用户模型还没有完成保存,我正在尝试读取id以将其保存到user_info.谁知道如何正确地做到这一点?

第二个问题.我想在创建用户后立即将UserInfo实例附加到用户.所以在post_init上我尝试创建一个UserInfo实例并将其分配给用户实例,但它不起作用,因为尚未为用户分配pk.我假设我只需要等到post_save(或更高版本)来创建此实例.这是唯一的方法吗?

追溯:

File "/Users/croberts/.virtualenvs/lunchbox/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  114.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/croberts/.virtualenvs/lunchbox/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper
  430.                 return self.admin_site.admin_view(view)(*args, **kwargs)
File "/Users/croberts/.virtualenvs/lunchbox/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  99.                     response = view_func(request, *args, **kwargs)
File "/Users/croberts/.virtualenvs/lunchbox/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  52.         response = view_func(request, *args, **kwargs)
File "/Users/croberts/.virtualenvs/lunchbox/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner
  198.             return view(request, *args, **kwargs)
File "/Users/croberts/.virtualenvs/lunchbox/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
  29.             return bound_func(*args, **kwargs) …
Run Code Online (Sandbox Code Playgroud)

python django django-models

11
推荐指数
1
解决办法
1万
查看次数

AUTH_USER_MODEL 指尚未安装的型号

我收到错误

ImproperlyConfigured at /admin/
AUTH_USER_MODEL refers to model 'ledger.User' that has not been installed
Run Code Online (Sandbox Code Playgroud)

我只在我的生产服务器上获取它。当我通过本地主机运行时则不然。首先,只有当我提出某个要求时。然后我认为我的数据库一定不同步,所以我删除了所有表,然后运行manage.pysyncdb。现在,它似乎已经传播,甚至到管理员那里也会抛出错误。

我以前从未见过这个错误,无法弄清楚这是什么交易。我在settings.py中定义了AUTH_USER_MODEL:

...
INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'ledger',
    'extension',
    'plugin',
    'social.apps.django_app.default',
)

AUTH_USER_MODEL = 'ledger.User'

...
Run Code Online (Sandbox Code Playgroud)

模型.py:

...
class User(AbstractUser):
    def __unicode__(self):
        return self.username
    balance = models.IntegerField(default=0)
    total_pledged = models.IntegerField(default=0)
    last_pledged = models.ForeignKey('Transaction', related_name='pledger', blank=True, null=True)
    extension_key = models.CharField(max_length=100, null=True, blank=True)
    plugin_key = models.CharField(max_length=100, null=True, blank=True)
    ghosted = models.BooleanField(default=False)

    def save(self, *args, **kwargs):
        print('saving')
        try:
            self.company.save()
        except:
            print('no company')
        super(User, self).save(*args, …
Run Code Online (Sandbox Code Playgroud)

python django django-authentication django-settings

11
推荐指数
2
解决办法
3万
查看次数

使用minimumScaleFactor时,UIButton titleLabel不会垂直居中

我有一个UIButton,文本在按钮中居中,直到文本字符串变长,并开始缩小文本的大小.然后文本似乎粘在textField的底部而不是保持在按钮的中心.

self.titleBtn.titleLabel.adjustsFontSizeToFitWidth = YES;
self.titleBtn.titleLabel.minimumScaleFactor = .2;

[self.descriptionBtn setTitle:@"T" forState:UIControlStateNormal]; 
//works normally
Run Code Online (Sandbox Code Playgroud)

[self.descriptionBtn setTitle:@"This a longer title" forState:UIControlStateNormal];
//is vertically lower than center
Run Code Online (Sandbox Code Playgroud)

uibutton ios

10
推荐指数
2
解决办法
2824
查看次数

PIL在图像上绘制半透明方形叠加

from PIL import Image
from PIL import ImageDraw 
from io import BytesIO
from urllib.request import urlopen

url = "https://i.ytimg.com/vi/W4qijIdAPZA/maxresdefault.jpg"
file = BytesIO(urlopen(url).read())
img = Image.open(file)
img = img.convert("RGBA")
draw = ImageDraw.Draw(img, "RGBA")
draw.rectangle(((0, 00), (img.size[0], img.size[1])), fill=(0,0,0,127))
img.save('dark-cat.jpg')
Run Code Online (Sandbox Code Playgroud)

这给了我一个巨大的黑色方块.我希望它是一个带有猫的半透明黑色方形.有任何想法吗?

python python-imaging-library python-3.x pillow

10
推荐指数
2
解决办法
5585
查看次数

个人资料图片或头像的电子邮件标题?

我正在使用 python mailjet api,发现我可以设置发件人的姓名,这样我就可以让它们从“Carlos”显示,而不是从“Info”(info@example.com)显示电子邮件。我还想添加一张像西南航空或 Twitter 那样的个人资料图片。

在此输入图像描述

有人知道我该怎么做吗?

我知道如果我不发布代码人们就会生气,所以这里有一些代码:

mailjet = Client(auth=(API_KEY, API_PASSWORD), version='v3.1')
data = {
    'Messages': [
        {
            "From": {
                "Email": "info@example.com",
                "Name": "Carlos"
            },
            "To": [
                {
                    "Email": trip.email
                }
            ],
            "Subject": "Subject of the message",
            "TextPart":"This is the body of the message",
            "Headers": {
                    "X-My-Header": "https://www.example.com/profile_pic.png"
            }
        }
    ]
}
mailjet.send.create(data=data)
Run Code Online (Sandbox Code Playgroud)

python email email-headers mailjet

10
推荐指数
1
解决办法
4484
查看次数

Instagram如何使用django?

我不知道这是否是一个正确的问题.我读到Instagram使用django这是一个python web框架.但Instagram是iOS应用程序.iOS应用程序不是用目标c编写的吗?Instagram使用django是什么意思?

django instagram

8
推荐指数
1
解决办法
2万
查看次数