Skip to content

Commit b62f4ba

Browse files
committed
Linux Hotfix (Program for Linux) 0.1.1b
1 parent 6318c89 commit b62f4ba

File tree

6 files changed

+129
-52
lines changed

6 files changed

+129
-52
lines changed

.idea/Streamhelper.iml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/__init__.py

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,43 @@
2424

2525

2626
def is_admin():
27-
try:
28-
return ctypes.windll.shell32.IsUserAnAdmin()
29-
except:
30-
return False
27+
if savestate.platform == "linux":
28+
return True
29+
else:
30+
try:
31+
return ctypes.windll.shell32.IsUserAnAdmin()
32+
except:
33+
return False
3134

3235

3336
class uiControlTest(QMainWindow):
34-
3537
if is_admin():
3638
def __init__(self):
3739
super(uiControlTest, self).__init__()
3840

3941
# Basic loading and startup operations
4042

41-
self.ui = uic.loadUi('uis\\mainALPHA.ui')
43+
self.ui = uic.loadUi('uis' + savestate.symbol + 'main.ui')
4244
window = self.ui
43-
window.setWindowIcon(QIcon("images\\icon.png"))
45+
window.setWindowIcon(QIcon("images" + savestate.symbol + "icon.png"))
4446
information("The Program is in developement! \n"
4547
"Currently, only the textfiles and numbers are working, the other stuff is WIP. . Masks aren't "
4648
"importable yet")
4749
self.ui.show()
4850

4951
# Check if the folder exists
50-
try:
51-
print("Trying to create the standard Folder...")
52-
os.mkdir(os.getenv('LOCALAPPDATA') + "\\StreamHelper")
53-
except FileExistsError:
54-
print("Folder exists!")
52+
if savestate.platform == "linux":
53+
try:
54+
print("Trying to create the standard Folder...")
55+
os.mkdir(savestate.home + "/Documents/StreamHelper")
56+
except FileExistsError:
57+
print("Folder exists!")
58+
else:
59+
try:
60+
print("Trying to create the standard Folder...")
61+
os.mkdir(os.getenv('LOCALAPPDATA') + "\\StreamHelper")
62+
except FileExistsError:
63+
print("Folder exists!")
5564

5665
# Lets create all the standard files (xml and txt) or at least check if they exist
5766
createStandardFiles(standardFilePath, 0)
@@ -64,7 +73,7 @@ def __init__(self):
6473
"importable yet \n")
6574

6675
# Parse the paths from the xml files so we know where to check for the files
67-
tree = ET.parse(standardFilePath + "\\config.xml")
76+
tree = ET.parse(standardFilePath + savestate.symbol + "config.xml")
6877
root = tree.getroot()
6978
dictStandard = root[0][1].attrib
7079
dictCustom = root[0][0].attrib
@@ -103,14 +112,15 @@ def __init__(self):
103112

104113
window.updateButton.clicked.connect(lambda: getTextOfItem(self, oldFilePath, newFilePath))
105114

106-
window.actionLog.triggered.connect(lambda: webbrowser.open(standardFilePath + "\\StreamLog.log"))
115+
window.actionLog.triggered.connect(lambda: webbrowser.open(standardFilePath + savestate.symbol +
116+
"StreamLog.log"))
107117

108118
window.actionVersion_Changes.triggered.connect(lambda: webbrowser.open("CHANGELOG.txt"))
109-
110-
111-
112119
else:
113-
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)
120+
if savestate.platform is 'linux':
121+
logWrite("The application could not be started in sudo mode!")
122+
else:
123+
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)
114124

115125

116126
if __name__ == "__main__":

resources/runtime/functions.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,28 +107,28 @@ def erroreasy(self, text, errorcode):
107107

108108
def initXMLFiles(path):
109109
for file in standardXMLNames:
110-
print("Opening files at " + path + "\\" + file + ".xml")
111-
open(path + "\\" + file + ".xml", "w+")
110+
print("Opening files at " + path + savestate.symbol + file + ".xml")
111+
open(path + savestate.symbol + file + ".xml", "w+")
112112

113113
data = ET.Element('data')
114114
filepath = ET.SubElement(data, "filepath")
115115
customfilepath = ET.SubElement(filepath, "CustomFilePath")
116116
standardFilePathXML = ET.SubElement(filepath, "StandardFilePath")
117117
customfilepath.set("path", standardFilePath)
118118
standardFilePathXML.set("path", standardFilePath)
119-
myfile = open(standardFilePath + "\\" + "config.xml", "w")
119+
myfile = open(standardFilePath + savestate.symbol + "config.xml", "w")
120120
myfile.write(ET.tostring(data).decode('utf-8'))
121121

122122

123123
def createStandardFiles(path, arg):
124124
print("Trying to create the standard Files with arg " + str(arg) + "...")
125125
try:
126-
os.mkdir(path + "\\textfiles")
126+
os.mkdir(path + savestate.symbol + "textfiles")
127127
except FileExistsError:
128128
print("Standard file folder exists!")
129129

130130
if arg == 0:
131-
if exists(path + "\\config.xml"):
131+
if exists(path + savestate.symbol + "config.xml"):
132132
print("XML Files exist, not creating any new ones")
133133
else:
134134
initXMLFiles(path)
@@ -138,7 +138,7 @@ def createStandardFiles(path, arg):
138138

139139

140140
def logCreate():
141-
logname = "\\StreamLog.log"
141+
logname = savestate.symbol + "StreamLog.log"
142142

143143
z = open(standardFilePath + logname, "w+")
144144
z.write("Log initialized on " + str(datetime.datetime.now(tz=None)) + "\n" + "\n")
@@ -152,7 +152,7 @@ def logCreate():
152152

153153
def logWrite(text):
154154
now = datetime.datetime.now()
155-
logname = standardFilePath + "\\StreamLog.log"
155+
logname = standardFilePath + savestate.symbol + "StreamLog.log"
156156
try:
157157
z = open(logname, "a")
158158
except FileNotFoundError:
@@ -162,7 +162,7 @@ def logWrite(text):
162162

163163

164164
def logWriteNoTime(text):
165-
logname = standardFilePath + "\\StreamLog.log"
165+
logname = standardFilePath + savestate.symbol + "StreamLog.log"
166166
try:
167167
z = open(logname, "a")
168168
except FileNotFoundError:

resources/runtime/interactions.py

Lines changed: 67 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def addListElement(self):
2323

2424
# text, ok = QInputDialog.getText(self, 'Enter Name',
2525
# 'Enter the desired name for your object:')
26-
itemselect = uic.loadUi("uis\\SelectionDialog.ui")
26+
itemselect = uic.loadUi("uis" + savestate.symbol + "SelectionDialog.ui")
2727
itemselect.setWindowTitle("Itemselection")
2828
itemselect.buttonBox.accepted.connect(itemselect.accept)
2929
itemselect.buttonBox.rejected.connect(itemselect.reject)
@@ -51,7 +51,7 @@ def addListElement(self):
5151
elif item == 3:
5252
# Creates a CHRONOS item which writes time or dates to textfiles
5353
if ok:
54-
information("Not implemented yet!")
54+
createChronoItem(self, text, "", 3)
5555
# savestate.itemorder.append(savestate.itemType.CHRONOS) TODO
5656

5757

@@ -65,7 +65,7 @@ def createTextItem(self, text, value, slist):
6565
print("Added item: " + str(item))
6666
logWrite("Added item: " + str(item[savestate.count]) + "\n")
6767

68-
wid = uic.loadUi("uis\\TextFileWidget.ui")
68+
wid = uic.loadUi("uis" + savestate.symbol + "TextFileWidget.ui")
6969
wid.setStyleSheet(savestate.shortBorder)
7070
wid.label.setText(text)
7171

@@ -83,7 +83,7 @@ def createTextItem(self, text, value, slist):
8383
savestate.count = leftOne.count()
8484
item = {savestate.count: str(text)}
8585
print("Added item: " + str(item))
86-
wid = uic.loadUi("uis\\TextFileWidget.ui")
86+
wid = uic.loadUi("uis" + savestate.symbol + "TextFileWidget.ui")
8787
wid.setStyleSheet(savestate.shortBorder)
8888
wid.label.setText(text)
8989
if value:
@@ -108,7 +108,7 @@ def createNumberItem(self: QMainWindow, text: str, value: int, listnr: int, pret
108108
savestate.count = leftOne.count()
109109
item = {savestate.count: str(text)}
110110
print("Added item: " + str(item))
111-
wid = uic.loadUi("uis\\NumberWidget.ui")
111+
wid = uic.loadUi("uis" + savestate.symbol + "NumberWidget.ui")
112112
wid.setStyleSheet(savestate.shortBorder)
113113
wid.label.setText(text)
114114

@@ -130,7 +130,7 @@ def createNumberItem(self: QMainWindow, text: str, value: int, listnr: int, pret
130130
item = {savestate.count: str(text)}
131131
print("Added item: " + str(item))
132132

133-
wid = uic.loadUi("uis\\NumberWidget.ui")
133+
wid = uic.loadUi("uis" + savestate.symbol + "NumberWidget.ui")
134134
wid.setStyleSheet(savestate.shortBorder)
135135
wid.label.setText(text)
136136

@@ -150,6 +150,52 @@ def createNumberItem(self: QMainWindow, text: str, value: int, listnr: int, pret
150150
information("Please select a list to add the object!")
151151

152152

153+
def createChronoItem(self, text, value, listnr):
154+
leftOne = self.ui.listWidget
155+
rightOne = self.ui.listWidget_2
156+
157+
if listnr == 0 or self.ui.addleft.isChecked():
158+
savestate.count = leftOne.count()
159+
item = {savestate.count: str(text)}
160+
print("Added item: " + str(item))
161+
wid = uic.loadUi("uis" + savestate.symbol + "ChronoWidget.ui")
162+
wid.setStyleSheet(savestate.shortBorder)
163+
wid.label.setText(text)
164+
165+
wid.showTime.setText(value)
166+
167+
wid.setWhatsThis("chrono")
168+
item[savestate.count] = QListWidgetItem()
169+
item[savestate.count].setFlags(item[savestate.count].flags() | Qt.ItemIsEditable)
170+
item[savestate.count].setData(5, text)
171+
item[savestate.count].setSizeHint(QSize(270, 80))
172+
leftOne.addItem(item[savestate.count])
173+
leftOne.setItemWidget(item[savestate.count], wid)
174+
175+
elif listnr == 1 or self.ui.addright.isChecked():
176+
177+
savestate.count = rightOne.count()
178+
item = {savestate.count: str(text)}
179+
print("Added item: " + str(item))
180+
181+
wid = uic.loadUi("uis" + savestate.symbol + "ChronoWidget.ui")
182+
wid.setStyleSheet(savestate.shortBorder)
183+
wid.label.setText(text)
184+
185+
wid.showTime.setText(value)
186+
187+
wid.setWhatsThis("chrono")
188+
item[savestate.count] = QListWidgetItem()
189+
item[savestate.count].setFlags(item[savestate.count].flags() | Qt.ItemIsEditable)
190+
item[savestate.count].setData(5, savestate.count + 1)
191+
item[savestate.count].setSizeHint(QSize(270, 80))
192+
rightOne.addItem(item[savestate.count])
193+
rightOne.setItemWidget(item[savestate.count], wid)
194+
195+
else:
196+
information("Please select a list to add the object!")
197+
198+
153199
def autTextListElement(self, name, nr, value, *itemType):
154200
"""
155201
@@ -177,7 +223,7 @@ def autTextListElement(self, name, nr, value, *itemType):
177223
print("Added item: " + str(dictname.get(savestate.count)) + "\n")
178224

179225
# create the widget and set the text
180-
wid = uic.loadUi("uis\\TextFileWidget.ui")
226+
wid = uic.loadUi("uis" + savestate.symbol + "TextFileWidget.ui")
181227
wid.setStyleSheet(savestate.shortBorder)
182228
wid.label.setText(text)
183229

@@ -197,7 +243,7 @@ def autTextListElement(self, name, nr, value, *itemType):
197243
savestate.count = leftOne.count()
198244
dictname = {savestate.count: str(text)}
199245
print("Added item: " + str(dictname.get(savestate.count)) + "\n")
200-
wid = uic.loadUi("uis\\TextFileWidget.ui")
246+
wid = uic.loadUi("uis" + savestate.symbol + "TextFileWidget.ui")
201247
wid.setStyleSheet(savestate.shortBorder)
202248
wid.label.setText(text)
203249
wid.lineEdit.setText(value)
@@ -218,7 +264,7 @@ def getTextOfItem(self, path, altpath, *item):
218264
# that item in the form: "text" #unique "label" so it can be split. item should be a number
219265

220266
# init the xml file for the textfiles
221-
xmlFile = open(path + "\\autosave.xml", "w+")
267+
xmlFile = open(path + savestate.symbol + "autosave.xml", "w+")
222268

223269
# Introducing the xml data tree
224270
data = ET.Element('data')
@@ -364,14 +410,14 @@ def createListFiles(self, newpath):
364410
logWrite("Trying to recall what was in the list...")
365411

366412
# delete old textfiles and create a new empty folder
367-
emptyDir(newpath + "\\textfiles")
368-
os.mkdir(newpath + "\\textfiles")
413+
emptyDir(newpath + savestate.symbol + "textfiles")
414+
os.mkdir(newpath + savestate.symbol + "textfiles")
369415
logWrite("Deleted old textfiles and created a fresh folder!\n")
370416

371417
# Lets look in the xml so we know what was up
372418
try:
373419
print(savestate.standardFilePath)
374-
source = ET.parse(savestate.standardFilePath + "\\autosave.xml")
420+
source = ET.parse(savestate.standardFilePath + savestate.symbol + "autosave.xml")
375421
sourceroot = source.getroot()
376422
logWrite("Parsing autosave...")
377423

@@ -423,7 +469,7 @@ def createListFiles(self, newpath):
423469

424470
def createTextFile(name, path, text):
425471
# This method is used to create and edit the textfiles used around the program.
426-
filename = str(path + "\\textfiles\\" + name + ".txt")
472+
filename = str(path + savestate.symbol + "textfiles" + savestate.symbol + name + ".txt")
427473

428474
file = open(filename, "w+")
429475
file.write(text)
@@ -432,7 +478,7 @@ def createTextFile(name, path, text):
432478

433479

434480
def deleteTextFile(name, path):
435-
filename = str(path + "\\textfiles\\" + name + ".txt")
481+
filename = str(path + savestate.symbol + "textfiles" + savestate.symbol + name + ".txt")
436482
os.remove(filename)
437483

438484

@@ -443,6 +489,7 @@ def emptyDir(path):
443489

444490
logWrite("The folder could not be found!")
445491

492+
446493
'''
447494
def autListElement(self, name, nr, value, itemType):
448495
if itemType == "text":
@@ -458,7 +505,7 @@ def saveConfig(self, basefilepath):
458505
# saves the current lists to a separate file
459506
filepath = QFileDialog.getSaveFileName(self, "Create Save", basefilepath, ".oi")
460507
file = str(filepath[0] + ".oi")
461-
savefile = shutil.copy(str(savestate.standardFilePath + "\\autosave.xml"), file)
508+
savefile = shutil.copy(str(savestate.standardFilePath + savestate.symbol + "autosave.xml"), file)
462509

463510

464511
def loadConfig(self, basefilepath):
@@ -474,8 +521,8 @@ def loadConfig(self, basefilepath):
474521
logWrite("Trying to parse input file...")
475522

476523
# delete old textfiles and create a new empty folder
477-
emptyDir(basefilepath + "\\textfiles")
478-
os.mkdir(basefilepath + "\\textfiles")
524+
emptyDir(basefilepath + savestate.symbol + "textfiles")
525+
os.mkdir(basefilepath + savestate.symbol + "textfiles")
479526
logWrite("Deleted old textfiles and created a fresh folder!\n")
480527

481528
# After parsing we need to get the values for each field. Then we put it in the list. Sorry for the naming here,
@@ -533,7 +580,7 @@ def setFilePath(self, oldpath):
533580
if len(text) > 0:
534581
if ":" in text:
535582
# delete the old textfiles folder so theres no garbage floating around
536-
emptyDir(oldpath + "\\textfiles")
583+
emptyDir(oldpath + savestate.symbol + "textfiles")
537584

538585
setNewFilePath(self, text)
539586

@@ -545,21 +592,18 @@ def setFilePath(self, oldpath):
545592

546593

547594
def setNewFilePath(self, path):
548-
549595
# initialize the file path and create the standard files at that location
550596
print(path)
551597
logWrite("New textfilepath will be " + str(path))
552598
createStandardFiles(path, 1)
553599

554-
555-
556600
logWrite("Created the new textfiles at new path")
557601
# set the new filepath into the xml document so it gets saved for the next startup
558-
tree = ET.parse(standardFilePath + "\\config.xml")
602+
tree = ET.parse(standardFilePath + savestate.symbol + "config.xml")
559603
root = tree.getroot()
560604

561605
root[0][0].set("path", path)
562-
tree.write(standardFilePath + "\\config.xml")
606+
tree.write(standardFilePath + savestate.symbol + "config.xml")
563607
print(root[0][0].attrib)
564608

565609
# reset the two list widgets and reload the items from the xml

0 commit comments

Comments
 (0)