-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshortcut.py
94 lines (74 loc) · 2.57 KB
/
shortcut.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import glob
import os
import sys
import sys
import PyQt5
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
def makeShortcuts (inputPath,outputPath):
try:
currentPath = inputPath+"/**/*.exe"
for f in glob.glob(currentPath, recursive=True):
if("UnityCrashHandler" not in f):
# Make a link on the desktop
print(f)
# Check that the file doesn't already exist
if not os.path.exists(os.path.expanduser(outputPath+"/"+os.path.basename(f))):
os.symlink(f, os.path.expanduser(outputPath+"/"+os.path.basename(f)))
except:
# print the error
print("An error occurred: ", sys.exc_info()[0])
class window(QWidget):
def __init__(self, parent = None):
super(window, self).__init__(parent)
self.resize(800,100)
self.setWindowTitle("Game Lab Shortcut Creator")
self.label = QLabel(self)
self.label.setText("Input Path:")
self.label.move(100,5)
self.labelThree = QLabel(self)
self.labelThree.move(100,65)
self.labelTwo = QLabel(self)
self.labelTwo.setText("Output Path:")
self.labelTwo.move(100,35)
# Select input
self.inputButton = QPushButton(self)
self.inputButton.setText("Select")
self.inputButton.clicked.connect(self.selectInput)
# Select output
self.inputButton = QPushButton(self)
self.inputButton.setText("Select")
self.inputButton.move(0,30)
self.inputButton.clicked.connect(self.selectOutput)
# Run button
self.inputButton = QPushButton(self)
self.inputButton.setText("Run")
self.inputButton.move(0,60)
self.inputButton.clicked.connect(self.runCommand)
def selectInput(self):
file = QFileDialog.getExistingDirectory(self, "Select Directory")
self.inputFilePath = file
print(file)
self.label.setText("Input Path:"+file)
self.label.adjustSize()
self.label.update()
def selectOutput(self):
file = QFileDialog.getExistingDirectory(self, "Select Directory")
self.outputPath = file
print(file)
self.labelTwo.setText("Output Path:"+file)
self.labelTwo.adjustSize()
self.labelTwo.update()
def runCommand(self):
makeShortcuts(self.inputFilePath, self.outputPath)
self.labelThree.setText("Done!")
self.labelThree.adjustSize()
self.labelThree.update()
def main():
app = QApplication(sys.argv)
ex = window()
ex.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()