Exemple #1
0
    def __init__(self, parent=None, server=None):
        QtCore.QObject.__init__(self, parent)

        self.debug = False

        self.callbacks = {}

        self.netManager = QtNetwork.QNetworkAccessManager(self)

        ## Initialise cookies
        self.cookieJar = QtNetwork.QNetworkCookieJar()
        self.netManager.setCookieJar(self.cookieJar)

        self.netManager.finished.connect(self.on_request_finished)
def _open_connection():
    global CONNECTION
    global IP
    global MOSKETCH_PORT

    if CONNECTION is not None:
        _print_error("connection is already opened.")
        return

    # Test IP format
    if (is_valid_ipv4_address(IP) == False):
        _print_error('IP address looks wrong, please enter a valid IP address')
        return
    else:
        _print_success('Connecting to ' + IP)

    # Perform initial settings (pre connection)
    _initial_settings()

    # Try to connect
    CONNECTION = QtNetwork.QTcpSocket(MAIN_WINDOW)
    CONNECTION.readyRead.connect(_got_data)
    CONNECTION.error.connect(_got_error)
    CONNECTION.connected.connect(_connected)
    CONNECTION.disconnected.connect(_disconnected)

    print "Trying to connect to " + _get_connection_name()
    CONNECTION.connectToHost(IP, MOSKETCH_PORT)
Exemple #3
0
    def __init__(self, parent=None):
        super().__init__(parent)

        self.editor = parent

        self.popup = QtWidgets.QTreeWidget()
        self.popup.setWindowFlags(QtCore.Qt.Popup)
        self.popup.setFocusPolicy(QtCore.Qt.NoFocus)
        self.popup.setFocusProxy(parent)
        self.popup.setMouseTracking(True)

        self.popup.setColumnCount(1)
        self.popup.setUniformRowHeights(True)
        self.popup.setRootIsDecorated(False)
        self.popup.setEditTriggers(QtWidgets.QTreeWidget.NoEditTriggers)
        self.popup.setSelectionBehavior(QtWidgets.QTreeWidget.SelectRows)
        self.popup.setFrameStyle(QtWidgets.QFrame.Box | QtWidgets.QFrame.Plain)
        self.popup.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.popup.header().hide()

        self.popup.installEventFilter(self)

        self.popup.itemClicked.connect(self.doneCompletion)

        self.timer = QtCore.QTimer()
        self.timer.setSingleShot(True)
        self.timer.setInterval(500)
        self.timer.timeout.connect(self.autoSuggest)
        self.editor.textEdited.connect(self.timer.start)

        self.networkManager = QtNetwork.QNetworkAccessManager()
        self.networkManager.finished.connect(self.handleNetworkData)
 def __init__(self, i_parent=None):
     QtNetwork.QTcpServer.__init__(self, i_parent)
     self.parent = i_parent
     self.setMaxPendingConnections(1)
     self.port = int(cgruconfig.VARS['keeper_port'])
     self.newConnection.connect(self.connection)
     if not self.listen(QtNetwork.QHostAddress(QtNetwork.QHostAddress.Any),
                        self.port):
         print('Can`t listen %d port.' % self.port)
     else:
         print('Listening %d port...' % self.port)
     self.qsocket = None
Exemple #5
0
    def get(self,
            origin=None,
            url=None,
            params=None,
            tag=None,
            cb=None,
            widget=None,
            debug=False,
            spinner=True):

        self.debug = False

        srv = G.settings.current_server()
        if srv == None:
            print("NO Server in dServer.fetch()")
            return

        url = QtCore.QUrl("%s/ajax%s" % (srv.url, url))

        #q = QtCore.QUrlQuery()

        if params:
            for k, v in params.items():
                url.addQueryItem(str(k), str(v))

        request = QtNetwork.QNetworkRequest()
        request.setUrl(url)
        request.setOriginatingObject(origin)
        request.setPriority(QtNetwork.QNetworkRequest.HighPriority)
        if tag:
            request.setAttribute(ATTR_ID, tag)

        #self.load_cookies() TODO

        if spinner:
            pass  #self.spin(True)

        if G.args.dev:
            print("# --- GET: tag=%s, %s" % (tag, url.toString()))
        #self.trigger_reply( request, SERVER_STATUS.REQUESTING, SERVER_FLAG.WAIT )
        ## creat own accoutn bundle and senf

        #req = Request(url)
        ##req.timeout.connect(self.on_timeout)
        ##self.requests.append(req)
        #req.reply = self.netManager.get( request )
        reply = self.netManager.get(request)
Exemple #6
0
def _open_connection():
    global CONNECTION
    global IP
    global MOSKETCH_PORT

    if CONNECTION is not None:
        _print_error("connection is already opened.")
        return

    # Try to connect
    CONNECTION = QtNetwork.QTcpSocket(MAIN_WINDOW)
    CONNECTION.readyRead.connect(_got_data)
    CONNECTION.error.connect(_got_error)
    CONNECTION.connected.connect(_connected)
    CONNECTION.disconnected.connect(_disconnected)

    print "Trying to connect to " + _get_connection_name()
    CONNECTION.connectToHost(IP, MOSKETCH_PORT)
    def __init__(self, parent=None):
        super(QQtmRt, self).__init__(parent=parent)

        self._connected = False
        self._streaming = False
        self._socket = QtNetwork.QTcpSocket(parent=self)

        self._socket.disconnected.connect(self._disconnected)

        self._handlers = {
            QRTPacketType.PacketData: self._on_data,
            QRTPacketType.PacketEvent: self._on_event,
            QRTPacketType.PacketError: self._on_error,
            QRTPacketType.PacketNoMoreData: self._on_no_data,
        }

        self._receiver = qtm.Receiver(self._handlers)

        self.streamingChanged.connect(self._streaming_changed)
Exemple #8
0
 def autoSuggest(self):
     text = self.editor.text()
     url = gsuggestUrl % (text, )
     self.networkManager.get(QtNetwork.QNetworkRequest(QtCore.QUrl(url)))