小编use*_*364的帖子

django i18n:确保你有GNU gettext工具

我尝试django-admin.py makemessages -l zh_CN但有错误:

CommandError: Can't find msguniq. Make sure you have GNU gettext tools 0.15 or newer installed.
Run Code Online (Sandbox Code Playgroud)

在我使用brew install gettext之后,它仍然出错了.
我需要做点什么吗?这是我的终端截图
请指导我谢谢.

在此输入图像描述

python django

22
推荐指数
5
解决办法
2万
查看次数

如何获取docker container root的密码

如何获取docker container root的密码?

[root@localhost train02]# docker exec -it jenkins /bin/bash
[jenkins@89d5aa94e6ec /]ls /root
ls:cannot open directory /root: Permission denied
Run Code Online (Sandbox Code Playgroud)

docker

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

Python:如何检测未使用的包并删除它们

pip freeze > requirements.txt用来收集我安装的所有软件包。但是开发了很多天,有些包现在没用了。如何找到这些未使用的包并删除它们,以使我的项目更加清晰?

python package python-2.7 requirements.txt

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

如何将datetime.date.today()转换为UTC时间?

如何确保datetime.date.today() 转换为UTC时间?

到目前为止这是我的代码:

#today : 2014-12-21
today = datetime.date.today()

#1900-01-01 16:00:00+00:00
timeformat = datetime.datetime.strptime('16:00', '%H:%M').replace(tzinfo=pytz.utc)

#combine today and timeformat  2014-12-21 16:00:00
now = datetime.datetime.combine(u, timeformat.time())
str_now =  now.strftime("%Y-%m-%d %H:%M:%S")
Run Code Online (Sandbox Code Playgroud)

python pytz

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

@WebFilter排除url-pattern

我使用过滤器来检查登录用户的URL模式.

但是我需要过滤许多URL模式.

{ "/table/*", "/user/*", "/contact/*", "/run/*", "/conf/*", ..., ..., ...}
Run Code Online (Sandbox Code Playgroud)

它变得不可维护.排除以下内容会更简单:

{ "/", "/login", "/logout", "/register" }
Run Code Online (Sandbox Code Playgroud)

我怎样才能做到这一点?

@WebFilter(urlPatterns = { "/table/*","/user/*", "/contact/*","/run/*","/conf/*"})
public class SessionTimeoutRedirect implements Filter {

    protected final Logger logger = LoggerFactory.getLogger("SessionFilter");

    @Override
    public void doFilter(ServletRequest req, ServletResponse res,
            FilterChain chain) throws IOException, ServletException {
        HttpServletRequest request = (HttpServletRequest) req;
        HttpServletResponse response = (HttpServletResponse) res;
        if (request.getSession().getAttribute("Id") != null) {
            chain.doFilter(req, res);
        } else {
            logger.debug("session is null:"+request.getRequestURL());                    
            response.sendRedirect(request.getContextPath()+"/login");
        }
    }

    @Override
    public void init(FilterConfig arg0) …
Run Code Online (Sandbox Code Playgroud)

java servlets url-pattern servlet-filters

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

为什么我会得到"目的地路径".从我的webfaction服务器尝试克隆时已经存在"错误?

我正在尝试使用git clone从我的webfaction服务器下载代码

$ cd ../webapps/nameofwebapp/
$ git clone git@github.com:github-username/github-repo.git ./
Run Code Online (Sandbox Code Playgroud)

并且有错误:

fatal: destination path '.' already exists and is not an empty directory.
Run Code Online (Sandbox Code Playgroud)

我使用ls,并且有一些东西 nameofwebapp

auth  git.cgi  gitweb.cgi  repos  static
Run Code Online (Sandbox Code Playgroud)

我想问一下在哪里使用git clone 我是否需要创建一个新目录?

git webfaction

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

React ES6:您可能忘记定义`render`

我停了一会儿,不知道哪里出错,请帮帮我

这是错误消息:

Warning: App(...): No `render` method found on the returned component instance: you may have forgotten to define `render`.
Uncaught TypeError: inst.render is not a function
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

import React from 'react';
import ReactDOM from 'react-dom';

console.log('Start')

export class App extends React.Component{
  constructor(props) {
     super(props);
     console.log('getInitialState');
     return { status:true }
  }
  toggleState(){
    this.setState({status: !this.state.status})
  }
  render() {
    console.log('render');
        return (
           <div>
              <h1 onClick={this.toggleState}>Hello</h1>
           </div>
        );
     }

} 

ReactDOM.render(<App name='Vipul' />,document.getElementById('app'));
Run Code Online (Sandbox Code Playgroud)

ecmascript-6 reactjs

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

scrapy错误:exceptions.ValueError:请求url中缺少方案:

try except用来避免错误,但我的终端仍显示错误,但没有显示日志消息:

raise ValueError('Missing scheme in request url: %s' % self._url)
exceptions.ValueError: Missing scheme in request url: 
Run Code Online (Sandbox Code Playgroud)

当scrapy没有得到image_urls时,如何避免此错误?
请指导我,非常感谢.

    try:

        item['image_urls'] = ["".join(image.extract()) ]     
    except:
        log.msg("no image foung!. url={}".format(response.url),level=log.INFO)
Run Code Online (Sandbox Code Playgroud)

python scrapy

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

CSS Selector获取元素属性值

HTML结构是这样的:

<td class='hey'> 
<a href="https://example.com">First one</a>
</td>
Run Code Online (Sandbox Code Playgroud)

这是我的选择器:

m_URL = sel.css("td.hey a:nth-child(1)[href] ").extract()  
Run Code Online (Sandbox Code Playgroud)

我的选择器现在将输出<a href="https://example.com">First one</a>,但我只希望它输出链接本身:https://example.com.

我怎样才能做到这一点?

python css-selectors scrapy web-scraping

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

django migrate有错误:指定USING表达式以执行转换

我将我的模型字段从Charfiled()更改为GenericIPAddressField()

ip = models.GenericIPAddressField()
Run Code Online (Sandbox Code Playgroud)

并使用django 1.7迁移

./manage.py makemigrations core
./manage.py migrate
Run Code Online (Sandbox Code Playgroud)

但是有错误:

return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: column "ip" cannot be cast automatically to type inet
HINT:  Specify a USING expression to perform the conversion.
Run Code Online (Sandbox Code Playgroud)

我试试这个,但不行:

ALTER TABLE core_message ALTER COLUMN ip TYPE inet USING (ip::inet);
Run Code Online (Sandbox Code Playgroud)

错误:

ERROR:  invalid input syntax for type inet: ""
Run Code Online (Sandbox Code Playgroud)

我现在能做什么?
请帮帮我谢谢!

python django postgresql

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