当前位置: 首页>>代码示例>>Python>>正文


Python Connector.start方法代码示例

本文整理汇总了Python中connector.Connector.start方法的典型用法代码示例。如果您正苦于以下问题:Python Connector.start方法的具体用法?Python Connector.start怎么用?Python Connector.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在connector.Connector的用法示例。


在下文中一共展示了Connector.start方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from connector import Connector [as 别名]
# 或者: from connector.Connector import start [as 别名]
    def run(s):

        s.log.info('Started host node {0} on {1}'.format(s.nodename, s.address))

        # Make some count of creator
        for i in range(0, s.creators):

            # Create instance
            creator = Creator(s.nodename)

            # Run thread
            creator.start()

            # Logging
            s.log.info('Started creator thread: {0}'.format(creator.name))

        # Make connector
        connector = Connector(s.nodename)

        # Run connector thread
        connector.start()

        # Logging
        s.log.info('Started connector thread: {0}'.format(connector.name))
开发者ID:akru,项目名称:tigro-lxc,代码行数:26,代码来源:hostnode.py

示例2: connect

# 需要导入模块: from connector import Connector [as 别名]
# 或者: from connector.Connector import start [as 别名]
class Target:
    ## @var config
    # A configurator::Configurator object

    ## @var connection
    # A connector::Connector instance used to send commands to XML-RPC connection

    ## @var is_slave
    # Shows if this is a slave target

    ## @var parameters
    # The target parameters

    ## @var datastream_queue
    # The queue where DataCollector thread puts data and observers get it

    ## @var datastream_poller
    # The DataPoller thread

    ## @var datastream_collector
    # The DataCollector thread

    ## @var signal_structure
    # The structure of the signal obtained with getSignalStructure

    ## @var is_connected
    # Checks if the Target is connected or not. Actually the status is simply set bu connect() and disconnect()

    ## Target initializer.
    def __init__(self, slave=False, protocol=None, address=None, port=None, target_name=None):
        self.config = Configurator()
        self.is_connected = False
        self.is_slave = slave
        self.parameters = None
        self.datastream_queue = None
        self.datastream_poller = None
        self.datastream_collector = None
        self.signal_structure = None

        # Sets basic configurations
        if protocol:
            self.config.setAttr("protocol", protocol)

        if address:
            self.config.setAttr("address", address)

        if port:
            self.config.setAttr("port", port)

        if target_name:
            self.config.setAttr("target_name", target_name)

        # Initializes connection
        self.connection = Connector(self.config)

    ## Prints a summary of the target and its status
    # TODO: Decidere che informazioni restituire
    def getInfo(self):
        print "Target name: %s" % self.config.getAttr("target_name")
        print "Connection status: %s" % ("Connected" if self.is_connected else "Disconnected")
        print "Connection request: %s://%s:%s" % (
            self.config.getAttr("protocol"),
            self.config.getAttr("address"),
            self.config.getAttr("port"),
        )

    ## Setups the queue and the threads needed to read the data stream
    # @param sample_time The sample time of the signal
    # @param decimation The decimation to use
    # @start_threads The flag given by startData() to let the data threads start (False if this method is called by addObserver())
    # @return The boolean result of the operation
    def setup_data_threads(self, sample_time=None, decimation=None, start_threads=False):
        if self.is_slave:
            if not self.datastream_queue:
                self.datastream_queue = []

            # TODO: creare un DataPoller per ogni segnale (non per tutta la traccia) e registrare gli observer sugli specifici DataPoller.
            if not self.datastream_poller:
                self.datastream_poller = DataPoller(self.datastream_queue, decimation)

            # TODO: Il DataCollector deve leggere il numero di segnale e usare la coda specifica per inserirci i dati
            if not self.datastream_collector:
                # TODO: Fermare i thread alla chiusura del target
                self.datastream_collector = DataCollector(
                    self.config.getAttr("address"), self.config.getAttr("slave_data_port"), self.datastream_queue
                )

            if start_threads:
                print ("Starting data threads...")
                if sample_time:
                    self.datastream_poller.updateSampleTime(sample_time)
                    self.datastream_poller.start()
                    self.datastream_collector.start()
                    print ("Data threads started...")
                else:
                    print ("Can't start data threads without a sample time")
                    return False

            return True
        else:
#.........这里部分代码省略.........
开发者ID:tommyblue,项目名称:pyRTAI,代码行数:103,代码来源:target.py

示例3: MainWindow

