1
0
Fork 0
mirror of https://github.com/kbumsik/VirtScreen.git synced 2025-02-12 11:21:53 +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
# project code, see
# 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
# 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
from pathlib import Path
from enum import Enum
from typing import List, Dict
# PyQt5 packages
from PyQt5.QtWidgets import QApplication
from PyQt5.QtCore import QObject, QUrl, Qt, pyqtProperty, pyqtSlot, pyqtSignal, Q_ENUMS
from PyQt5.QtGui import QIcon, QCursor
from PyQt5.QtQml import qmlRegisterType, QQmlApplicationEngine, QQmlListProperty
# Twisted and netifaces
from twisted.internet import protocol, error
from netifaces import interfaces, ifaddresses, AF_INET
# -------------------------------------------------------------------------------
# file path definitions
# -------------------------------------------------------------------------------
@ -37,6 +39,7 @@ ICON_PATH = BASE_PATH + "/icon/icon.png"
QML_PATH = BASE_PATH + "/qml"
MAIN_QML_PATH = QML_PATH + "/main.qml"
# -------------------------------------------------------------------------------
# Subprocess wrapper
# -------------------------------------------------------------------------------
@ -64,6 +67,10 @@ class ProcessProtocol(protocol.ProcessProtocol):
self.onErrRecevied = onErrRecevied
self.onProcessEnded = onProcessEnded
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):
"""Spawn a process
@ -73,7 +80,7 @@ class ProcessProtocol(protocol.ProcessProtocol):
"""
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):
"""Kill a spawned process
@ -551,7 +558,8 @@ class Backend(QObject):
def _onEnded(exitCode):
if exitCode is not 0:
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
else:
self.vncState = self.VNCState.OFF
@ -651,10 +659,10 @@ def main():
"Cannot create ~/.virtscreen")
sys.exit(1)
# Replace Twisted reactor with qt5reactor
import qt5reactor # pylint: disable=E0401
qt5reactor.install()
from twisted.internet import utils, reactor # pylint: disable=E0401
from twisted.internet import reactor # pylint: disable=E0401
app.setWindowIcon(QIcon(ICON_PATH))
os.environ["QT_QUICK_CONTROLS_STYLE"] = "Material"