很多公司都大量使用了python,其中有一些开发规范,code guidline, 通用组件,基础框架是可以共用的。
每个公司都自己搞一套, 太浪费人力,我想开一帖和大家讨论一下这些python基础设施的搭建。
原则是我们尽量不重新发明轮子,但开源组件这么多,也要有个挑选的过程和组合使用的过程,在这里讨论一下。
另一方面,有些开源组件虽然强大,但我们不能完全的驾驭它,或只使用其中很少的一部分,我们就可以考虑用python实现一个简单的轮子,可控性更强,最好不要超过300行代码。
#!/usr/bin/env python | |
# encoding: utf-8 | |
""" | |
Usage: | |
fab deploy:appname | |
""" | |
from fabric.api import env, run, cd, local, put | |
env.hosts = ['myserver.com'] | |
env.user = 'eric' |
#coding: utf-8 | |
from bottle import route, error, post, get, run, static_file, abort, redirect, response, request, template | |
@route('/') | |
@route('/index.html') | |
def index(): | |
return '<a href="/hello">Go to Hello World page</a>' | |
@route('/hello') | |
def hello(): |
# -*- coding:utf-8 -*- | |
import requests | |
from time import sleep | |
from threading import Thread | |
UPDATE_INTERVAL = 0.01 | |
class URLThread(Thread): | |
def __init__(self, url, timeout=10, allow_redirects=True): | |
super(URLThread, self).__init__() |
# -*- coding:utf-8 -*- | |
import requests, os, re, sys, time | |
from time import sleep | |
from threading import Thread | |
reload(sys) | |
sys.setdefaultencoding('utf8') | |
UPDATE_INTERVAL = 0.01 |
#-*- coding: utf-8 -*- | |
import urllib, re, os, argparse | |
RE_NEXT_URL = ur'<a href=\"(?!javascript\:)([^\"]*?)">下一页<\/a>' | |
RE_PICTURE = ur'<p\s+(?:align=\"center\")>\s*<img.*?src=\"(.*?)\".*?\/?>' | |
RE_ARCTITLE = ur'var arctitle=\'(.*?)\';' | |
def get_html(url): | |
try: | |
return urllib.urlopen(url).read().decode('gbk') |
import re | |
import json | |
import urllib | |
import base64 | |
import hashlib | |
import requests | |
import OS | |
WBCLIENT = 'ssologin.js(v.1.3.18)' |
#! /usr/bin/env python | |
# coding=utf-8 | |
__author__ = 'jszhou' | |
from bottle import * | |
import hashlib | |
import xml.etree.ElementTree as ET | |
import urllib2 | |
# import requests | |
import json |
#! /usr/bin/env python | |
# coding=utf-8 | |
__author__ = 'jszhou' | |
from bottle import * | |
import hashlib | |
import xml.etree.ElementTree as ET | |
import urllib2 | |
# import requests | |
import json |