# 需要导入模块: from connector import Connector [as 别名]
# 或者: from connector.Connector import start [as 别名]
class MainWindow(QtGui.QWidget):
    forceSig = QtCore.Signal(bool)
    def __init__(self):
        QtGui.QWidget.__init__(self)
        self.setObjectName("MainWindow")
        self.icon = QtGui.QIcon('icon.png')
        self.host_lb = QtGui.QLabel()
        self.win1_data_lb = QtGui.QLabel()
        self.win4_data_lb = QtGui.QLabel()
        self.win1_data_lb.setAlignment(QtCore.Qt.AlignRight)
        self.win4_data_lb.setAlignment(QtCore.Qt.AlignRight)
        self.status_lb = QtGui.QLabel(u"Sztátus:")
        self.createTrayIcon()
        self.conn = Connector(self.forceSig)
        self.conn.refreshed.connect(self.update)
        self.conn.statusSig.connect(self.setStatus) 
        self.conn.uconnected.connect(self.connectError)
        self.conn.start()
        
        layout = QtGui.QVBoxLayout()
        btn_lyl = QtGui.QHBoxLayout() 
        box = QtGui.QGroupBox()
        box.setTitle("Adatok")
        box.setLayout(self.createNWDataLayout())
        setting_bt = QtGui.QPushButton()
        setting_bt.setText(u"Beállítások")
        setting_bt.clicked.connect(self.settings)
        self.forcing_bt = QtGui.QPushButton()
        self.forcing_bt.setText(u"Megállít")
        self.forcing_bt.clicked.connect(self.forcing)
        btn_lyl.addSpacerItem(QtGui.QSpacerItem(0,0))
        btn_lyl.addWidget(setting_bt)
        btn_lyl.addWidget(self.forcing_bt)
        
        layout.addWidget(box)
        layout.addLayout(btn_lyl)
        
        self.setLayout(layout)
        self.setMinimumWidth(300)
        self.setWindowFlags(QtCore.Qt.Tool)
        self.setWindowTitle("Bitwatcher v0.10 BETA")
    
    def setStatus(self, status):
        self.status = status
        if self.status == 0:
            self.forcing_bt.setText(u"Erőltetett indítás")
            self.status_lb.setText(u"Szüneteltetve")
        elif self.status == 1:
            self.forcing_bt.setText(u"Erőltetett szüneteltetés")
            self.status_lb.setText(u"Seedel")
        elif self.status == 2:
            self.forcing_bt.setText(u"Erőltetés vége")
            self.status_lb.setText(u"Erőltetett szünet")
        elif self.status == 3:
            self.forcing_bt.setText(u"Erőltetés vége")
            self.status_lb.setText(u"Erőltetett seed")
    
    def forcing(self):
        if self.status == 0 or self.status == 1:
            self.forceSig.emit(True)
        elif self.status == 2 or self.status == 3:
            self.forceSig.emit(False)
    
    def connectError(self, conn):
        if not conn:
            self.tray.showMessage("Kapcsolat hiba", u"A Bitwatcher nem tud csatlakozni a uTorrenthez. Ellenőrizd a beállításokat!")
      
    def createNWDataLayout(self):
        lyl = QtGui.QGridLayout()
        win1_text_lb = QtGui.QLabel(u"Egy napos forgalom:")
        win4_text_lb = QtGui.QLabel(u"Négy napos frogalom:")
        
        lyl.addWidget(self.host_lb,0,0)
        lyl.addWidget(win1_text_lb,1,0)
        lyl.addWidget(win4_text_lb,2,0)
        
        lyl.addWidget(self.win1_data_lb,1,1)
        lyl.addWidget(self.win4_data_lb,2,1)
        lyl.addWidget(self.status_lb,3,0)
        return lyl
    
    def quit(self):
        self.conn.stop()
        QtGui.qApp.quit()
        
    def trayActivated(self, reason):
        if reason in (QtGui.QSystemTrayIcon.Trigger, QtGui.QSystemTrayIcon.DoubleClick):
            self.show()
            self.activateWindow()
        
    def createTrayIcon(self):
        self.trayIconMenu = QtGui.QMenu(self)
        self.trayIconMenu.addSeparator()
        quit = QtGui.QAction(u"&Kilép", self)
        forcing = QtGui.QAction(u"&Erőltet", self)
        forcing.triggered.connect(self.forcing)
        quit.triggered.connect(self.quit)
        sett = QtGui.QAction(u"&Beállít", self)
        sett.triggered.connect(self.settings)
        self.trayIconMenu.addAction(sett)
#.........这里部分代码省略.........
开发者ID:Noirello,项目名称:Bitwatcher,代码行数:103,代码来源:bitwatcher.py


注:本文中的connector.Connector.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。