| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1415 人关注过本帖
标题:求教 怎么能输出id值啊?
只看楼主 加入收藏
sywzh
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2012-8-3
收藏
 问题点数:0 回复次数:0 
求教 怎么能输出id值啊?
#!/usr/bin/env python
# coding=utf-8
__author__ = 'yang'
__metaclass__ = type

import os #
import time #

import sys
import snapshot #
import reaper   


from PyQt4 import QtGui,QtCore
from utils import confer #
from message_queue import message_queue #
class Worker: #

    def __init__(self,conf_path):#
        self.conf = confer(file(conf_path).read()) #

    def prepare(self):
        conf = self.conf
        secret_path = conf['SECRET_FILE_PATH']
        my_reaper = None
        if secret_path.endswith('.db01'):
            my_reaper = reaper.DbReaper01()
        elif secret_path.endswith('.txt'):
            my_reaper = reaper.LineReaper()
        if conf['STATE_FILE_PATH'] != '' and os.path.exists(conf['STATE_FILE_PATH']):
            my_reaper = snapshot.rollback(conf['STATE_FILE_PATH'])
        else:
            my_reaper.get_secrets(conf['SECRET_FILE_PATH'])
            my_reaper.arm(conf['REAP_TYPE'],**conf['REAP_KWARGS'])
        for linedic_path in conf['DICS']['LineDic']:
            my_reaper.add_dic(dic_type = 'LineDic',dic_path=linedic_path)
        for custom_dic in conf['DICS']['CustomDic']:
            my_reaper.add_costom_dic(custom_dic)
        for pydic_path in conf['DICS']['PyDic']:
            my_reaper.add_dic(dic_type = 'PyDic',dic_path=pydic_path)
        camera_interval = conf['CAMERA_INTERVAL']
        my_camera = snapshot.Camera(my_reaper,'reapme',interval=camera_interval)
        self.reaper = my_reaper
        self.camera = my_camera

    def run_id(self):
        self.camera.paused = False
        self.camera.start()
        self.reaper.start()
        watcher_interval = self.conf['WATCHER_INTERVAL']
        print self.reaper.get_dics_length()
        while True:
            time.sleep(watcher_interval)
            if isinstance(self.reaper,reaper.DbReaper01):
                return self.reaper.curr_id
                break



    def run_pw(self):
        self.camera.paused = False
        #self.camera.start()
        #self.reaper.start()
        watcher_interval = self.conf['WATCHER_INTERVAL']
        self.reaper.get_dics_length()
        while True:
            time.sleep(watcher_interval)
            if isinstance(self.reaper,reaper.DbReaper01):
                return self.reaper.pw_index
                break


    def run_message(self):
        self.camera.paused = False
        #self.camera.start()
        #self.reaper.start()
        watcher_interval = self.conf['WATCHER_INTERVAL']
        self.reaper.get_dics_length()
        while True:
            time.sleep(watcher_interval)
            #if isinstance(self.reaper,reaper.DbReaper01):


            for message in message_queue:
                return message
            if not self.reaper.isAlive():
                print 'all finish'
                self.camera.paused = True
                break

class GridLayout(Worker,QtGui.QWidget):
    def __init__(self,parent = None):
        QtGui.QWidget.__init__(self)
        self.setWindowTitle('Result!')
        id1 =QtGui.QLabel('ID')
        pw1=QtGui.QLabel('Password')
        ssha1=QtGui.QLabel('SSHA')
        self.id1 =QtGui.QLineEdit()
        self.pw1=QtGui.QLineEdit()
        self.ssha1 =QtGui.QLineEdit()
        quit=QtGui.QPushButton('close',self)
        quit.setGeometry(500,380,60,35)
        self.connect(quit,QtCore.SIGNAL('clicked()'),QtGui.qApp,QtCore.SLOT('quit()'))
        grid=QtGui.QGridLayout()
        grid.setSpacing(10)
        grid.addWidget(id1,1,0)
        grid.addWidget(self.id1,1,1)
        grid.addWidget(pw1,2,0)
        grid.addWidget(self.pw1,2,1)
        grid.addWidget(ssha1,3,0)
        grid.addWidget(self.ssha1,3,1)
        self.setLayout(grid)
        self.resize(600,445)
        self.base_run_id()
    def base_run_id(self):
        Worker.run_id(self)
        id=self.run_id()
        self.id1.setText(str(id))



app=QtGui.QApplication(sys.argv)
qb=GridLayout()
qb.show()
sys.exit(app.exec_())
搜索更多相关主题的帖子: file import python 
2012-08-03 15:01
快速回复:求教 怎么能输出id值啊?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016799 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved