我不知道怎么--retry-max-time
计算.如果我下载文件file.txt
:
curl --max-time 10 --retry 3 --retry-delay 5 --retry-max-time 32 'http://www.site.com/download/file.txt'
Run Code Online (Sandbox Code Playgroud)
[ 0- 2]
它需要2s
下载50%
文件,而且没有速度了.[ 2-10]
它等待另一个8s
,仍然没有速度,超时,将重试[10-15]
它5s
在重试#1之前等待[15-25]
仍然没有速度,将重试[25-30]
它5s
在重试#2之前等待[30-34]
它需要4s
下载33%
文件,而且没有速度了.[34-40]
它等待另一个6s
,仍然没有速度,超时此时会curl
停止重试(40s
)吗?
什么时候retry timer
开始和停止?
--retry-max-time <seconds>
The retry timer is reset before the first transfer attempt. Retries will be done as usual (see --retry) as
long as …
Run Code Online (Sandbox Code Playgroud) 我需要使用sqlalchemy在mysql中创建一个db,如果它已经存在,我可以连接到db,但是我希望能够创建它,如果它不存在的话.这是我的表:
#def __init__(self):
Base = declarative_base()
class utente(Base):
__tablename__="utente"
utente_id=Column(Integer,primary_key=True)
nome_utente=Column(Unicode(20))
ruolo=Column(String(10))
MetaData.create_all()
def __repr(self):
return "utente: {0}, {1}, id: {2}".format(self.ruolo,self.nome_utente,self.utente_id)
class dbmmas(Base):
__tablename__="dbmmas"
db_id=Column(Integer,primary_key=True,autoincrement=True)
nome_db=Column(String(10))
censimento=Column(Integer)
versione=Column(Integer)
ins_data=Column(DateTime)
mod_data=Column(DateTime)
ins_utente=Column(Integer)
mod_utente=Column(Integer)
MetaData.create_all()
def __repr(self):
return "dbmmas: {0}, censimento {1}, versione {2}".format(self.nome_db,self.censimento,self.versione)
class funzione(Base):
__tablename__="funzione"
funzione_id=Column(Integer,primary_key=True,autoincrement=True)
categoria=Column(String(10))
nome=Column(String(20))
def __repr__(self):
return "funzione:{0},categoria:{1},id:{2} ".format(self.nome,self.categoria,self.funzione_id)
class profilo(Base):
__tablename__="rel_utente_funzione"
utente_id=Column(Integer,primary_key=True)
funzione_id=Column(Integer,primary_key=True)
amministratore=Column(Integer)
MetaData.create_all()
def __repr(self):
l=lambda x: "amministratore" if x==1 else "generico"
return "profilo per utente_id:{0}, tipo: {1}, funzione_id: {2}".format(self.utente_id,l(self.amministratore),self.funzione_id)
class aree(Base):
__tablename__="rel_utente_zona" …
Run Code Online (Sandbox Code Playgroud) 有没有什么理由说QtGui与PyQt5一起打包???
我正在使用Mark Summerfield的Rapid GUI编程书.显然这本书是用Qt4编写的,但我被推荐使用Qt5和PyQt5.我想在第4章中运行第一个示例代码.代码以以下import语句开头:
import sys
import time
from PyQt5.QtCore import *
from PyQt5.QtGui import *
Run Code Online (Sandbox Code Playgroud)
编译器响应:
Traceback (most recent call last):
File "wakeUp.py", line 4, in <module>
from PyQt5.QtGui import *
ImportError: No module named 'PyQt5.QtGui'
Run Code Online (Sandbox Code Playgroud)
请注意,PyQt5.QtCore import语句不会生成错误.
从终端,
$ echo $PYTHONPATH
:/usr/lib/python3.3/site-packages
Run Code Online (Sandbox Code Playgroud)
有没有其他人遇到QtGui的导入错误?
从我可以进行的互动会议
>>> import PyQt5.Qt
>>> import PyQt5.QtDBus
>>> import PyQt5.QtNetwork
>>> import PyQt5.QtXmlPatterns
Run Code Online (Sandbox Code Playgroud)
但我没有QtWidgets,QtGui,QtWebkit,QtDesigner和其他几个.
此外,如果它有用,/ usr/lib/python3.3/site-package/PepQt5的内容是:
__init__.py QtCore.so QtDBus.so QtNetwork.so Qt.so QtXmlPatterns.so uic
Run Code Online (Sandbox Code Playgroud)
这是我能够导入的相同模块.其他模块(QtWidgets,QtGui等)是否也应该在这里?
我使用的是Ubuntu 13.04和Python 3.3.
使用Apache PIG时从Python UDF返回字典的输出模式是什么.
我有一本字典词典,如下所示:
dict = {x:{a:1,b:2,c:3}, y:{d:1,e:3,f:9}}
Run Code Online (Sandbox Code Playgroud)
我的输出架构看起来像
@outputSchema("m:map[im:map[X:float,Y:float]]")
Run Code Online (Sandbox Code Playgroud)
**方括号,因为在Pig中我们使用[]作为此词典转换为的地图.
如何将python方法/槽连接到QML信号?看起来QtObject.connect()曾经在PyQt4中工作,但它在PyQt5中不再可用.
#Sample QML File (stack.qml)
import QtQuick 2.0
Rectangle {
MouseArea {
anchors.fill: parent
onClicked: {
// relay this to python
}
}
}
Run Code Online (Sandbox Code Playgroud)
-
#Sample Python File
from PyQt5.QtCore import QUrl
from PyQt5.QtGui import QGuiApplication
from PyQt5.QtQuick import QQuickView
if __name__ == '__main__':
import os
import sys
app = QGuiApplication(sys.argv)
view = QQuickView()
view.setWidth(500)
view.setHeight(500)
view.setTitle('Hello PyQt')
view.setResizeMode(QQuickView.SizeRootObjectToView)
view.setSource(QUrl.fromLocalFile(os.path.join(os.path.dirname(__file__),'stack.qml')))
def on_qml_mouse_clicked(mouse_event):
print 'mouse clicked'
view.show()
qml_rectangle = view.rootObject()
# this technique doesn't work #############################
qml_rectangle.mousePressEvent.connect(on_qml_mouse_clicked)
sys.exit(app.exec_())
Run Code Online (Sandbox Code Playgroud)
一些PyQT示例通过"setContextProperty"将对象传递到QML上下文,然后将QML事件中继到该对象上的插槽,但这种方法似乎是迂回的.有没有更好的办法?
我一直试图找到一种方法来从主外部的Python线程更新GUI线程.sourceforge上的PyQt5文档有关于如何执行此操作的良好说明.但我仍然无法让事情发挥作用.
有没有一种很好的方法来解释交互式会话的以下输出?不应该有办法在这些对象上调用emit方法吗?
>>> from PyQt5.QtCore import QObject, pyqtSignal
>>> obj = QObject()
>>> sig = pyqtSignal()
>>> obj.emit(sig)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'QObject' object has no attribute 'emit'
Run Code Online (Sandbox Code Playgroud)
和
>>> obj.sig.emit()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'QObject' object has no attribute 'sig'
Run Code Online (Sandbox Code Playgroud)
和
>>> obj.sig = pyqtSignal()
>>> obj.sig.emit()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'PyQt5.QtCore.pyqtSignal' object …
Run Code Online (Sandbox Code Playgroud) 当我尝试制作散射图时,按密度着色,它需要永远.
可能是因为数据的长度非常大.
这基本上就是我这样做的:
xy = np.vstack([np.array(x_values),np.array(y_values)])
z = gaussian_kde(xy)(xy)
plt.scatter(np.array(x_values), np.array(x_values), c=z, s=100, edgecolor='')
Run Code Online (Sandbox Code Playgroud)
作为附加信息,我必须补充一点:
>>len(x_values)
809649
>>len(y_values)
809649
Run Code Online (Sandbox Code Playgroud)
是否有其他选择可以获得相同的结果,但速度结果更好?
我将我们的Web服务器日志存储在MongoDB中,模式类似于以下内容:
[
{
"_id" : 12345,
"url" : "http://www.mydomain.com/xyz/abc.html",
....
},
....
]
Run Code Online (Sandbox Code Playgroud)
$project
在我开始通过聚合管道传递集合之前,我试图使用运算符重新整形此模式.基本上,我需要添加一个名为"type"的新字段,稍后将用于执行group-by.新领域的逻辑非常简单.
if "url" contains "pattern_A" then set "type" = "sales lead";
else if "url" contains "pattern_B" then set "type" = "existing client";
...
Run Code Online (Sandbox Code Playgroud)
我想它必须是这样的:
db.weblog.aggregate(
{
$project : {
type : { /* how to implement the logic??? */ }
}
}
);
Run Code Online (Sandbox Code Playgroud)
我知道如何使用map-reduce(通过将"keyf"属性设置为实现上述逻辑的自定义JS函数)来执行此操作,但现在我正在尝试使用新的聚合框架来执行此操作.我尝试使用表达式运算符实现逻辑,但到目前为止无法使其工作.任何帮助/建议将不胜感激!
我从PyQt4开始,在最简单的示例中使用QGraphicsScene/View时面临着一个coredump:
#!/usr/bin/python
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
app = QApplication(sys.argv)
grview = QGraphicsView()
scene = QGraphicsScene()
grview.setScene(scene)
grview.show()
sys.exit(app.exec_())
Run Code Online (Sandbox Code Playgroud)
该程序运行,但关闭它时,它会产生大量的GTK错误(使用Ubuntu),最后是核心转储(分段错误):
(python:2732): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(python:2732): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(python:2732): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(python:2732): Gtk-CRITICAL **: IA__gtk_container_add: assertion `GTK_IS_CONTAINER (container)' failed
(python:2732): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
(python:2732): Gtk-CRITICAL **: IA__gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED …
Run Code Online (Sandbox Code Playgroud) 我知道我应该使用访问方法.我在datetime
模块中看到该类datetime
继承自date.
class datetime(date):
<some other code here....>
self = date.__new__(cls, year, month, day)
self._hour = hour
self._minute = minute
self._second = second
self._microsecond = microsecond
self._tzinfo = tzinfo
return self
Run Code Online (Sandbox Code Playgroud)
我还看到datetime能够访问date的成员,如__repr__
:
def __repr__(self):
"""Convert to formal string, for repr()."""
L = [self._year, self._month, self._day, # These are never zero
self._hour, self._minute, self._second, self._microsecond]
Run Code Online (Sandbox Code Playgroud)
我试图将datetime子类化为其添加一些信息,然后编写一个类似的__repr__
函数:
def __repr__(self):
"""Convert to formal string, for repr()."""
L = [self._year, self._month, self._day, # These are …
Run Code Online (Sandbox Code Playgroud) python ×4
pyqt ×3
pyqt5 ×3
python-3.x ×2
qt ×2
apache-pig ×1
curl ×1
dictionary ×1
mongodb ×1
mysql ×1
performance ×1
pyqt4 ×1
qml ×1
qt-signals ×1
qtgui ×1
schema ×1
sqlalchemy ×1
subclass ×1
ubuntu ×1