我想激活elasticsearch的日志.
当我运行elasticsearch二进制文件时,我意识到我的日志记录存在问题:配置无法加载!
这是输出:
~ $ sudo /usr/share/elasticsearch/bin/elasticsearch
Failed to configure logging...
org.elasticsearch.ElasticsearchException: Failed to load logging configuration
at org.elasticsearch.common.logging.log4j.LogConfigurator.resolveConfig(LogConfigurator.java:117)
at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:81)
at org.elasticsearch.bootstrap.Bootstrap.setupLogging(Bootstrap.java:94)
at org.elasticsearch.bootstrap.Bootstrap.main(Bootstrap.java:178)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:32)
Caused by: java.nio.file.NoSuchFileException: /usr/share/elasticsearch/config
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55)
at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:144)
at sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:97)
at java.nio.file.Files.readAttributes(Files.java:1686)
at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:109)
at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:69)
at java.nio.file.Files.walkFileTree(Files.java:2602)
at org.elasticsearch.common.logging.log4j.LogConfigurator.resolveConfig(LogConfigurator.java:107)
... 4 more
log4j:WARN No appenders could be found for logger (node).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Java HotSpot(TM) …
Run Code Online (Sandbox Code Playgroud) 我在Stack Exchange上的一些问题中看到,限制可以是每15分钟的请求数量的函数,并且还取决于算法的复杂性,除了这不是一个复杂的.
所以我使用这段代码:
import tweepy
import sqlite3
import time
db = sqlite3.connect('data/MyDB.db')
# Get a cursor object
cursor = db.cursor()
cursor.execute('''CREATE TABLE IF NOT EXISTS MyTable(id INTEGER PRIMARY KEY, name TEXT, geo TEXT, image TEXT, source TEXT, timestamp TEXT, text TEXT, rt INTEGER)''')
db.commit()
consumer_key = ""
consumer_secret = ""
key = ""
secret = ""
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(key, secret)
api = tweepy.API(auth)
search = "#MyHashtag"
for tweet in tweepy.Cursor(api.search,
q=search,
include_entities=True).items():
while True:
try:
cursor.execute('''INSERT INTO MyTable(name, …
Run Code Online (Sandbox Code Playgroud) 我在json文件中有一些日期,我正在搜索与今天日期相对应的日期:
import os
import time
from datetime import datetime
from pytz import timezone
input_file = file(FILE, "r")
j = json.loads(input_file.read().decode("utf-8-sig"))
os.environ['TZ'] = 'CET'
for item in j:
lt = time.strftime('%A %d %B')
st = item['start']
st = datetime.strptime(st, '%A %d %B')
if st == lt :
item['start'] = datetime.strptime(st,'%H:%M')
Run Code Online (Sandbox Code Playgroud)
我有这样的错误:
File "/home/--/--/--/app/route.py", line 35, in file.py
st = datetime.strptime(st, '%A %d %B')
File "/usr/lib/python2.7/_strptime.py", line 328, in _strptime
data_string[found.end():])
ValueError: unconverted data remains: 02:05
Run Code Online (Sandbox Code Playgroud)
你有什么建议吗 ?
我正在使用python(在LinuxMint中使用虚拟环境),我安装了pygal
.
一切正常(渲染到html)但不渲染到svg或png.结果:只有黑色背景.
我安装cssselect
并tinycss
喜欢这里提到的.
它是第一次工作,但在重试时,我遇到了同样的问题.
(我不知道这是否相关,但在上周使用黑暗表格导出照片时,这种情况发生在我身上)
我使用pygal网站上的例子:
import pygal # First import pygal
bar_chart = pygal.Bar() # Then create a bar graph object
bar_chart.add('Fibonacci', [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]) # Add some values
bar_chart.render_to_file('bar_chart.svg') # Save the svg to a file
Run Code Online (Sandbox Code Playgroud)
编辑:
bar_chart.render_to_png('bar_chart.png')
Run Code Online (Sandbox Code Playgroud)
现在正在工作.
但不是:
bar_chart.render_to_file('bar_chart.svg')
Run Code Online (Sandbox Code Playgroud) 是否有一个随时可用的引导程序包来添加其他颜色,而不是默认颜色?
默认颜色是(标签示例):
<span class="label">Default</span>
<span class="label label-success">Success</span>
<span class="label label-warning">Warning</span>
<span class="label label-important">Important</span>
<span class="label label-info">Info</span>
<span class="label label-inverse">Inverse</span>
Run Code Online (Sandbox Code Playgroud) 我正在使用venv,我开发使用eclipse.我想添加一个联系页面.
我做了:
$ . bin/activate
$ pip install flask-wtf
Run Code Online (Sandbox Code Playgroud)
我在forms.py中导入了一些模块:
我用过这个:
from flask.ext.wtf import Form, TextField, TextAreaField, SubmitField
Run Code Online (Sandbox Code Playgroud)
然后这个:
from flask.ext.wtf import Form
from wtforms.fields import TextField, BooleanField
Run Code Online (Sandbox Code Playgroud)
没有人工作,因为我有这个错误:
from flask.ext.wtf import Form
File "/usr/local/lib/python2.7/dist-packages/flask/exthook.py", line 87, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named flask.ext.wtf
Run Code Online (Sandbox Code Playgroud) 我正在使用python和schedule lib来创建一个类似cron的工作
class MyClass:
def local(self, command):
#return subprocess.call(command, shell=True)
print "local"
def sched_local(self, script_path, cron_definition):
import schedule
import time
#job = self.local(script_path)
schedule.every(1).minutes.do(self.local(script_path))
while True:
schedule.run_pending()
time.sleep(1)
Run Code Online (Sandbox Code Playgroud)
在主要时调用它
cg = MyClass()
cg.sched_local(script_path, cron_definition)
Run Code Online (Sandbox Code Playgroud)
我懂了:
local
Traceback (most recent call last):
File "MyClass.py", line 131, in <module>
cg.sched_local(script_path, cron_definition)
File "MyClass.py", line 71, in sched_local
schedule.every(1).minutes.do(self.local(script_path))
File "/usr/local/lib/python2.7/dist-packages/schedule/__init__.py", line 271, in do
self.job_func = functools.partial(job_func, *args, **kwargs)
TypeError: the first argument must be callable
Run Code Online (Sandbox Code Playgroud)
在类中调用另一个方法而不是sched_local时,比如
def job(self):
print "I am …
Run Code Online (Sandbox Code Playgroud) 我刚开始使用sqlite3和python.我想知道之间的区别:
cursor = db.execute("SELECT customer FROM table")
for row in cursor:
print row[0]
Run Code Online (Sandbox Code Playgroud)
和
cursor = db.execute("SELECT customer FROM table")
for row in cursor.fetchall():
print row[0]
Run Code Online (Sandbox Code Playgroud)
除了cursor
是<type 'sqlite3.Cursor'>
和cursor.fetchall()
是<type 'list'>
,它们都有相同的结果.
是否存在差异,偏好或特定情况,其中一个比另一个更优先?
当我运行这个bash脚本时:
if [ [$EUID -ne 0] ]; then
echo "This script must be run as root" 1>&2
exit 1
else
printf " whathever "
exit 0
fi
Run Code Online (Sandbox Code Playgroud)
我有这个错误:
./myScript: 15: [: Illegal number: [
Run Code Online (Sandbox Code Playgroud)
你看到有什么问题吗?
我正在尝试使用以下方法创建 GKE 集群:
gcloud container clusters create mycluster --region europe-west1
Run Code Online (Sandbox Code Playgroud)
但我有一个错误:
ERROR: (gcloud.container.clusters.create) ResponseError: code=403, message=Insufficient regional quota to satisfy request: resource "IN_USE_ADDRESSES": request requires '9.0' and is short '1.0'. project has a quota of '8.0' with '8.0' available. View and manage quotas at https://console.cloud.google.com/iam-admin/quotas?usage=USED&project=myproject-xxxx.
Run Code Online (Sandbox Code Playgroud)
好像是资源IN_USE_ADDRESSES的限制有问题。这很奇怪,因为该项目是新的,因此除了要创建的集群之外,我没有任何资源。我有第二个项目,我在其中部署了 postgres 数据库。而已。
当我访问配额页面时,我似乎没有超过任何限制。
您的帮助将不胜感激。