运行时django make messages:
./manage.py makemessages -l pt
Run Code Online (Sandbox Code Playgroud)
我明白了:
CommandError: Can't find msguniq. Make sure you have GNU gettext tools 0.15 or newer installed.
Run Code Online (Sandbox Code Playgroud)
我尝试安装但是我在Instalation Setup中找到的最新版本是0.14.我在哪里可以找到最新版本,如何安装?
我正在使用Django 1.10和Pycharm 2016.2.
在每个Django项目中,manage.py命令都能正常工作,但自动完成会产生以下错误:
Failed to get real commands on module "projects_name" python died with code 1
File opt/Pycharm/helpers/.../jb_manage_tasks_provider.py
File opt/pycharm/helpers.../parser.py
File my virtual env folder/lib/python3.5/site packages/django/core/management/base.py
AttributeError Command object has no attribute 'args'
Run Code Online (Sandbox Code Playgroud)
重新安装Pycharm没有帮助.
搜索了一段时间后,我找到了以下解决方案,用于需要Delete方法的api调用.
首先尝试:(httplib库)
url = '/v1/users/'+ spotify_user_id +'/playlists/'+ playlist_id +'/tracks'
data = json.dumps({"tracks": [{ "uri" : track_uri }]})
headers = {
'Authorization' : 'Bearer ' + access_token,
'Content-Type' : 'application/json'
}
conn = httplib.HTTPSConnection('api.spotify.com')
conn.request('DELETE', url , data, headers)
resp = conn.getresponse()
content = resp.read()
return json.loads(content)
Run Code Online (Sandbox Code Playgroud)
返回:
{u'error':{u'status':400,u'ssssage':u'Empty JSON body.'}}
第二次尝试:(urllib2库)
url = 'https://api.spotify.com/v1/users/'+ spotify_user_id +'/playlists/'+ playlist_id +'/tracks'
data = json.dumps({"tracks": [{ "uri" : track_uri }]})
headers = {
'Authorization' : 'Bearer ' + access_token,
'Content-Type' : 'application/json'
}
opener …Run Code Online (Sandbox Code Playgroud) 我有一个运行 MySQL 5.6.39 的 AWS RDS 数据库,并启用了 IAM 数据库身份验证。
首先,我成功完成了教程:配置 Lambda 函数以访问 Amazon VPC 中的 Amazon RDS,这是我后续步骤的起点。
当我创建 RDS MySQL 实例时,我选择了Enabling IAM database authentication.
创建了一个名为 的用户lambda:
CREATE USER 'lambda' IDENTIFIED WITH AWSAuthenticationPlugin as 'RDS';
GRANT ALL PRIVILEGES ON test_db.* TO 'lambda'@'%';
FLUSH PRIVILEGES;
Run Code Online (Sandbox Code Playgroud)创建了一个 IAM 策略,并将其附加到我用作 lambda 函数的执行角色的角色:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"rds-db:connect"
],
"Resource": [
"<DB-ARN>/lambda"
]
}
]
}
Run Code Online (Sandbox Code Playgroud)创建了一个 lambda …
我使用Python Social Auth - Django登录我的用户.
我的后端是微软,所以我可以使用Microsoft Graph,但我不认为它是相关的.
Python Social Auth处理身份验证,但现在我想调用API,为此,我需要一个有效的访问令牌.根据用例我可以得到:
social = request.user.social_auth.get(provider='azuread-oauth2')
response = self.get_json('https://graph.microsoft.com/v1.0/me',
headers={'Authorization': social.extra_data['token_type'] + ' '
+ social.extra_data['access_token']})
Run Code Online (Sandbox Code Playgroud)
但访问令牌只有3600秒有效,所以我需要刷新,我想我可以手动完成,但必须有一个更好的解决方案.如何刷新access_token?
我正在修改 SQL Server 2016 Management Studio (SSMS) 中的一列并收到错误消息:
您所做的更改需要删除并重新创建以下表
我正在测试,因此删除和重新创建新表没有任何问题。禁用此错误的选项在哪里?
我正在尝试在 Windows 10 Home 中使用 docker。
在安装期间(在 Virtual Box 部分)我收到一个错误:
无法重命名此连接。已存在具有您指定名称的连接。指定不同的名称。
这可以关闭并继续安装。
但是,当我单击快速启动 ( start.sh) 时,出现以下错误:
启动“默认”...(默认)如果需要,请检查网络以重新创建...无法启动 VM:C:\Program Files\Oracle\VirtualBox\VBoxManage.exe startvm default --type headless failed: VBoxManage。 exe:错误:虚拟机“默认”在启动期间意外终止,退出代码为 1 (0x1)。'C:\Users*****.docker\machine\machines\default\default\Logs\VBoxHardening.log VBoxManage.exe:错误:详细信息:代码E_FAIL(0x80004005),组件MachineWrap,界面中可能提供更多详细信息IMachine 看起来在“检查默认状态”步骤中出了点问题...按任意键继续...
这个错误已经是工具箱的一个问题,但对某些人有用的解决方案对我不适用:
.docker 目录(in C:\Users\<user.name>\.docker);我正在尝试使用django-auth-ldap来通过我的 Active Directory 对 Django 中的用户进行身份验证,但没有成功。
我的活动目录有以下树:
我有(在settings.py中):
AUTH_LDAP_SERVER_URI = "ldap://something.test.local"
AUTH_LDAP_BIND_DN = "cn=Administrator,cn=Users,dc=test,dc=local"
AUTH_LDAP_BIND_PASSWORD = "password"
AUTH_LDAP_USER_SEARCH = LDAPSearch("cn=Users,dc=test,dc=local",
ldap.SCOPE_SUBTREE, "(uid=%(user)s)")
Run Code Online (Sandbox Code Playgroud)
我总是得到(在 Django shell 中调试):
>>> from django.contrib.auth import authenticate, login
>>> authenticate(username='test', password='password')
search_s('cn=Users,dc=test,dc=local', 2, '(uid=%(user)s)') returned 0 objects:
Authentication failed for test: failed to map the username to a DN.
Run Code Online (Sandbox Code Playgroud) 我要测试的示例方法:
def example_method(var, optional_var=None):
if optional_var is not None:
raise ExampleException()
Run Code Online (Sandbox Code Playgroud)
我的测试方法:
def test_method(self):
self.assertRaises(ExampleException, example_method, ???)
Run Code Online (Sandbox Code Playgroud)
我应该如何传递参数以引发异常?
在Ubuntu Server 16.04上启动docker-ce(18.06.1-ce,构建e68fc7a)之后,将创建以下内容:
$ ifconfig
docker0 Link encap:Ethernet HWaddr 02:42:fe:36:81:72
inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
Run Code Online (Sandbox Code Playgroud)
不幸的是,我的PC在此网络上。这意味着,一旦docker启动,我将失去与服务器的ssh连接。
几个论坛都说要添加以下内容/etc/docker/daemon.json:
{
"bip": "192.168.1.1/24"
}
Run Code Online (Sandbox Code Playgroud)
一种可行的解决方案正在运行:
sudo ip addr add dev docker0 192.168.1.1/24
sudo ip addr del dev docker0 172.17.0.1/16
Run Code Online (Sandbox Code Playgroud)
资料来源:forums.docker.com
尽管这是一个可能的解决方案,但我必须在docker服务启动后执行此操作。我无法执行某些操作,因为与此同时我失去了连接。
添加-bip到ExecStart行后,尝试启动docker给出(journalctl -xe): …
python ×7
django ×5
amazon-rds ×1
aws-lambda ×1
docker-ce ×1
gettext ×1
gnu ×1
json ×1
ldap ×1
mysql ×1
pycharm ×1
spotify ×1
sql-server ×1
ssms ×1
ssms-2016 ×1
unit-testing ×1
virtualbox ×1
windows ×1