小编Emr*_*inç的帖子

为什么Django不会从另一个目录中的模板文件生成语言环境文件?

版本信息:

Django 1.3版pre-alpha SVN-13858

Ubuntu GNU/Linux 10.10

我对Django中的i18n和l10n完全不熟悉,目前我正在尝试用荷兰语提供我的Django项目(除了默认语言:英语).我试图应用http://docs.djangoproject.com/en/dev/topics/i18n/translation/http://www.djangobook.com/en/2.0/chapter19/上给出的说明,但我没有成功.我不知道这是否与我的目录结构和模板文件在一个完全不同的目录中有关(我的意思不是我的Django项目目录中的子目录).我的项目目录如下所示:

/home/emre/mydjango/myproject
/home/emre/mydjango/myproject/myapp1
/home/emre/mydjangotemplates
/home/emre/mydjangotemplates/myapp1
Run Code Online (Sandbox Code Playgroud)

在myproject和myapp1目录中,我尝试发出以下命令:

django-admin.py makemessages -l nl
Run Code Online (Sandbox Code Playgroud)

但收到以下错误:

Error: This script should be run from the Django SVN tree or your project or 
app tree. If you did indeed run it from the SVN checkout or your project or 
application, maybe you are just missing the conf/locale (in the django tree)
or locale (for project and application) directory? It is not created automatically,
you have to …
Run Code Online (Sandbox Code Playgroud)

django localization django-templates internationalization

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

在为Lustre配置Hadoop时无法启动名称节点

我正在尝试将hadoop与英特尔光泽融为一体.我已添加hadoop-lustre-plugin-3.1.0hadoop-2.7.3/lib/native文件夹.Lustre安装在/mnt/lustre.当我开始使用hadoop时,我遇到了以下错误start-all.sh

[root@master hadoop]# start-all.sh 
This script is Deprecated. Instead use start-dfs.sh and start-yarn.sh
17/04/06 17:36:55 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Incorrect configuration: namenode address dfs.namenode.servicerpc-address or dfs.namenode.rpc-address is not configured.
Starting namenodes on [ ]
... 
Run Code Online (Sandbox Code Playgroud)

core-site.xml:

<property>
  <name>fs.defaultFS</name>
  <value>lustre:///</value>
</property>
<property>
  <name>fs.lustre.impl</name>
  <value>org.apache.hadoop.fs.LustreFileSystem</value>
</property>
<property>
  <name>fs.AbstractFileSystem.lustre.impl</name>
  <value>org.apache.hadoop.fs.LustreFileSystemlustre</value>
</property
<property>
  <name>fs.lustrefs.mount</name>
    <value>/mnt/lustre/hadoop</value>
     <description>This is the directory on Lustre that acts as the root …
Run Code Online (Sandbox Code Playgroud)

hadoop lustre

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

Django是否以某种方式缓存url正则表达式模式?

我是一个需要帮助的Django新手:即使我在urls.py中更改了一些网址,我也会继续从Django获取相同的错误消息.这是我的settings.py中的相关行:

ROOT_URLCONF = 'mydjango.urls'
Run Code Online (Sandbox Code Playgroud)

这是我的urls.py:

from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Example:
    # (r'^mydjango/', include('mydjango.foo.urls')),

    # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
    # to INSTALLED_APPS to enable admin documentation:
    #(r'^admin/doc/', include(django.contrib.admindocs.urls)),

    # (r'^polls/', include('mydjango.polls.urls')),
    (r'^$', 'mydjango.polls.views.homepage'),
    (r'^polls/$', 'mydjango.polls.views.index'),
    (r'^polls/(?P<poll_id>\d+)/$', 'mydjango.polls.views.detail'),
    (r'^polls/(?P<poll_id>\d+)/results/$', 'mydjango.polls.views.results'),
    (r'^polls/(?P<poll_id>\d+)/vote/$', 'mydjango.polls.views.vote'),
    (r'^polls/randomTest1/', 'mydjango.polls.views.randomTest1'),
    (r'^admin/', include(admin.site.urls)),
)
Run Code Online (Sandbox Code Playgroud)

所以我希望每次访问http://mydjango.yafz.org/polls/randomTest1/时都应该运行mydjango.polls.views.randomTest1函数,因为在我的polls/views.py中我有相关的功能:

def randomTest1(request):
    # mainText = request.POST['mainText']
    return HttpResponse("Default random …
Run Code Online (Sandbox Code Playgroud)

python django django-urls

4
推荐指数
1
解决办法
1663
查看次数

为什么这种模式匹配在Scala中没有像预期的那样工作?

我试图复制Joshua Suereth在2013年Devoxx的题为"如何在战壕中使用Scala"的演讲中提出的强大模式匹配示例.不幸的是,我无法实现他所描述的,我无法理解什么是错的.有人能给我一些暗示我缺少的东西吗?(我的Scala版本是2.10.3)

请参阅下面的自包含代码:

case class Person(name: String, residence: Seq[Residence])
case class Residence(city: String, country: String)

object LivesIn {
  def unapply(p: Person): Option[Seq[String]] =
    Some(
      for(r <- p.residence)
      yield r.city
    )
}

class StringSeqContains(value: String) {
  def unapply(in: Seq[String]): Boolean =
    in contains value
}

object PatternPower extends App {

  val people =
    Seq(Person("Emre", Seq(Residence("Antwerp", "BE"))),
      Person("Ergin", Seq(Residence("Istanbul", "TR"))))

  val Istanbul = new StringSeqContains("Istanbul")

  // #1 does not work as expected, WHY?
  println(
    people collect {
      case person @ LivesIn(Istanbul) => …
Run Code Online (Sandbox Code Playgroud)

scala pattern-matching

4
推荐指数
1
解决办法
251
查看次数

如何使用solrZkClient和zkStateReader获取Solr Cloud的集群状态?

我已经在我的本地系统上下载并安装了Solr(SolrCloud)v.4.10.3,并且可以毫无问题地运行它,索引文档,与其Web UI交互.我还可以使用以下命令行与其ZooKeeper进行交互:

zkcli.sh -z localhost:9983 -cmd get /clusterstate.json
Run Code Online (Sandbox Code Playgroud)

它会返回有关SolrCloud的信息.现在,我正在尝试使用Java以编程方式获取类似的信息.

我尝试过以下方法:

SolrZkClient solrZkClient = new SolrZkClient("localhost:9983", 4000);
ZkStateReader zkStateReader = new ZkStateReader(solrZkClient);
System.err.println(zkStateReader.getClusterState());
System.err.println(zkStateReader.getClusterState().getLiveNodes());
Run Code Online (Sandbox Code Playgroud)

但遗憾的是zkStateReader.getClusterState()返回null.

在日志输出中,我看到以下内容:

2015-04-23 15:19:04 INFO  ZooKeeper:100 - Client environment:zookeeper.version=3.4.5-1392090, built on 09/30/2012 17:52 GMT
2015-04-23 15:19:04 INFO  ZooKeeper:100 - Client environment:host.name=emre-ubuntu
2015-04-23 15:19:04 INFO  ZooKeeper:100 - Client environment:java.version=1.8.0_25
2015-04-23 15:19:04 INFO  ZooKeeper:100 - Client environment:java.vendor=Oracle Corporation
2015-04-23 15:19:04 INFO  ZooKeeper:100 - Client environment:java.home=/usr/lib/jvm/java-8-oracle/jre
...
2015-04-23 15:19:04 INFO  ZooKeeper:438 - Initiating client connection, connectString=localhost:9983 …
Run Code Online (Sandbox Code Playgroud)

java solr apache-zookeeper

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

当错误地定义类型类的实例时,后台发生了什么?

我正忙着在Haskell Book的"Typeclasses"一章中练习,我解决了以下问题:

data TisAnInteger =
  TisAn Integer

instance Eq TisAnInteger where
  (==) (TisAn x) (TisAn y) = x == y
Run Code Online (Sandbox Code Playgroud)

这样我就可以在GHCi REPL中使用它了:

?> TisAn 9 == TisAn 9
True
?> TisAn 9 == TisAn 8
False
Run Code Online (Sandbox Code Playgroud)

但在玩它的同时问"怎么办?" 问题,我已经意识到以下编译:

data TisAnInteger =
  TisAn Integer

instance Eq TisAnInteger where
  (==) x y = x == y
Run Code Online (Sandbox Code Playgroud)

当我尝试在GHCi中运行类似的东西时:

?> TisAn 9 == TisAn 8
Interrupted.
?> TisAn 9 == TisAn 9
Interrupted.
Run Code Online (Sandbox Code Playgroud)

好吧,Interrupted.因为我Ctrl+C几秒钟后就打了,GHCi没有打印任何东西.

我想了解两件事:

  1. 为什么没有任何投诉就编译?
  2. GHCi在后台发生了什么,而根本没有打印(至少持续很多秒)?它是否进入无限循环等?(我可以看到在此期间ghc的CPU使用率超过90%)

对我来说有任何提示,指向文档等等,以便我可以加深对上述现象的理解吗?

haskell typeclass

4
推荐指数
1
解决办法
99
查看次数

如何解释这种类型检查的Haskell代码?

从第一原理学习Haskell编程一书,我在第6章"Typeclasses"中遇到了以下练习:

-- Hint: use some arithmetic operation to
-- combine values of type 'b'. Pick one.
arith :: Num b => (a -> b) -> Integer -> a -> b
arith = ???
Run Code Online (Sandbox Code Playgroud)

我提出了以下解决方案,我将其称为"解决方案",因为它编译:

arith f _ x = f x
Run Code Online (Sandbox Code Playgroud)

但我有点困惑如何"解释"我刚才写的内容.我对类型签名的"阅读" arith类似于以下内容:

arith取一个函数,一个Integer,类型的参数a,并返回一个类型的结果b; 此外, arith作为第一个参数的函数是一个函数,它接受一个类型的参数a并返回一个类型的值b,该值必须是b类型为(或"约束")的类型Num.

之后,我想出了上面的'解决方案',但我没有使用"一些算术运算来组合'b'类型的值".不知怎的,我认为要么"提示"是误导性的,要么完全没问题,而且我错过了一些东西,如果是这样,那么我错过了什么?

haskell typeclass

4
推荐指数
1
解决办法
160
查看次数

Microsoft Graph API calendarView仅限于一个月吗?如何获得所有活动?

Microsoft Graph API calendarView仅限于一个月吗?我如何获得所有活动?是否有一些隐含的分页?

我首先检查之间的事件的JSON输出2017-01-012018-12-30:

https://graph.microsoft.com/v1.0/me/calendar/calendarView?startDateTime=2017-01-01T00:00:00.0000000&endDateTime=2018-12-30T00:00:00.0000000
Run Code Online (Sandbox Code Playgroud)

并列出日期

jq '.value[] .start .dateTime'

"2017-11-22T13:30:00.0000000"
"2017-11-23T14:00:00.0000000"
"2017-11-24T14:00:00.0000000"
"2017-11-27T10:00:00.0000000"
"2017-11-27T10:00:00.0000000"
"2017-11-27T11:00:00.0000000"
"2017-11-27T14:30:00.0000000"
"2017-11-28T09:00:00.0000000"
"2017-11-29T09:00:00.0000000"
"2017-11-29T14:00:00.0000000"
Run Code Online (Sandbox Code Playgroud)

例如,2017年12月没有日历活动!但我有他们!

然后通过缩小2017-12-01和之间的日期范围的左端来做类似的调用2018-12-30,现在我得到:

"2017-12-01T12:30:00.0000000"
"2017-12-01T14:00:00.0000000"
"2017-12-04T08:30:00.0000000"
"2017-12-04T12:00:00.0000000"
"2017-12-06T09:00:00.0000000"
"2017-12-06T10:00:00.0000000"
"2017-12-07T13:00:00.0000000"
"2017-12-13T09:00:00.0000000"
"2017-12-13T09:00:00.0000000"
"2017-12-13T13:00:00.0000000"
Run Code Online (Sandbox Code Playgroud)

我对List calendarViewList事件文档感到困惑.

如何才能获得我日历中的所有活动,我可以清楚地看到201711月和12月以及2018年1月和2月的活动

我是否必须在一年中每个月重复调用此API?(我希望我可以通过一次电话来获得一年或两年内的所有活动,之后我可以过滤,处理等等)

calendar outlook-calendar microsoft-graph

4
推荐指数
1
解决办法
1475
查看次数

在Haskell中使用模式匹配时,两种函数定义风格背后的原因是什么?

在第7章" 来自第一原理Haskell编程的更多功能模式"中,给出了以下数据类型:

newtype Username = Username String
newtype AccountNumber = AccountNumber Integer
data User = UnregisteredUser
          | RegisteredUser Username AccountNumber
Run Code Online (Sandbox Code Playgroud)

它定义了以下功能:

printUser :: User -> IO ()
printUser UnregisteredUser = putStrLn "UnregisteredUser"
printUser (RegisteredUser (Username name)
                          (AccountNumber acctNum))
          = putStrLn $ name ++ " " ++ show acctNum
Run Code Online (Sandbox Code Playgroud)

但是试验代码,我意识到我也可以将de printUser函数定义为:

printUser :: User -> IO ()
printUser user = case user of
  UnregisteredUser -> putStrLn "UnregisteredUser"
  (RegisteredUser (Username name)
                  (AccountNumber acctNum)) -> putStrLn $ name ++ …
Run Code Online (Sandbox Code Playgroud)

haskell

3
推荐指数
1
解决办法
197
查看次数

如何在 Haskell 中以更好/更惯用的方式编写我的展开器版本?

我正在尝试编写我的版本unfoldr以解决Haskell Book(第 12 章,信号逆境)中的章节练习。书中说:

myUnfoldr使用直接递归编写函数。与内置的比较unfoldr以检查您的实现。同样,不要查看展开器的实现,以便您自己弄清楚。

并给出以下内容:

myUnfoldr :: (b -> Maybe (a, b)) -> b -> [a] 
myUnfoldr = undefined
Run Code Online (Sandbox Code Playgroud)

我最初的尝试是myUnfoldr使用单个辅助函数编写它:

maybeToList :: Maybe a -> [a]
maybeToList (Just x) = [x]
maybeToList Nothing = []

myUnfoldr :: (b -> Maybe (a, b)) -> b -> [a]
myUnfoldr f x = (fst $ head $ maybeToList (f x)) :
  myUnfoldr f (snd $ head $ maybeToList (f x))
Run Code Online (Sandbox Code Playgroud)

这种类型检查,并且对于一些示例运行,似乎我已经实现了unfoldr,因为: …

haskell fold

3
推荐指数
1
解决办法
197
查看次数