Revert "Trying to fix windows issue with chdir not working."
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This reverts commit 29ecc0585d
.
This commit is contained in:
parent
61c5ef4c30
commit
e5b7e0c129
1 changed files with 18 additions and 11 deletions
|
@ -35,12 +35,13 @@ from webbrowser import open as openWeb
|
||||||
|
|
||||||
# Create the temporary file for saving copied screenshots
|
# Create the temporary file for saving copied screenshots
|
||||||
fd, tmpfile = mkstemp(suffix='.png')
|
fd, tmpfile = mkstemp(suffix='.png')
|
||||||
|
pwd = getcwd()
|
||||||
|
|
||||||
current_dir = path.dirname(path.realpath(__file__))
|
chdir(path.dirname(path.realpath(__file__)))
|
||||||
|
|
||||||
from sys import path as sys_path
|
from sys import path as sys_path
|
||||||
if path.realpath(path.join(current_dir, "..")) not in sys_path:
|
if path.realpath(path.join(getcwd(), "..")) not in sys_path:
|
||||||
sys_path.append(path.realpath(path.join(current_dir, "..")))
|
sys_path.append(path.realpath(path.join(getcwd(), "..")))
|
||||||
|
|
||||||
|
|
||||||
from LogarithmPlotter import config, native, __VERSION__
|
from LogarithmPlotter import config, native, __VERSION__
|
||||||
|
@ -65,6 +66,7 @@ class Helper(QObject):
|
||||||
|
|
||||||
@Slot(str, str)
|
@Slot(str, str)
|
||||||
def write(self, filename, filedata):
|
def write(self, filename, filedata):
|
||||||
|
chdir(pwd)
|
||||||
if path.exists(path.dirname(path.realpath(filename))):
|
if path.exists(path.dirname(path.realpath(filename))):
|
||||||
if filename.split(".")[-1] == "lpf":
|
if filename.split(".")[-1] == "lpf":
|
||||||
# Add header to file
|
# Add header to file
|
||||||
|
@ -72,9 +74,11 @@ class Helper(QObject):
|
||||||
f = open(path.realpath(filename), 'w', -1, 'utf8')
|
f = open(path.realpath(filename), 'w', -1, 'utf8')
|
||||||
f.write(filedata)
|
f.write(filedata)
|
||||||
f.close()
|
f.close()
|
||||||
|
chdir(path.dirname(path.realpath(__file__)))
|
||||||
|
|
||||||
@Slot(str, result=str)
|
@Slot(str, result=str)
|
||||||
def load(self, filename):
|
def load(self, filename):
|
||||||
|
chdir(pwd)
|
||||||
data = '{}'
|
data = '{}'
|
||||||
if path.exists(path.realpath(filename)):
|
if path.exists(path.realpath(filename)):
|
||||||
f = open(path.realpath(filename), 'r', -1, 'utf8')
|
f = open(path.realpath(filename), 'r', -1, 'utf8')
|
||||||
|
@ -93,6 +97,7 @@ class Helper(QObject):
|
||||||
QMessageBox.warning(None, 'LogarithmPlotter', 'Could not open file "{}":\n{}'.format(filename, e), QMessageBox.Ok) # Cannot parse file
|
QMessageBox.warning(None, 'LogarithmPlotter', 'Could not open file "{}":\n{}'.format(filename, e), QMessageBox.Ok) # Cannot parse file
|
||||||
else:
|
else:
|
||||||
QMessageBox.warning(None, 'LogarithmPlotter', 'Could not open file: "{}"\nFile does not exist.'.format(filename), QMessageBox.Ok) # Cannot parse file
|
QMessageBox.warning(None, 'LogarithmPlotter', 'Could not open file: "{}"\nFile does not exist.'.format(filename), QMessageBox.Ok) # Cannot parse file
|
||||||
|
chdir(path.dirname(path.realpath(__file__)))
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@Slot(result=str)
|
@Slot(result=str)
|
||||||
|
@ -151,15 +156,15 @@ def run():
|
||||||
print("Loaded dependencies in " + str((dep_time - start_time)*1000) + "ms.")
|
print("Loaded dependencies in " + str((dep_time - start_time)*1000) + "ms.")
|
||||||
|
|
||||||
icon_fallbacks = QIcon.fallbackSearchPaths();
|
icon_fallbacks = QIcon.fallbackSearchPaths();
|
||||||
icon_fallbacks.append(path.realpath(path.join(current_dir, "qml", "eu", "ad5001", "LogarithmPlotter", "icons")))
|
icon_fallbacks.append(path.realpath(path.join(getcwd(), "qml", "eu", "ad5001", "LogarithmPlotter", "icons")))
|
||||||
icon_fallbacks.append(path.realpath(path.join(current_dir, "qml", "eu", "ad5001", "LogarithmPlotter", "icons", "settings")))
|
icon_fallbacks.append(path.realpath(path.join(getcwd(), "qml", "eu", "ad5001", "LogarithmPlotter", "icons", "settings")))
|
||||||
icon_fallbacks.append(path.realpath(path.join(current_dir, "qml", "eu", "ad5001", "LogarithmPlotter", "icons", "settings", "custom")))
|
icon_fallbacks.append(path.realpath(path.join(getcwd(), "qml", "eu", "ad5001", "LogarithmPlotter", "icons", "settings", "custom")))
|
||||||
QIcon.setFallbackSearchPaths(icon_fallbacks);
|
QIcon.setFallbackSearchPaths(icon_fallbacks);
|
||||||
|
|
||||||
app = QApplication(argv)
|
app = QApplication(argv)
|
||||||
app.setApplicationName("LogarithmPlotter")
|
app.setApplicationName("LogarithmPlotter")
|
||||||
app.setOrganizationName("Ad5001")
|
app.setOrganizationName("Ad5001")
|
||||||
app.setWindowIcon(QIcon(path.realpath(path.join(current_dir, "logarithmplotter.svg"))))
|
app.setWindowIcon(QIcon(path.realpath(path.join(getcwd(), "logarithmplotter.svg"))))
|
||||||
|
|
||||||
# Installing macOS file handler.
|
# Installing macOS file handler.
|
||||||
macOSFileOpenHandler = None
|
macOSFileOpenHandler = None
|
||||||
|
@ -173,16 +178,18 @@ def run():
|
||||||
engine.rootContext().setContextProperty("TestBuild", "--test-build" in argv)
|
engine.rootContext().setContextProperty("TestBuild", "--test-build" in argv)
|
||||||
engine.rootContext().setContextProperty("StartTime", dep_time)
|
engine.rootContext().setContextProperty("StartTime", dep_time)
|
||||||
|
|
||||||
engine.addImportPath(path.realpath(path.join(current_dir, "qml")))
|
engine.addImportPath(path.realpath(path.join(getcwd(), "qml")))
|
||||||
engine.load(path.realpath(path.join(current_dir, "qml", "eu", "ad5001", "LogarithmPlotter", "LogarithmPlotter.qml")))
|
engine.load(path.realpath(path.join(getcwd(), "qml", "eu", "ad5001", "LogarithmPlotter", "LogarithmPlotter.qml")))
|
||||||
|
|
||||||
if not engine.rootObjects():
|
if not engine.rootObjects():
|
||||||
print("No root object", path.realpath(path.join(current_dir, "qml")))
|
print("No root object", path.realpath(path.join(getcwd(), "qml")))
|
||||||
print(path.realpath(path.join(current_dir, "qml", "eu", "ad5001", "LogarithmPlotter", "LogarithmPlotter.qml")))
|
print(path.realpath(path.join(getcwd(), "qml", "eu", "ad5001", "LogarithmPlotter", "LogarithmPlotter.qml")))
|
||||||
exit(-1)
|
exit(-1)
|
||||||
|
|
||||||
|
chdir(pwd)
|
||||||
if len(argv) > 0 and path.exists(argv[-1]) and argv[-1].split('.')[-1] in ['lpf']:
|
if len(argv) > 0 and path.exists(argv[-1]) and argv[-1].split('.')[-1] in ['lpf']:
|
||||||
engine.rootObjects()[0].loadDiagram(argv[-1])
|
engine.rootObjects()[0].loadDiagram(argv[-1])
|
||||||
|
chdir(path.dirname(path.realpath(__file__)))
|
||||||
|
|
||||||
if platform == "darwin":
|
if platform == "darwin":
|
||||||
macOSFileOpenHandler.init_graphics(engine.rootObjects()[0])
|
macOSFileOpenHandler.init_graphics(engine.rootObjects()[0])
|
||||||
|
|
Loading…
Reference in a new issue