This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/expect | |
set timeout 60 | |
spawn /usr/bin/ssh -D 7070 -g [email protected] | |
#这里的 username 为你自己的用户名,yourserver.com 为你自己的服务器域名或ip | |
expect { | |
"password:" { | |
send "password\r" | |
#将第二个 password 改为你自己的密码 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python2.7 | |
#coding=utf-8 | |
import sys | |
import time | |
import gzip | |
import logging | |
import urllib, httplib | |
from Cookie import BaseCookie | |
from StringIO import StringIO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def init_logger(): | |
logger = logging.getLogger() | |
hdr = logging.FileHandler('xiami.log.txt') | |
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') | |
hdr.setFormatter(formatter) | |
logger.addHandler(hdr) | |
logger.setLevel(logging.NOTSET) | |
return logger | |
# useage # |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding=utf-8 | |
import sys | |
import time | |
import gzip | |
import logging | |
import urllib | |
from urllib import urlencode | |
import httplib | |
from Cookie import BaseCookie | |
from StringIO import StringIO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.core.mail import send_mail as core_send_mail | |
from django.core.mail import EmailMultiAlternatives | |
import threading | |
class EmailThread(threading.Thread): | |
def __init__(self, subject, body, from_email, recipient_list, fail_silently, html): | |
self.subject = subject | |
self.body = body | |
self.recipient_list = recipient_list | |
self.from_email = from_email |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from models import Contact | |
# 根据条件进行查询 | |
cs = Contact.query(user_id=1) # 返回列表,列表中元素是过core.database.MongoDoc封装的对象 | |
# 添加文档至数据库,返回_id | |
_id = Contact.create({'user_id':1}) | |
# 根据_id获取MongoDoc对象 | |
_id = '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prepare(self): | |
""" | |
watch out _prepare* functions' sequence | |
NOTE: WITHOUT JUDGING self._finished THERE WILL BE BIG PROBLEMS | |
""" | |
self._prepare_debug() | |
if self._finished: return | |
self._prepare_mobile() | |
if self._finished: return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
from django.http import HttpResponse, HttpResponseRedirect | |
from django.contrib.auth.models import User | |
from django.contrib.auth import login as auth_login | |
from django.contrib.auth import authenticate as auth_authenticate | |
from utils.viewsbase import render_tpl, ApiBaseError, get_rsrc | |
def validate(val, p, unique=None): | |
res = re.search(p, val) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
#coding=utf8 | |
import sys | |
from utils import directSelectSort | |
class Process(object): | |
def __init__(self, id, priority, schema): | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
#coding=utf8 | |
import sys | |
from utils import directSelectSort, col_decorate, BaseError | |
class MEMStoreError(BaseError): | |
pass | |
class InputError(BaseError): |
OlderNewer