1
0
Fork 0
mirror of https://github.com/kbumsik/VirtScreen.git synced 2025-03-09 15:40:18 +00:00

FIX: twisted reactor not defined

This commit is contained in:
Bumsik Kim 2018-05-21 14:40:17 -04:00
parent 46769793e7
commit a88525fdd8
No known key found for this signature in database
GPG key ID: E31041C8EC5B01C6
2 changed files with 16 additions and 8 deletions

View file

@ -40,7 +40,7 @@ setup(
# For a discussion on single-sourcing the version across setup.py and the # For a discussion on single-sourcing the version across setup.py and the
# project code, see # project code, see
# https://packaging.python.org/en/latest/single_source_version.html # https://packaging.python.org/en/latest/single_source_version.html
version='0.1.1', # Required version='0.1.2', # Required
# This is a one-line description or tagline of what your project does. This # This is a one-line description or tagline of what your project does. This
# corresponds to the "Summary" metadata field: # corresponds to the "Summary" metadata field:

View file

@ -1,18 +1,20 @@
#!/usr/bin/env python #!/usr/bin/python3
# Python standard packages
import sys, os, subprocess, signal, re, atexit, time, json, shutil import sys, os, subprocess, signal, re, atexit, time, json, shutil
from pathlib import Path from pathlib import Path
from enum import Enum from enum import Enum
from typing import List, Dict from typing import List, Dict
# PyQt5 packages
from PyQt5.QtWidgets import QApplication from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QObject, QUrl, Qt, pyqtProperty, pyqtSlot, pyqtSignal, Q_ENUMS from PyQt5.QtCore import QObject, QUrl, Qt, pyqtProperty, pyqtSlot, pyqtSignal, Q_ENUMS
from PyQt5.QtGui import QIcon, QCursor from PyQt5.QtGui import QIcon, QCursor
from PyQt5.QtQml import qmlRegisterType, QQmlApplicationEngine, QQmlListProperty from PyQt5.QtQml import qmlRegisterType, QQmlApplicationEngine, QQmlListProperty
# Twisted and netifaces
from twisted.internet import protocol, error from twisted.internet import protocol, error
from netifaces import interfaces, ifaddresses, AF_INET from netifaces import interfaces, ifaddresses, AF_INET
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
# file path definitions # file path definitions
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
@ -37,6 +39,7 @@ ICON_PATH = BASE_PATH + "/icon/icon.png"
QML_PATH = BASE_PATH + "/qml" QML_PATH = BASE_PATH + "/qml"
MAIN_QML_PATH = QML_PATH + "/main.qml" MAIN_QML_PATH = QML_PATH + "/main.qml"
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
# Subprocess wrapper # Subprocess wrapper
# ------------------------------------------------------------------------------- # -------------------------------------------------------------------------------
@ -64,6 +67,10 @@ class ProcessProtocol(protocol.ProcessProtocol):
self.onErrRecevied = onErrRecevied self.onErrRecevied = onErrRecevied
self.onProcessEnded = onProcessEnded self.onProcessEnded = onProcessEnded
self.logfile = logfile self.logfile = logfile
# We cannot import this at the top of the file because qt5reactor should
# be installed in the main function first.
from twisted.internet import reactor # pylint: disable=E0401
self.reactor = reactor
def run(self, arg: str): def run(self, arg: str):
"""Spawn a process """Spawn a process
@ -73,7 +80,7 @@ class ProcessProtocol(protocol.ProcessProtocol):
""" """
args = arg.split() args = arg.split()
reactor.spawnProcess(self, args[0], args=args, env=os.environ) self.reactor.spawnProcess(self, args[0], args=args, env=os.environ)
def kill(self): def kill(self):
"""Kill a spawned process """Kill a spawned process
@ -551,7 +558,8 @@ class Backend(QObject):
def _onEnded(exitCode): def _onEnded(exitCode):
if exitCode is not 0: if exitCode is not 0:
self.vncState = self.VNCState.ERROR self.vncState = self.VNCState.ERROR
self.onError.emit('X11VNC: Error occurred.\nDouble check if the port is already used.') self.onError.emit('X11VNC: Error occurred.\n'
'Double check if the port is already used.')
self.vncState = self.VNCState.OFF # TODO: better handling error state self.vncState = self.VNCState.OFF # TODO: better handling error state
else: else:
self.vncState = self.VNCState.OFF self.vncState = self.VNCState.OFF
@ -651,10 +659,10 @@ def main():
"Cannot create ~/.virtscreen") "Cannot create ~/.virtscreen")
sys.exit(1) sys.exit(1)
# Replace Twisted reactor with qt5reactor
import qt5reactor # pylint: disable=E0401 import qt5reactor # pylint: disable=E0401
qt5reactor.install() qt5reactor.install()
from twisted.internet import utils, reactor # pylint: disable=E0401 from twisted.internet import reactor # pylint: disable=E0401
app.setWindowIcon(QIcon(ICON_PATH)) app.setWindowIcon(QIcon(ICON_PATH))
os.environ["QT_QUICK_CONTROLS_STYLE"] = "Material" os.environ["QT_QUICK_CONTROLS_STYLE"] = "Material"