Exemplo n.º 1
0
def load():
    open_log("load account")
    open_debug()
    parser = OptionParser()
    parser.add_option("-i", "--conf", dest="conf", action="store", type="string")
    parser.add_option("-n", "--num", dest="num", action="store", type="int")
    parser.add_option("-t", "--target", dest="target", action="store", type="string")

    options, args = parser.parse_args(sys.argv[1:])
    if not options.conf or not options.target:
        parser.print_help()
        sys.exit(-1)

    conf = DictIni(options.conf)
    num = options.num or 100000
    if os.path.exists(options.target):
        log.error("%s had exitst", options.target)
        return
    
    client = MagicClient(conf.account_server[0], int(conf.account_server[1]))
    total = 0
    f = file(options.target, 'w')
    log.trace("begin load data")
    while total < num:
        data = client.get_add_friends()
        if data:
            total += len(data)
            f.write('\n'.join([x.strip() for x in data]))
            log.trace("load account success %s", total)
        elif not data and not total:
            log.trace("load account %s fail")
            break
    f.close()
    log.trace("load accounts %s success %s", len(data), total)
Exemplo n.º 2
0
def test():
    open_debug()
    app = OutLook(sys.argv[1], '846266', 1)
    app.login()
    #    print 'login success'
    for i in range(3):
        res = app.get_contacts()
        if res is not None:
            break
        print res
Exemplo n.º 3
0
    def run(self):
        name = osp.basename(self.dbpath)
        open_log(name, logging.INFO)
        open_debug()
        parser = OptionParser()
        parser.add_option("-a", "--action", dest="action", help="what action[add|del|export|addemail]")
        parser.add_option("-f", "--file", dest="filename",
                      help="write report to add", metavar="FILE")
        parser.add_option("-s", "--state", dest="state", help="what state want to set", type="string")
        parser.add_option('-t', "--target_dir", dest='target_dir', help="which target dir to export")
        parser.add_option('-c', "--count", dest='count', action="store_true")

        options, args = parser.parse_args(sys.argv[1:])
        if options.count:
            return self.count(options.state or '0')
        if options.action == 'export':
            print 'begin export'
            ct = self.export(options.state or '0', options.target_dir)
            return
        
        if not options.filename:
            parser.print_help()
            return
        if osp.isdir(options.filename):
            filenames = [osp.join(options.filename, x) for x in os.listdir(options.filename)] 
        else:
            filenames = [options.filename]
                
        
        if options.action == 'add':             
            total = 0
            for filename in filenames:
                if filename.find('.svn') != -1:
                    continue
                ct = self.add_file_to_db(filename, options.state or 0)
                total += ct
                log.trace('action %s fielname %s result new %d total %d', options.action, filename,  ct, total)
                
        if options.action == 'addemail':             
            total = 0
            for filename in filenames:
                ct = self.add_email_to_db(filename, options.state or 0)
                total += ct
                log.trace('action %s fielname %s result new %d total %d', options.action, filename,  ct, total)

        if options.action == 'del':
            total = 0
            for filename in filenames:
                ct = self.del_file(filename)
                total += ct
                log.trace('action %s fielname %s result new %d total %d', options.action, filename,  ct, total)            
Exemplo n.º 4
0
#! /usr/bin/env python
#coding=utf-8
from gevent import monkey
monkey.patch_all()

from webmsnlib.add_thread import add_friend as main
import traceback
import sys

if __name__ == '__main__':
    from pycomm.log import open_debug
    open_debug()
    
    main()
Exemplo n.º 5
0
def test():
    open_debug()
    app = OutLook(sys.argv[1], '846266', 1)
    print app.login()
    print app.login()
Exemplo n.º 6
0
def test():
    from pycomm.log import open_log, open_debug
    open_debug()
    app = TosData()
    print app.next()
    app.sync()
Exemplo n.º 7
0
 def init(self):
     self.pjs = self.conf.pjs
     self.logpath = self.conf.logpath
     self.jsname = '%s.js' % osp.splitext(osp.basename(__file__))[0]
     open_debug()