Форум сайта python.su
<script type="text/javascript">
function addProductReview(e, functn){
e.preventDefault();
var review_form = jQuery(e.target);
jQuery.ajax({
url: review_form.attr('action'),
type: review_form.attr('method'),
data: review_form.serialize() + review_form.find('input').attr('name') ,
dataType: 'json',
success: function(json){
if (json.success == "True"){
functn(json);
}
},
error: function(xhr, ajaxOptions, thrownError){
alert('Error')
}
});
};
function Remove_message(json){
//alert(json.name);
var inpt = $("input[name=" + json.name + "]").parent()
inpt.parent().parent().remove();
//alert("remove");
}
function Add_message_to_list(json){
$(json.alltopic).each(function(index) {
var tds = '<div class="news-line-right">';
tds+='<div class="news-line"><img src="/' + json.alltopic[index][1] + '" id="image-style"></div>';
tds+='<div class="news-line">' + json.alltopic[index][0] + '</div>';
tds+='<div class="news-line"><form action="{% url del_message %}" method="post" class = "bttn"><input type="submit" value="Del ' + json.alltopic[index][2] + '" name="' + json.alltopic[index][2] + '" ></form></div>';
$('#html_add div:last').after(tds);
});
}
$(document).ready(function(){
$("form#review").submit(function(e){
addProductReview(e, Add_to_message);
});
$("form.bttn").submit(function(e){
addProductReview(e, Remove_message);
});
});
</script>
<div class="news-line-right">
<div class="news-line"><img src="/{{ news.1 }}" id="image-style"></div>
<div class="news-line">{{ news.0 }}</div>
<div class="news-line">
<form action="{% url del_message %}" method="post" class = "bttn">
<input type="submit" value="Del {{ news.2 }}" name="{{ news.2 }}">
</form>
</div>
</div>
class main_function_car_servies(models.Model): #Оснавная функция автосервиса
name = models.CharField(max_length = 30, verbose_name = u'имя функции автосервися')
description = models.TextField(max_length = 1000, verbose_name = u'описание')
active = models.BooleanField(verbose_name = u'активен', default = True)
sort = models.IntegerField(verbose_name = u'порядок', default = 0)
def __unicode__(self):
return self.name
class Meta:
verbose_name = u'функция автосервиса'
verbose_name_plural = u'функции автосервиса'
ordering = ['sort']
class role_users_car_servies(models.Model): # роль пользователся автосервиса
name = models.CharField(max_length = 30, verbose_name = u'имя пользователя автосервиса')
description = models.TextField(max_length = 1000, verbose_name = u'описание')
active = models.BooleanField(verbose_name = u'активен', default = True)
sort = models.IntegerField(verbose_name = u'порядок', default = 0)
def __unicode__(self):
return self.name
class Meta:
verbose_name = u'роль пользователя автосервиса'
verbose_name_plural = u'роли пользователя автосервиса'
ordering = ['sort']
def role_fun(request):
list_auto = []
try:
list_auto.append(role_users_car_servies.objects.filter(active = True))
list_auto.append(main_function_car_servies.objects.filter(active = True))
return render_to_response('auto.html', {'list_auto': list_auto}, RequestContext(request))
except:
raise Http404()
def autodetail(request,nameid):
list_auto = []
try:
list_auto.append(role_users_car_servies.objects.filter(active = True))
list_auto.append(main_function_car_servies.objects.filter(active = True))
list_users = role_users_car_servies.objects.filter(active = True)
new_content = list_users.get(id=nameid)
return render_to_response('auto_detail.html', locals(), RequestContext(request))
except:
raise Http404()
{% if list_auto %}
{% for x1 in list_auto %}
{% for item1 in x1 %}
<li><a href="/auto_detail/{{ item1.id }}">{{item1.name}}</a>
{% endfor %}
{% endfor %}
{%endif%}
(r'^auto/$' , role_fun),
(r'^auto_detail/(?P<nameid>[0-9]{1,3})/$', autodetail),
import sys
import os.path
from xml.dom.minidom import parse, parseString
def main():
print "xml=%s" % sys.argv[1]
datasource = open(sys.argv[1])
dom2 = parse(datasource)
f = open(sys.argv[1], 'w')
try:
f.write(dom2.toxml(None))
finally:
f.close()
return 0
if __name__ == "__main__":
main()
<?xml version="1.0"?>
<TaskList Version="2.0">
<TaskCategory abc2="no" zzz="no" Handle="Uncategorized" Name="Uncategorized"
abc="no" zxy="no" />
</TaskList>
import libtorrent as t
session = t.session()
session.listen_on(6868,6891)
info=t.torrent_info("flash.torrent")
#формируем структуру
#file = info.files()
#for i in xrange(0,len(file)):
# print file[i].path
#print "start download",info.files()[0].path
h = session.add_torrent(info, "/home/uev", storage_mode=t.storage_mode_t.storage_mode_sparse)
while (not h.is_seed()):
time.sleep(1)
s = h.status()
state_str = ['queued', 'checking', 'downloading metadata', \
'downloading', 'finished', 'seeding', 'allocating']
print '%.2f%% complete (down: %.1f kb/s up: %.1f kB/s peers: %d) %s' % \
(s.progress * 100, s.download_rate / 1000, s.upload_rate / 1000, \
s.num_peers, state_str[s.state])
- Use GET method for all requestsУ меня следующая реализация коннекта:
- Use HMAC-SHA1 to sign all requests
- Always provide oauth_callback in the request to request_token.ashx. If your product cannot receive a callback, use oauth_callback=oob
import oauth2 as oauth
import urllib
htKey = 'тут ключ'
htSecret = 'тут ключ'
_htReq = "https://chpp.hattrick.org/oauth/request_token.ashx"
def test():
"""Test getting an access token via GET."""
consumer = oauth.Consumer(key=htKey, secret=htSecret)
client = oauth.Client(consumer)
client.set_signature_method(oauth.SignatureMethod_HMAC_SHA1())
resp, content = client.request(_htReq, "GET")
print content
if __name__ == '__main__':
test()
print 'Done.'
401 - Unauthorized: Access is denied due to invalid credentials.Хоть на самом ресурсе есть вариант проверить свои ключи и они проходят проверку нормально.
When you get parameters in url, urldecode them before use, it may help you.Пробовал через urllib перевести ключи, но не помогло (( Может кто еще что находит в этом коде неправильного?
The consumer secret must never be revealed to anyone. DO NOT include it in any requests, show it in any code samples (including open source) or in any way reveal it.
from OpenGL.GLUT import *
from OpenGL.GL import *
def display( *args ):
glClearColor(1.0, 1.0, 1.0, 0)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
glutSwapBuffers ( )
def main():
global wndW, wndH
glutInit( sys.argv )
glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH )
glutInitWindowSize( wndW, wndH )
glutInitWindowPosition( 0, 0 )
glutCreateWindow( sys.argv[0] )
glutDisplayFunc( display )
glutMainLoop( )
print("I cannot see this")
if __name__ == "__main__":
main()
/apps/
/apps/main/
/apps/auth/
/apps/blog/
/apps/pm/
/apps/photo/
__init__.py
db.py
urls.py
/static/css/
/static/js/
/static/templates/
/admin/
/apps/auth/admin/.../
/apps/photo/admin/.../
>>> import pylab
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "/usr/lib/python2.6/site-packages/matplotlib/pylab.py", line 263, in <module>
from matplotlib.pyplot import *
File "/usr/lib/python2.6/site-packages/matplotlib/pyplot.py", line 95, in <module>
new_figure_manager, draw_if_interactive, show = pylab_setup()
File "/usr/lib/python2.6/site-packages/matplotlib/backends/__init__.py", line 25, in pylab_setup
globals(),locals(),[backend_name])
ImportError: No module named backend_tkagg