Builder
This commit is contained in:
114
daun-builder.py
114
daun-builder.py
@@ -0,0 +1,114 @@
|
||||
import shutil
|
||||
import sys
|
||||
import os
|
||||
import modules.require # install required modules
|
||||
from modules.thread import threaded
|
||||
from modules.scrape import prep, parsers, functions
|
||||
import ui.main as uimain
|
||||
from PyQt5 import QtCore, QtWidgets
|
||||
from ui.gui import popup, cls
|
||||
import tempfile
|
||||
|
||||
app = QtWidgets.QApplication(sys.argv)
|
||||
MainWindow = QtWidgets.QMainWindow()
|
||||
ui = uimain.Ui_MainWindow()
|
||||
ui.setupUi(MainWindow)
|
||||
|
||||
icon_path = 'ui/logo.ico'
|
||||
|
||||
for name in list(parsers):
|
||||
item = QtWidgets.QListWidgetItem(name)
|
||||
item.setCheckState(QtCore.Qt.Checked)
|
||||
ui.modules_list.addItem(item)
|
||||
|
||||
MainWindow.show()
|
||||
|
||||
|
||||
def choose_icon():
|
||||
global icon_path
|
||||
icon_path = QtWidgets.QFileDialog.getOpenFileName(
|
||||
None,
|
||||
'Choose custom icon for daun',
|
||||
os.getenv('USERPROFILE') + '/Pictures',
|
||||
'*.ico'
|
||||
)[0]
|
||||
if icon_path == '':
|
||||
icon_path = 'ui/logo.ico'
|
||||
print(icon_path)
|
||||
|
||||
|
||||
@threaded
|
||||
def build(*args):
|
||||
tempdir = tempfile.TemporaryDirectory()
|
||||
temp = os.path.join(tempdir.name)
|
||||
ui.build_button.setEnabled(False)
|
||||
modules_to_add = list()
|
||||
for i in range(ui.modules_list.count()):
|
||||
if ui.modules_list.item(i).checkState():
|
||||
modules_to_add.append(ui.modules_list.item(i).text())
|
||||
with open('daun-to-build.py', 'w+') as f:
|
||||
f.writelines(prep['Before'])
|
||||
for module in list(parsers):
|
||||
if module in modules_to_add:
|
||||
f.writelines(parsers[module])
|
||||
f.writelines(prep['Parse args'])
|
||||
for module in list(functions):
|
||||
if module in modules_to_add:
|
||||
f.writelines(functions[module][1])
|
||||
|
||||
if ui.path_box.text() == '':
|
||||
ui.path_box.setText(os.getenv('USERPROFILE') + '/Desktop/daun.exe')
|
||||
|
||||
popup('Build', 'File is generated, press OK to build exe.\n'
|
||||
'Logs will appear in terminal.')
|
||||
cls()
|
||||
if ui.is_pyinstaller.isChecked():
|
||||
os.system(f'pyinstaller --onefile --{"console" if not ui.enable_console_button.isChecked() else "windowed"} '
|
||||
f'--noconfirm --icon {icon_path} --workpath {temp} daun-to-build.py')
|
||||
try:
|
||||
shutil.move(f'{os.getcwd()}/dist/daun-to-build.exe', ui.path_box.text())
|
||||
os.remove(f'daun-to-build.py')
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
if ui.is_nuitka.isChecked():
|
||||
os.system(f'nuitka --standalone --assume-yes-for-downloads --remove-output --disable-dll-dependency-cache '
|
||||
f'--onefile --windows-icon-from-ico={icon_path} '
|
||||
f'{"" if not ui.enable_console_button.isChecked() else "--windows-disable-console"} daun-to-build.py')
|
||||
try:
|
||||
shutil.move(f'{os.getcwd()}/daun-to-build.dist/daun-to-build.exe', ui.path_box.text())
|
||||
os.remove(f'daun-to-build.py')
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
ui.build_button.setEnabled(True)
|
||||
popup('Build', 'Builder process exited.\n'
|
||||
'You will find the executable\n'
|
||||
'in the path you specified\n'
|
||||
'if the build was successful.')
|
||||
|
||||
|
||||
show_desc = lambda: ui.desc_list.setText(functions[ui.modules_list.currentItem().text()][0])
|
||||
ui.modules_list.setCurrentItem(ui.modules_list.item(0))
|
||||
ui.modules_list.itemClicked.connect(show_desc)
|
||||
ui.modules_list.currentItemChanged.connect(show_desc)
|
||||
ui.modules_list.itemDoubleClicked.connect(lambda:
|
||||
ui.modules_list.currentItem().setCheckState(
|
||||
QtCore.Qt.Unchecked if ui.modules_list.currentItem().checkState()
|
||||
else QtCore.Qt.Checked
|
||||
)
|
||||
)
|
||||
ui.choose_folder_button.clicked.connect(lambda:
|
||||
ui.path_box.setText(
|
||||
QtWidgets.QFileDialog.getSaveFileName(
|
||||
None,
|
||||
'Choose where to save daun',
|
||||
os.getenv('USERPROFILE') + '/Desktop/daun.exe',
|
||||
'*.exe'
|
||||
)[0]
|
||||
)
|
||||
)
|
||||
ui.choose_icon_button.clicked.connect(choose_icon)
|
||||
ui.build_button.clicked.connect(build)
|
||||
|
||||
sys.exit(app.exec_())
|
||||
|
||||
22
daun.py
22
daun.py
@@ -4,6 +4,7 @@ import argparse
|
||||
parser = argparse.ArgumentParser(prog='daun',
|
||||
description='Dumb Additional Util Nativeier - if you see this but didn\'t download '
|
||||
'it, you may have a virus or your friend is motherhacker :)')
|
||||
# - Base ///
|
||||
# - Path ///
|
||||
parser.add_argument('--add-path', help='folder to add to path',
|
||||
metavar='P:/ath/To/Folder', dest='add_path')
|
||||
@@ -37,9 +38,18 @@ parser.add_argument('--pid', help='get pid by name or name by pid',
|
||||
# --- Parse args ///
|
||||
args = parser.parse_args()
|
||||
|
||||
# -- Base ///
|
||||
"""
|
||||
Base daun library, this module does not contain any code and will be added anyway
|
||||
|
||||
7.61 Mb
|
||||
"""
|
||||
|
||||
# -- Path ///
|
||||
"""
|
||||
Actions with PATH and environment variables
|
||||
|
||||
1 Kb
|
||||
"""
|
||||
if args.add_path:
|
||||
from modules import path
|
||||
@@ -56,6 +66,8 @@ if args.add_var:
|
||||
# -- Screenshot ///
|
||||
"""
|
||||
Make a screenshot of all screens and save it to specified file or to imgur
|
||||
|
||||
2.9 Mb
|
||||
"""
|
||||
if args.screenshot:
|
||||
from modules import screenshot
|
||||
@@ -71,6 +83,8 @@ if args.screenshot:
|
||||
# -- Wallpaper Engine Control ///
|
||||
"""
|
||||
Control wallpaper engine
|
||||
|
||||
0.3 Mb
|
||||
"""
|
||||
if args.wp_control:
|
||||
from modules.wallpaperengine import control_we
|
||||
@@ -80,6 +94,8 @@ if args.wp_control:
|
||||
# -- Wallpaper ///
|
||||
"""
|
||||
Set wallpapers
|
||||
|
||||
2.8 Mb
|
||||
"""
|
||||
if args.set_wallpaper:
|
||||
from modules.wallpaper import set_wallpaper
|
||||
@@ -89,15 +105,19 @@ if args.set_wallpaper:
|
||||
# -- Download ///
|
||||
"""
|
||||
Download file from url to specified
|
||||
|
||||
2.8 Mb
|
||||
"""
|
||||
if args.download:
|
||||
from modules.download import download
|
||||
|
||||
download(args.download[0], args.download[1])
|
||||
|
||||
# - Process ///
|
||||
# -- Process ///
|
||||
"""
|
||||
Action with windows processes
|
||||
|
||||
0.29 Mb
|
||||
"""
|
||||
if args.get_proc_path:
|
||||
from modules.process import get_location
|
||||
|
||||
4
modules/require.py
Normal file
4
modules/require.py
Normal file
@@ -0,0 +1,4 @@
|
||||
import sys
|
||||
import os
|
||||
|
||||
os.system(sys.executable + " -m pip install -r requirements.txt")
|
||||
25
modules/scrape.py
Normal file
25
modules/scrape.py
Normal file
@@ -0,0 +1,25 @@
|
||||
prep, parsers, functions = dict(), dict(), dict()
|
||||
|
||||
with open("daun.py", 'r') as f:
|
||||
daun_code = f.readlines()
|
||||
|
||||
i = 0
|
||||
while i < len(daun_code):
|
||||
if daun_code[i][-2:-5:-1] == '///':
|
||||
line = daun_code[i].replace('///', '').replace('\n', '').replace('#', '').strip()
|
||||
i += 1
|
||||
add_this = str()
|
||||
while i < len(daun_code) and daun_code[i][-2:-5:-1] != '///':
|
||||
add_this += daun_code[i]
|
||||
i += 1
|
||||
match line.split(' ')[0].count('-'):
|
||||
case 3:
|
||||
prep[line.replace('-', '').strip()] = add_this
|
||||
case 2:
|
||||
functions[line.replace('-', '').strip()] = \
|
||||
[
|
||||
add_this.split('"""')[1].strip(),
|
||||
add_this.split('"""')[2]
|
||||
]
|
||||
case 1:
|
||||
parsers[line.replace('-', '').strip()] = add_this
|
||||
20
ui/gui.py
Normal file
20
ui/gui.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import ctypes
|
||||
import os
|
||||
|
||||
|
||||
def popup(title, text, style=0):
|
||||
"""
|
||||
Styles:
|
||||
0 : OK
|
||||
1 : OK | Cancel
|
||||
2 : Abort | Retry | Ignore
|
||||
3 : Yes | No | Cancel
|
||||
4 : Yes | No
|
||||
5 : Retry | Cancel
|
||||
6 : Cancel | Try Again | Continue
|
||||
"""
|
||||
return ctypes.windll.user32.MessageBoxW(0, text, title, style)
|
||||
|
||||
|
||||
def cls():
|
||||
os.system("cls" if os.name == "nt" else "clear")
|
||||
@@ -256,7 +256,7 @@ class Ui_MainWindow(object):
|
||||
self.is_nuitka.setText(_translate("MainWindow", "nuitka"))
|
||||
self.label.setText(_translate("MainWindow", "Choose builder"))
|
||||
self.enable_console_button.setText(_translate("MainWindow", "Invisible window"))
|
||||
import images_rc
|
||||
import ui.images_rc
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user