示例#1
0
def run(configFile, name, uuid):

    wx = None

    @itchat.msg_register(itchat.content.TEXT)
    def text(msg):
        wx.text(msg)

    @itchat.msg_register(itchat.content.TEXT, isGroupChat=True)
    def text(msg):
        wx.textGroup(msg)

    def quit():
        try:
            wx.quit()
        except:
            pass

    OutputPath.init(configFile)

    thread = ThreadWritableObject(configFile, name)
    thread.start()

    sys.stdout = thread
    sys.errout = thread # XXX: Actually, it does NOT work

    try:
        wx = WX(configFile)
        wx.login(quit, uuid)
    except KeyboardInterrupt:
        pass
    except Exception, e:
        print 'Error occurs at', datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        traceback.print_exc(file=sys.stdout)
示例#2
0
文件: outputter.py 项目: wean/coupon
def run(configfile, name):

    OutputPath.init(configFile)

    thread = ThreadWritableObject(configFile, name)
    thread.start()

    sys.stdout = thread
    sys.errout = thread # XXX: Actually, it does NOT work

    try:

        db = Database(configFile, 'specials')
        db.initialize()

        evaluation = Evaluation(configFile, db)

        evaluation.updateOverdue()

        path = OutputPath.getSharePath()
        sharePath = getProperty(configFile, 'output-share-file')

        cmd = '/bin/rm -f {1} && /bin/ln -s {0} {1}'.format(path, sharePath)
        runCommand(cmd)

        data = evaluation.output()

        with open(path, 'w') as fp:
            fp.write(reprDict(data))

    except KeyboardInterrupt:
        pass
    except Exception, e:
        print 'Error occurs at', datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        traceback.print_exc(file=sys.stdout)
示例#3
0
def run(configfile, name, content, savefile):

    OutputPath.init(configFile)

    try:

        db = Database(configFile, 'specials')
        db.initialize()

        evaluation = Evaluation(configFile, db)

        data = evaluation.search(content)

        if savefile is not None:
            with open(savefile, 'w') as fp:
                fp.write(reprDict(data))
        else:
            print reprDict(data)

        return 0

    except KeyboardInterrupt:
        pass
    except Exception, e:
        print 'Error occurs at', datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        traceback.print_exc(file=sys.stdout)
示例#4
0
def run(configFile, userId, name, logFile):

    OutputPath.init(configFile)

    thread = ThreadWritableObject(configFile, name, logFile)
    thread.start()

    sys.stdout = thread
    sys.errout = thread  # XXX: Actually, it does NOT work

    try:
        db = None
        qwd = None

        db = Database(configFile, 'register')
        db.initialize()

        qwd = QWD(db, userId)
        qwd.updateDb(force=True)

    except KeyboardInterrupt:
        pass
    except Exception, e:
        print 'Error occurs at', datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        traceback.print_exc(file=sys.stdout)
示例#5
0
文件: main.py 项目: sausame/currency
def run(configfile, name, filename):

    OutputPath.init(configFile)

    thread = ThreadWritableObject(configFile, name)
    thread.start()

    #sys.stdout = thread
    #sys.errout = thread # XXX: Actually, it does NOT work

    try:
        looper = CurrencyLooper(configFile)

        #looper.run(filename)
        looper.runWithVoice(filename)

        #CurrencyLooper.autorun()

    except KeyboardInterrupt:
        pass
    except Exception as e:
        print('Error occurs at', datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
        traceback.print_exc(file=sys.stdout)

    thread.quit()
    thread.join()
示例#6
0
def run(configFile, userId, name, shareFile, index, savefile, logFile):

    OutputPath.init(configFile)

    thread = ThreadWritableObject(configFile, name, logFile)
    thread.start()

    sys.stdout = thread
    sys.errout = thread # XXX: Actually, it does NOT work

    try:
        db = None
        qwd = None

        db = Database(configFile, 'register')
        db.initialize()

        qwd = QWD(db, userId)

        viewer = Viewer(configFile, qwd)
        data = viewer.get(shareFile, index)

        if savefile is not None:
            with open(savefile, 'w') as fp:
                fp.write(reprDict(data))
        else:
            print reprDict(data)

    except KeyboardInterrupt:
        pass
    except Exception, e:
        print 'Error occurs at', datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        traceback.print_exc(file=sys.stdout)
示例#7
0
def run(configFile, userId, name, screenshotPath, inputPath, outputPath,
        loginConfigFile, logFile):

    OutputPath.init(configFile)

    thread = ThreadWritableObject(configFile, name, logFile)
    thread.start()

    sys.stdout = thread
    sys.errout = thread  # XXX: Actually, it does NOT work

    result = JsonResult.error()

    try:
        db = Database(configFile, 'register')
        db.initialize()

        account = Account(db, userId)
        result = account.login(screenshotPath, inputPath, outputPath,
                               loginConfigFile)

    except KeyboardInterrupt:
        pass
    except Exception as e:
        print 'Error occurs at', datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        traceback.print_exc(file=sys.stdout)
    finally:
        try:
            if db is not None:
                db.quit()
        except:
            pass

    try:
        if outputPath is not None:
            with open(outputPath, 'w') as fp:
                fp.write(reprDict(result))
    except KeyboardInterrupt:
        pass
    except Exception as e:
        print 'Error occurs at', datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        traceback.print_exc(file=sys.stdout)

    thread.quit()
    thread.join()
示例#8
0
def run(configFile, userId, name, content, savefile, logFile):

    OutputPath.init(configFile)

    thread = ThreadWritableObject(configFile, name, logFile)
    thread.start()

    sys.stdout = thread
    sys.errout = thread  # XXX: Actually, it does NOT work

    try:
        key = SearchingKeyRegex.parse(content)

        if key is None:
            key = content

        print 'Searching "', key, '" from user', userId

        db = None
        qwd = None

        db = Database(configFile, 'register')
        db.initialize()

        qwd = QWD(db, userId)

        searcher = Searcher(configFile, qwd)
        data = searcher.explore(key)

        if savefile is not None:
            with open(savefile, 'w') as fp:
                fp.write(reprDict(data))
        else:
            print reprDict(data)

    except KeyboardInterrupt:
        pass
    except Exception, e:
        print 'Error occurs at', datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        traceback.print_exc(file=sys.stdout)
示例#9
0
def run(configFile, name):

    OutputPath.init(configFile)
    OutputPath.clear()

    thread = ThreadWritableObject(configFile, name)
    thread.start()

    sys.stdout = thread
    sys.errout = thread  # XXX: Actually, it does NOT work

    try:
        db = Database(configFile, 'specials')
        db.initialize()

        skuManager = SkuManager(configFile, db)

        couponManager = CouponManager(configFile, db)
        discountManager = DiscountManager(configFile, db)
        seckillManager = SeckillManager(db)

        priceHistoryManager = PriceHistoryManager(db)
        evaluation = Evaluation(configFile, db)

        couponManager.update()
        discountManager.update()
        seckillManager.update()

        skuManager.update()
        evaluation.update()

        priceHistoryManager.update()

        evaluation.evaluate()

    except KeyboardInterrupt:
        pass
    except Exception, e:
        print 'Error occurs at', datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        traceback.print_exc(file=sys.stdout)
示例#10
0
文件: blossoming.py 项目: sausame/ttv
def run(name, configFile, ttsConfigFile, contentFile, videoFile, logFile):

    OutputPath.init(configFile)

    #thread = ThreadWritableObject(configFile, name, logFile)
    #thread.start()

    #sys.stdout = thread
    #sys.errout = thread # XXX: Actually, it does NOT work

    try:
        print('Now: ', datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
        Network.setIsEnabled(True)
        tts = Tts(ttsConfigFile)
        combiner = Combiner(configFile)
        combiner.combine(tts, contentFile, videoFile)
    except KeyboardInterrupt:
        pass
    except Exception as e:
        print('Error occurs at', datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
        traceback.print_exc(file=sys.stdout)
    finally:
        pass