Skip to main content

Posts

Showing posts from December, 2014

Scrapy ERROR :ImportError: Error loading object 'scrapy.telnet.TelnetConsole': No module named conch

原文: https://stackoverflow.com/questions/17263509/error-while-using-scrapy-scrapy-telnet-telnetconsole-no-module-named-conch/17264705#17264705 On Ubuntu, you should avoid using  easy_install  wherever you can. Instead, you should be using  apt-get ,  aptitude , "Ubuntu Software Center", or another of the distribution-provided tools. For example, this single command is all you need to install scrapy - along with every one of its dependencies that is not already installed: $ sudo apt - get install python - scrapy easy_install  is not nearly as good at installing things as  apt-get . Chances are the reason you can't get it to work is that it didn't quite install things sensibly, particularly with respect to what was already installed on the system. Sadly, it also leaves no record of what it did, so uninstallation is difficult or impossible. You may now have a big mess on your system that prevents proper installations from working as well (or maybe not, you might

linux下批处理

linux使用中发现我们可能开机要启动一系列程序. 所以写个批处理d文件很方便: 首先 到你用户d目录下: vim startup.sh #your dir cd /home/jason/Downloads/openkeeper-cli-1.1-x86_64 #your command as you do ok cd /home/jason/Downloads/goagent-goagent-52e1f7b/local/ python proxy.py ~                           Then chmod 777 startup.sh

Master-Worker模式 Python(转载)

转载来自: http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/001386832973658c780d8bfa4c6406f83b2b3097aed5df6000 分布式进程 810次阅读 在Thread和Process中,应当优选Process,因为Process更稳定,而且,Process可以分布到多台机器上,而Thread最多只能分布到同一台机器的多个CPU上。 Python的 multiprocessing 模块不但支持多进程,其中 managers 子模块还支持把多进程分布到多台机器上。一个服务进程可以作为调度者,将任务分布到其他多个进程中,依靠网络通信。由于 managers 模块封装很好,不必了解网络通信的细节,就可以很容易地编写分布式多进程程序。 举个例子:如果我们已经有一个通过 Queue 通信的多进程程序在同一台机器上运行,现在,由于处理任务的进程任务繁重,希望把发送任务的进程和处理任务的进程分布到两台机器上。怎么用分布式进程实现? 原有的 Queue 可以继续使用,但是,通过 managers 模块把 Queue 通过网络暴露出去,就可以让其他机器的进程访问 Queue 了。 我们先看服务进程,服务进程负责启动 Queue ,把 Queue 注册到网络上,然后往 Queue 里面写入任务: # taskmanager.py import random, time, Queue from multiprocessing.managers import BaseManager # 发送任务的队列: task_queue = Queue.Queue() # 接收结果的队列: result_queue = Queue.Queue() # 从BaseManager继承的QueueManager: class QueueManager(BaseManager): pass # 把两个Queue都注册到网络上, callable参数关联了Queue对象: QueueManager.register('get_task_queue', callable=lambda: tas

为Tomcat配置Nginx

Nginx配置 server { listen mysite.com :80; #如:listen 80 server_name mysite.com; #如:localhost root /path/to/tomcat/webapps/mysite/ ; location / { proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://127.0.0.1: 8082 /; 这个地方的端口是Tomcat的端口号,如果你没有更改过tomcat的server.xml 那这个就是8080 } } Tomcat配置: 见之前一篇: http://sjasonzhang.blogspot.jp/2014/11/blog-post.html

Nginx install from source on cenos 6.5

ERROR: /configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by using --without-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by using --with-pcre=<path> option. 安装依赖库 yum install -y httpd-devel pcre perl pcre-devel zlib zlib-devel GeoIP GeoIP-devel

ftp服务器返回的文件列表解析

EG: drwx------   3 user group            0 Dec  2 12:09 Java_server_proxy drwx------   3 user group            0 Dec  1 12:42 agent drwx------   3 user group            0 Nov 26 09:21 download drwx------   3 user group            0 Nov 27 07:18 gae-server drwx------   3 user group            0 Nov 28 16:11 openssl drwx------   3 user group            0 Nov 26 08:09 python -rw-------   1 user group        15672 Dec  2 12:00 Java_server_proxy.rar -rw-------   1 user group        18650 Dec  2 12:04 Java_server_proxy.zip #将空格规范后的文件列表 def parse_file_list(parsed_list,file_quantity):     all_file_name=""     all_file_create_data=""     all_file_size = ""     all_file_user=""     all_file_operator_limit=""     for i in range(0,file_quantity):                  i_handle_line = parsed_list.split("\r\n")[i]                  #handle a file         the_line = i_handle_line.split(" ")         file_name = t